1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-28 05:10:31 -04:00
jarv.is/layouts/partials/functions/prepare-js.html
Jake Jarvis 3a3849e8ec
add a partial template that returns an asset's URL and hash from webpack's manifest
still a mess but slightly more modular. also added a real 404 page.
2021-09-03 11:16:27 -04:00

39 lines
1.3 KiB
HTML

{{/* Pull in JS processed by Webpack */}}
{{- define "__head_preload" -}}
{{ with partial "functions/webpack" (dict "context" . "src" "fonts/inter-subset.var.woff2") }}
<link rel="preload" href="{{ .src }}" as="font" type="font/woff2" crossorigin>
{{ end }}
{{ with partial "functions/webpack" (dict "context" . "src" "fonts/roboto-mono-subset.var.woff2") }}
<link rel="preload" href="{{ .src }}" as="font" type="font/woff2" crossorigin>
{{ end }}
{{ with partial "functions/webpack" (dict "context" . "src" "main.js") }}
<link rel="preload" href="{{ .src }}" as="script">
{{ end }}
{{- end -}}
{{- define "__body_js" -}}
{{ with partial "functions/webpack" (dict "context" . "src" "main.js") }}
<script async defer src="{{ .src }}"></script>
{{ end }}
{{/* Detect shortcodes and append external scripts as needed once per page */}}
{{ if .HasShortcode "gh-buttons" -}}
{{ template "__shortcode_gh-buttons_js" $ }}
{{ end -}}
{{ if .HasShortcode "tweet" -}}
{{ template "__shortcode_twitter_js" $ }}
{{ end -}}
{{ if .HasShortcode "facebook" -}}
{{ template "__shortcode_facebook_js" $ }}
{{ end -}}
{{ if .HasShortcode "instagram" -}}
{{ template "__shortcode_instagram_js" $ }}
{{ end -}}
{{ if .HasShortcode "vimeo" -}}
{{ template "__shortcode_vimeo_js" $ }}
{{ end -}}
{{- end -}}