1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-19 04:35:31 -04:00

fingerprint CSS and JS, set one week browser cache

...and LOTS of tidying partials
This commit is contained in:
2020-04-25 11:15:31 -04:00
parent d2648a68be
commit adfa73b5fc
25 changed files with 86 additions and 110 deletions

View File

@@ -2,7 +2,7 @@
{{ printf "<!--\n ,,, ,,,\n ;\" ^; ;\" \",\n ; s$$$$$s ;\n , ss$$$$$$$ss ,\"\n ;$$$$$$$$$$$$$$$$\n $$$$$$$$$$$$$$$$$$ Hello, human. :)\n $$$$$\"\"\"$$$\"\"\"$$$$$$\n $$$$$ p\"$$$\"q $$$$$ %s\n $$$$ .$$$$$. $$$$\n $$$$$$$$$$$$$$$$$\n \"$$$$\"*\"$$$$\"\n \"$$.$$\"\n-->" ("humans.txt" | absURL) | safeHTML }}
<html lang="{{ .Site.LanguageCode | default "en" }}">
<head>
{{ partial "head/head" . }}
{{ partial "head/_head" . }}
</head>
<body class="light">
{{ partialCached "page/header" . }}

View File

@@ -226,14 +226,13 @@
{{ partialCached "head/favicons" (dict "pngSizes" "192 48 32 16" "icoSizes" "16 32 48") }}
{{ partialCached "head/feeds" . }}
<link rel="manifest" href="{{ "site.webmanifest" | absURL }}">
{{ partial "head/schema-person" . }}
{{ partial "head/schema-article" . }}
{{ partial "head/schema" . }}
</head>
<body>
<header>
<nav>
<a id="logo" href="{{ .Site.BaseURL }}" title="{{ .Site.Title }}">
{{ partialCached "page/logo" . }}
{{ partialCached "svg/logo.svg" (dict "width" 30 "height" 45) }}
<span id="name">{{ .Site.Title }}</span>
</a>

View File

@@ -5,18 +5,10 @@
X-Frame-Options: sameorigin
X-XSS-Protection: 1; mode=block
# Super long cache (one year) for vendored assets:
# web fonts, emojis, etc.
# 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=31536000, immutable
# Proper MIME type for Atom feed:
/feed.atom
Content-Type: application/atom+xml
# Recommended MIME type for PWA manifests:
# https://github.com/w3c/manifest/issues/689
/manifest.json
Content-Type: application/manifest+json
/site.webmanifest
Content-Type: application/manifest+json
Cache-Control: public, max-age=604800, immutable

View File

@@ -0,0 +1,11 @@
{{ partial "head/meta" . -}}
{{ partial "functions/social-images" . -}}
{{ partial "head/open-graph" . -}}
{{ partialCached "head/mobile" . -}}
{{ partial "head/preload" . -}}
{{ partial "head/styles" . -}}
{{ partialCached "head/favicons" (dict "pngSizes" "192 48 32 16" "icoSizes" "16 32 48") -}}
{{ partialCached "head/feeds" . -}}
{{ partialCached "head/webmention" . -}}
{{ partial "head/canonical" . -}}
{{ partial "head/schema" . -}}

View File

@@ -0,0 +1,7 @@
<link rel="canonical" href="{{ .Permalink }}">
{{ if and .IsPage (eq .Type .Site.Params.mainSection) }}
{{- with .OutputFormats.Get "amp" -}}
<link rel="amphtml" href="{{ .Permalink }}">
{{ end -}}
{{ end -}}
<link rel="author" href="{{ "humans.txt" | absURL }}">

View File

@@ -4,7 +4,6 @@
{{- $safariIcon := resources.Get "img/safari-pinned-tab.svg" }}
<link rel="mask-icon" href="{{ $safariIcon.Permalink }}" color="#009cdf">
{{/* TODO: automate shrinking to given sizes based on one super big favicon */}}
{{- range (split .pngSizes " ") }}
{{- $faviconPng := resources.Get (printf "img/favicon-%v.png" .) }}
<link rel="icon" href="{{ $faviconPng.Permalink }}" sizes="{{ . }}x{{ . }}">

View File

