1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-12-03 02:48:56 -05:00

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.
This commit is contained in:
2021-09-03 11:16:27 -04:00
parent a304fa5079
commit 3a3849e8ec
13 changed files with 97 additions and 111 deletions

View File

@@ -1,25 +1,23 @@
{{/* Pull in JS processed by Webpack */}}
{{- define "__head_preload" -}}
{{ with .Site.Data.manifest }}
{{ with index . "fonts/inter-subset.var.woff2" }}
<link rel="preload" href="{{ .src | absURL }}" as="font" type="font/woff2" crossorigin>
{{ end }}
{{ with index . "fonts/roboto-mono-subset.var.woff2" }}
<link rel="preload" href="{{ .src | absURL }}" as="font" type="font/woff2" crossorigin>
{{ end }}
{{ with index . "main.js" }}
<link rel="preload" href="{{ .src | absURL }}" as="script">
{{ end }}
{{ 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 .Site.Data.manifest }}
{{ with index . "main.js" -}}
<script async defer src="{{ .src | absURL }}"></script>
{{ end -}}
{{ end -}}
{{ 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" -}}