mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-07-18 22:05:29 -04:00
bundle simple analytics script locally & minify everything with terser
This commit is contained in:
@@ -12,9 +12,6 @@
|
||||
{{ partialCached "page/footer" . }}
|
||||
{{ partial "scripts/_bundle" . }}
|
||||
{{ partial "scripts/shortcodes" . }}
|
||||
{{ if eq hugo.Environment "production" }}
|
||||
{{ partialCached "scripts/simple_analytics" . }}
|
||||
{{ end }}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@@ -5,14 +5,6 @@
|
||||
X-Frame-Options: sameorigin
|
||||
X-XSS-Protection: 1; mode=block
|
||||
|
||||
# Long cache (one week) for vendored and fingerprinted assets:
|
||||
/css/*
|
||||
Cache-Control: public, max-age=604800, immutable
|
||||
/js/*
|
||||
Cache-Control: public, max-age=604800, immutable
|
||||
/vendor/*
|
||||
Cache-Control: public, max-age=604800, immutable
|
||||
|
||||
# Recommended MIME type for PWA manifests:
|
||||
# https://github.com/w3c/manifest/issues/689
|
||||
/site.webmanifest
|
||||
|
@@ -1,11 +1,9 @@
|
||||
{{ $style := resources.Get "sass/main.scss" | resources.ExecuteAsTemplate "sass/main.scss" . | resources.ToCSS (dict "targetPath" "css/main.min.css") | resources.PostCSS (dict "config" "postcss.config.js") | resources.Fingerprint "sha256" }}
|
||||
{{ $style := resources.Get "sass/main.scss" | resources.ExecuteAsTemplate "sass/main.scss" . | resources.ToCSS (dict "targetPath" "css/main.css") | resources.PostCSS (dict "config" "postcss.config.js") }}
|
||||
<link rel="stylesheet" href="{{ $style.Permalink }}">
|
||||
|
||||
{{/* Page-specific styles set via front matter, scoped via SCSS */}}
|
||||
{{ with .Params.css }}
|
||||
{{- $target := path.Join $.File.Dir "css/inline.min.scss" }}
|
||||
|
||||
{{- $css := . | resources.FromString $target | resources.ToCSS | resources.PostCSS (dict "config" "postcss.config.js") | resources.Fingerprint "sha256" -}}
|
||||
|
||||
{{- $target := path.Join $.File.Dir "css/inline.scss" }}
|
||||
{{- $css := . | resources.FromString $target | resources.ToCSS | resources.PostCSS (dict "config" "postcss.config.js") -}}
|
||||
<link rel="stylesheet" href="{{ $css.Permalink }}">
|
||||
{{ end }}
|
||||
|
@@ -1,5 +1,13 @@
|
||||
{{ $darkmode := resources.Get "js/dark-mode.js" | resources.ExecuteAsTemplate "vendor/emoji/dark-mode.js" . }}
|
||||
{{ $darkmode := resources.Get "js/dark-mode.js" | resources.ExecuteAsTemplate "js/dark-mode.js" . }}
|
||||
{{ $twemoji := resources.Get "vendor/emoji/emoji.js" | resources.ExecuteAsTemplate "vendor/emoji/emoji.min.js" . }}
|
||||
{{ $analytics := resources.Get "js/simple-analytics.js" | resources.ExecuteAsTemplate "js/simple-analytics.js" . }}
|
||||
|
||||
{{ $js := slice $darkmode $twemoji | resources.Concat "/js/main.js" | resources.Minify | resources.Fingerprint "sha256" }}
|
||||
<script async defer {{ printf "src=%q integrity=%q" $js.Permalink $js.Data.Integrity | safeHTMLAttr }}></script>
|
||||
{{ $bundle := "" }}
|
||||
{{ if eq hugo.Environment "development" }}
|
||||
{{ $bundle = slice $darkmode $twemoji }}
|
||||
{{ else }}
|
||||
{{ $bundle = slice $darkmode $twemoji $analytics }}
|
||||
{{ end }}
|
||||
|
||||
{{ $js := $bundle | resources.Concat "/js/app.js" }}
|
||||
<script async defer src="{{ $js.Permalink }}"></script>
|
||||
|
@@ -1,2 +0,0 @@
|
||||
<script async defer src="https://s.jarv.is/latest.js" data-skip-dnt="true"></script>
|
||||
<noscript><img src="https://s.jarv.is/image.gif" alt=""></noscript>
|
Reference in New Issue
Block a user