@@ -1,21 +0,0 @@
{{ partial "head/meta" . -}}
{{ partial "functions/social-images" . -}}
{{ partial "head/open-graph" . -}}
{{ partialCached "head/mobile" . -}}
{{ partial "head/preload" . -}}
{{ partial "head/styles" . -}}
{{ partialCached "head/favicons" (dict "pngSizes" "192 48 32 16" "icoSizes" "16 32 48") -}}
<link rel="manifest" href="{{ "site.webmanifest" | absURL }}">
<link rel="canonical" href="{{ .Permalink }}">
{{ partialCached "head/feeds" . -}}
{{ partialCached "head/webmention" . -}}
<link rel="author" href="{{ "humans.txt" | absURL }}">
{{ if and .IsPage (eq .Type .Site.Params.mainSection) }}
{{- with .OutputFormats.Get "amp" -}}
<link rel="amphtml" href="{{ .Permalink }}">
{{- end }}
{{ partial "head/schema-person" . }}
{{ partial "head/schema-article" . }}
{{ else }}
{{ partial "head/schema-person" . }}
{{ end -}}

View File

@@ -2,3 +2,4 @@
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta name="apple-mobile-web-app-title" content="{{ .Site.Title }}">
<meta name="theme-color" content="#0e6dc2">
<link rel="manifest" href="{{ "site.webmanifest" | absURL }}">

View File

@@ -0,0 +1,6 @@
{{ if and .IsPage (eq .Type .Site.Params.mainSection) }}
{{ partial "head/schema/person" . }}
{{ partial "head/schema/article" . }}
{{ else }}
{{ partial "head/schema/person" . }}
{{ end -}}

View File

@@ -1,12 +1,12 @@
{{ $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") }}
{{ $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" }}
<link rel="stylesheet" href="{{ $style.Permalink }}">
{{/* Page-specific styles set via front matter, scoped via SCSS */}}
{{ with .Params.css }}
{{- $sass := printf "div#content { %s }" . }}
{{- $target := path.Join $.File.Dir "css/inline.scss" }}
{{- $target := path.Join $.File.Dir "css/inline.min.scss" }}
{{- $css := $sass | resources.FromString $target | resources.ToCSS | resources.PostCSS (dict "config" "postcss.config.js") -}}
{{- $css := $sass | resources.FromString $target | resources.ToCSS | resources.PostCSS (dict "config" "postcss.config.js") | resources.Fingerprint "sha256" -}}
<link rel="stylesheet" href="{{ $css.Permalink }}">
{{ end }}

View File

@@ -1,2 +1,2 @@
<link rel="webmention" href="https://webmention.io/jarv.is/webmention">
<link rel="pingback" href="https://webmention.io/jarv.is/xmlrpc">
<link rel="webmention" href="https://webmention.io/jarv.is/webmention">

View File

@@ -1,7 +1,7 @@
<header>
<nav>
<a class="no-underline" href="{{ .Site.BaseURL }}" id="logo" rel="me author" aria-label="{{ .Site.Title }}">
{{ partialCached "page/logo" . }}
{{ partialCached "svg/logo.svg" (dict "width" 30 "height" 45) }}
<h1 id="name">{{ .Site.Title }}</h1>
</a>
<ul>

View File

@@ -1,7 +0,0 @@
{{ $logo := resources.Get "img/logo.svg" -}}
{{ $svg := $logo.Content -}}
{{ $svg = replaceRE "<\\?xml.+\\?>" "" $svg -}}
{{ $svg = replace $svg "<svg" "<svg width=\"30\" height=\"45\"" -}}
{{ printf "<!-- inlined: %s -->" $logo.Permalink | safeHTML }}
{{ $svg | safeHTML -}}

View File

@@ -1,5 +1,5 @@
{{ $darkmode := resources.Get "js/dark-mode.js" }}
{{ $twemoji := resources.Get "vendor/emoji/emoji.js" | resources.ExecuteAsTemplate "vendor/emoji/emoji.min.js" . }}
{{ $js := slice $darkmode $twemoji | resources.Concat "/js/main.js" }}
<script src="{{ $js.Permalink }}"></script>
{{ $js := slice $darkmode $twemoji | resources.Concat "/js/main.js" | resources.Minify | resources.Fingerprint "sha256" }}
<script src="{{ $js.Permalink }}" integrity="{{ $js.Data.Integrity }}"></script>

View File

@@ -0,0 +1,14 @@
{{ $svg := resources.Get "img/logo.svg" -}}
{{ $html := $svg.Content -}}
{{/* remove unneeded tags/attributes when SVG is inlined versus a .svg file */}}
{{ $html = replaceRE "<\\?xml.+\\?>" "" $html -}}
{{ $html = replaceRE " version=\"(.*?)\"" "" $html -}}
{{ $html = replaceRE " xmlns=\"(.*?)\"" "" $html -}}
{{ $wxh := printf "<svg width=\"%d\" height=\"%d\"" .width .height }}
{{ $html = replace $html "<svg" $wxh -}}
{{ printf "<!-- auto-inlined from: %s -->" $svg.Permalink | safeHTML }}
{{ $html | safeHTML -}}