1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-26 14:28:25 -04:00

clean up a bunch of layouts, especially social-images function

also made even more config.toml parameters optional, will help when finally releasing theme
This commit is contained in:
Jake Jarvis 2020-06-25 10:35:59 -04:00
parent 0a48ce296f
commit f3198e0235
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39
31 changed files with 167 additions and 162 deletions

View File

@ -1,5 +1,5 @@
# Hugo stuff that doesn't play well with Prettier
assets/vendor/
assets/**/vendor/
layouts/
static/

View File

@ -25,15 +25,15 @@ Run `yarn install` ([Yarn must be installed](https://yarnpkg.com/en/docs/install
### 🐳 Using Docker:
To ensure consistency and compatibility, the [`Dockerfile`](Dockerfile) in this repository will download the correct versino of the Hugo Extended binary and its dependencies, and start a live testing server in the temporary container.
To ensure consistency and compatibility, the [`Dockerfile`](Dockerfile) in this repository will download the correct version of the Hugo Extended binary and its dependencies, and start a live testing server in a temporary container.
Using Docker doesn't require Node or Yarn, but you can also use `yarn start:docker` which simply runs:
Using Docker doesn't require Node or Yarn, but you can also use `yarn start:docker` (or `npm run start:docker`) which is simply an alias for:
```bash
docker run --rm -v $(pwd):/src -p 1337:1337 $(docker build --no-cache -q .)
```
...then open [http://localhost:1337/](http://localhost:1337/).
Once built, these two methods act identically — simply open [http://localhost:1337/](http://localhost:1337/) as above.
### 🤯 Why does this sound _way_ more complex than it needs to be?!

View File

@ -8,25 +8,28 @@
// Generate the needed variables, this seems like a lot of repetition, but it
// makes our script availble for multple destination which prevents us to
// need multiple scripts. The minified version stays small.
var https = "https:";
var version = 3;
var functionName = "sa_event";
var pageviewsText = "pageview";
var https = "https:";
var protocol = https + "//";
var con = window.console;
var slash = "/";
var fullApiUrl = protocol + baseUrl;
var doc = window.document;
var con = window.console;
var nav = window.navigator;
var screen = window.screen;
var loc = window.location;
var locationHostname = loc.hostname;
var doc = window.document;
var userAgent = nav.userAgent;
var notSending = "Not sending requests ";
var documentElement = doc.documentElement || {};
var addEventListenerFunc = window.addEventListener;
var encodeURIComponentFunc = encodeURIComponent;
var decodeURIComponentFunc = decodeURIComponent;
var stringify = JSON.stringify;
var thousand = 1000;
var addEventListenerFunc = window.addEventListener;
var fullApiUrl = protocol + baseUrl;
var undefinedVar = undefined;
var documentElement = doc.documentElement || {};
var notSending = "Not sending requests ";
var language = "language";
var Height = "Height";
var Width = "Width";
@ -35,14 +38,12 @@
var offsetHeight = "offset" + Height;
var clientHeight = "client" + Height;
var clientWidth = "client" + Width;
var screen = window.screen;
var functionName = "sa_event";
var bot = /(bot|spider|crawl)/i.test(userAgent);
var payload = {
version: 3,
version: version,
};
var bot = /(bot|spider|crawl)/i.test(userAgent);
if (bot) payload.bot = true;
var options = {

View File

@ -113,6 +113,7 @@ button {
img.emoji {
height: 1.1em;
width: 1.1em;
margin: 0;
padding: 0 0.09em;
vertical-align: -0.18em;

View File

@ -2,7 +2,7 @@
// NOTE: all variables set by Hugo's config.toml MUST go here:
// prettier-ignore
$max-width: "{{ printf "%d%s" .Site.Params.pageMaxWidth "px" }}";
$max-width: "{{ printf "%d%s" .Site.Params.maxWidth "px" }}";
$base-url: "{{ strings.TrimRight "/" .Site.BaseURL }}" + "/";
// those values need quotes because, even though prettier & stylelint are correct

View File

@ -24,19 +24,19 @@ disableAliases = true
[params]
description = "Hi there! I'm a frontend web developer based in Boston, Massachusetts specializing in the JAMstack, modern JavaScript frameworks, and progressive web apps."
domain = "jarv.is"
mainSection = "notes"
pageMaxWidth = 940
defaultImage = "img/me_large.jpg"
github = "jakejarvis/jarv.is"
image = "img/logo.png" # must be in assetDir
mainSection = "notes" # reflected in RSS, Atom, AMP
maxWidth = 940 # px
githubRepo = "jakejarvis/jarv.is"
facebookAppID = "3357248167622283"
webmention = "jarv.is"
webmentionIO = "jarv.is" # webmention.io username
copyrightFirstYear = "2001"
license = "CC-BY-4.0"
licenseFull = "Creative Commons Attribution 4.0 International"
[author]
name = "Jake Jarvis"
image = "img/me_large.jpg" # must be in assetDir
jobTitle = "Front-End Web Developer"
email = "jake@jarv.is"
twitter = "jakejarvis"
@ -51,7 +51,6 @@ disableAliases = true
[module]
[[module.imports]]
path = "github.com/twitter/twemoji"
disable = false
[[module.imports.mounts]]
source = "assets/svg"
target = "static/vendor/emoji/svg"

View File

@ -12,8 +12,8 @@
{{ block "main" . }}{{ end }}
</div>
{{ partialCached "page/footer" . }}
{{ partial "scripts/_bundle" . }}
{{ partial "scripts/shortcodes" . }}
{{ partial "scripts/_bundle" . -}}
{{ partial "scripts/shortcodes" . -}}
</body>
</html>

View File

@ -90,7 +90,7 @@
padding-left: 1em;
}
article {
max-width: {{ printf "%d%s" .Site.Params.pageMaxWidth "px" }};
max-width: {{ printf "%d%s" .Site.Params.maxWidth "px" }};
margin: 0 auto;
padding: 0 15px;
line-height: 1.75;
@ -147,7 +147,7 @@
text-decoration: none;
}
nav {
max-width: {{ printf "%d%s" .Site.Params.pageMaxWidth "px" }};
max-width: {{ printf "%d%s" .Site.Params.maxWidth "px" }};
margin: 0 auto;
padding: 0 15px;
display: flex;
@ -198,7 +198,7 @@
}
footer div.row {
width: 100%;
max-width: {{ printf "%d%s" .Site.Params.pageMaxWidth "px" }};
max-width: {{ printf "%d%s" .Site.Params.maxWidth "px" }};
margin: 0 auto;
display: flex;
justify-content: space-between;

View File

@ -2,7 +2,7 @@
<main id="single">
<article>
<div id="meta">
<a class="no-underline" href="{{ .Permalink }}" title="{{ .Date.Format "Mon, Jan 2 2006 3:04:05 PM MST" }}">{{ .Date.Format "January 2, 2006" }}</a>{{ with .Site.Params.github }}<span class="dash"></span><a class="no-underline" href="https://github.com/{{ . }}/blob/main/content/{{ $.File.Path }}" title="Edit this post on GitHub" target="_blank" rel="noopener">Improve This Post</a>{{ end }}
<a class="no-underline" href="{{ .Permalink }}" title="{{ .Date.Format "Mon, Jan 2 2006 3:04:05 PM MST" }}">{{ .Date.Format "January 2, 2006" }}</a>{{ with .Site.Params.githubRepo }}<span class="dash"></span><a class="no-underline" href="https://github.com/{{ . }}/blob/main/content/{{ $.File.Path }}" title="Edit this post on GitHub" target="_blank" rel="noopener">Improve This Post</a>{{ end }}
</div>
<h1 id="title"><a class="no-underline" href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1>

View File

@ -1,3 +1,4 @@
{{- $img := partial "functions/social-images" . -}}
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ .Site.Title }}</title>
@ -10,8 +11,8 @@
{{- with .Site.Copyright }}
<rights>{{ . }}</rights>
{{- end }}
{{- with .Site.Params.defaultImage }}
<logo>{{ . | absURL }}</logo>
{{- with .Scratch.Get "authorImage" }}
<logo>{{ .Permalink }}</logo>
{{- end }}
<updated>{{ .Date.Format "2006-01-02T15:04:05Z" | safeHTML }}</updated>
{{- with .OutputFormats.Get "ATOM" }}

View File

@ -2,7 +2,7 @@
{{- $android192 := resources.Get "img/android-chrome-192x192.png" -}}
{
"name": "{{ .Site.Title }}",
"short_name": "{{ .Site.Params.domain }}",
"short_name": "{{ (urls.Parse .Site.BaseURL).Host }}",
"icons": [
{
"src": "{{ $android512.Permalink | safeJS }}",

View File

@ -1,15 +1,15 @@
{{ $svg := resources.Get .src -}}
{{ $html := $svg.Content -}}
{{- $svg := resources.Get .src -}}
{{- $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 -}}
{{- $html = replaceRE "<\\?xml.+\\?>" "" $html -}}
{{- $html = replaceRE " version=\"(.*?)\"" "" $html -}}
{{- $html = replaceRE " xmlns=\"(.*?)\"" "" $html -}}
{{ $wxh := printf "<svg width=\"%d\" height=\"%d\"" .width .height }}
{{- $wxh := printf "<svg width=\"%d\" height=\"%d\" " .width .height }}
{{ $html = replace $html "<svg" $wxh -}}
{{- $html = replace $html "<svg " $wxh -}}
{{/* bit of a hack: calling .Permalink so that the SVG file is published too */}}
{{ printf "<!-- auto-inlined from: %s -->" $svg.Permalink | safeHTML }}
{{ $html | safeHTML -}}
{{/* bit of a hack: calling .Permalink so that the SVG file is published too, comment will be removed when minified */}}
{{- printf "<!-- auto-inlined from: %s -->" $svg.Permalink | safeHTML }}
{{- $html | safeHTML -}}

View File

@ -3,7 +3,7 @@
{{ $original := .Page.Resources.GetMatch (.Get "src") }}
{{ .Scratch.Set "image" $original }}
{{ $setWidth := .Site.Params.pageMaxWidth }}
{{ $setWidth := .Site.Params.maxWidth }}
{{ if .Get "width" }}
{{ $setWidth = (int (.Get "width")) }}
@ -22,4 +22,4 @@
{{ $displayWidth := $setWidth }}
{{ $displayHeight := (math.Ceil (mul $origRatio $setWidth)) }}
{{ return (dict "Permalink" $image.Permalink "Width" $displayWidth "Height" $displayHeight) }}
{{ return (dict "Permalink" $image.Permalink "Width" $displayWidth "Height" $displayHeight "MediaType" $image.MediaType) }}

View File

@ -1,28 +1,27 @@
{{/* Default image */}}
{{- $defaultImage := resources.Get $.Site.Params.defaultImage }}
{{- $.Scratch.Set "defaultImage_url" $defaultImage.Permalink }}
{{- $.Scratch.Set "defaultImage_width" $defaultImage.Width }}
{{- $.Scratch.Set "defaultImage_height" $defaultImage.Height }}
{{- $.Scratch.Set "defaultImage_type" $defaultImage.MediaType }}
{{/* Chooses and initializes various images for use by JSON schema & open graph tags */}}
{{/* Author image (default) */}}
{{- with .Site.Author.image -}}
{{- with resources.Get . -}}
{{- $.Scratch.Set "authorImage" . -}}
{{- end -}}
{{- end -}}
{{/* Article image */}}
{{- with .Params.image }}
{{- $socialImage := $.Page.Resources.GetMatch . }}
{{- $.Scratch.Set "socialImage_url" $socialImage.Permalink }}
{{- $.Scratch.Set "socialImage_width" $socialImage.Width }}
{{- $.Scratch.Set "socialImage_height" $socialImage.Height }}
{{- $.Scratch.Set "socialImage_type" $socialImage.MediaType }}
{{ else }}
{{/* fallback to default image set above */}}
{{- $.Scratch.Set "socialImage_url" $defaultImage.Permalink }}
{{- $.Scratch.Set "socialImage_width" $defaultImage.Width }}
{{- $.Scratch.Set "socialImage_height" $defaultImage.Height }}
{{- $.Scratch.Set "socialImage_type" $defaultImage.MediaType }}
{{ end -}}
{{- with .Params.image -}}
{{- with $.Page.Resources.GetMatch . -}}
{{- $.Scratch.Set "pageImage" . -}}
{{- end -}}
{{- else -}}
{{/* Fallback to author image set above */}}
{{- with $.Scratch.Get "authorImage" -}}
{{- $.Scratch.Set "pageImage" . -}}
{{- end -}}
{{- end -}}
{{/* Site logo */}}
{{- $logoImage := resources.Get "img/logo.png" }}
{{- $.Scratch.Set "logoImage_url" $logoImage.Permalink }}
{{- $.Scratch.Set "logoImage_width" $logoImage.Width }}
{{- $.Scratch.Set "logoImage_height" $logoImage.Height }}
{{- $.Scratch.Set "logoImage_type" $logoImage.MediaType }}
{{- with .Site.Params.image -}}
{{- with resources.Get . -}}
{{- $.Scratch.Set "logoImage" . -}}
{{- end -}}
{{- end -}}

View File

@ -2,13 +2,13 @@
{{ partial "functions/social-images" . -}}
{{ partial "head/open-graph" . -}}
{{ partialCached "head/mobile" . -}}
{{ partial "head/preload" . -}}
{{ partialCached "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" . -}}
{{ if eq hugo.Environment "production" }}
{{ partial "scripts/simple_analytics_events" . -}}
{{ end }}
{{ if eq hugo.Environment "production" -}}
{{ partialCached "scripts/simple_analytics_events" . -}}
{{ end -}}

View File

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

View File

@ -7,10 +7,10 @@
{{- range (split .pngSizes " ") }}
{{- $faviconPng := resources.Get (printf "img/favicon-%v.png" .) }}
<link rel="icon" href="{{ $faviconPng.Permalink }}" sizes="{{ . }}x{{ . }}">
{{- end }}
{{- end -}}
{{- $s := slice }}
{{- range (split .icoSizes " ") }}{{ $s = $s | append (printf "%vx%v" . .) }}{{ end }}
{{- $s := slice -}}
{{- range (split .icoSizes " ") }}{{ $s = $s | append (printf "%vx%v" . .) }}{{ end -}}
{{- $faviconIco := resources.Get "img/favicon.ico" }}
<link rel="shortcut icon" href="{{ $faviconIco.Permalink }}" sizes="{{ delimit $s " " }}">

View File

@ -5,11 +5,13 @@
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{ .Site.Params.description }}{{ end }}">
<meta property="og:image" content="{{ .Scratch.Get "socialImage_url" | absURL }}">
<meta property="og:image:type" content="{{ .Scratch.Get "socialImage_type" }}">
<meta property="og:image:width" content="{{ .Scratch.Get "socialImage_width" }}">
<meta property="og:image:height" content="{{ .Scratch.Get "socialImage_height" }}">
<meta property="og:image:alt" content="{{ .Title }}">
{{- with .Scratch.Get "pageImage" }}
<meta property="og:image" content="{{ .Permalink }}">
<meta property="og:image:type" content="{{ .MediaType }}">
<meta property="og:image:width" content="{{ .Width }}">
<meta property="og:image:height" content="{{ .Height }}">
<meta property="og:image:alt" content="{{ $.Title }}">
{{ end -}}
{{- if and .IsPage (eq .Type .Site.Params.mainSection) }}
{{- if not .PublishDate.IsZero }}
@ -23,16 +25,16 @@
<meta property="article:author" content="https://www.facebook.com/{{ . }}">{{ end }}
{{- with .Params.tags }}{{ range . }}
<meta property="article:tag" content="{{ . }}">{{ end }}{{ end }}
{{- end }}
{{ end -}}
{{ with .Site.Author.facebookid }}<meta property="fb:admins" content="{{ . }}">{{ end }}
{{ with .Site.Params.facebookAppID }}<meta property="fb:app_id" content="{{ . }}">{{ end }}
<meta name="twitter:card" content="{{ if .IsPage }}summary_large_image{{ else }}summary{{ end }}">
<meta name="twitter:domain" content="{{ .Site.Params.domain }}">
<meta name="twitter:domain" content="{{ (urls.Parse .Site.BaseURL).Host }}">
{{- with .Site.Author.twitter }}
<meta name="twitter:site" content="{{ printf "%s%s" "@" . }}">
<meta name="twitter:creator" content="{{ printf "%s%s" "@" . }}">
{{- end }}
{{ end -}}
{{ with .Site.Author.twitterid }}<meta name="twitter:creator_id" content="{{ . }}">{{ end }}
<meta name="twitter:dnt" content="on">

View File

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

View File

@ -17,19 +17,19 @@
"publisher": {
"@type": "Organization",
"name": {{ .Site.Title }},
"url": {{ .Site.BaseURL }},
"url": {{ .Site.BaseURL }}{{ with .Scratch.Get "logoImage" }},
"logo": {
"@type": "ImageObject",
"url": {{ .Scratch.Get "logoImage_url" | absURL }},
"width": "{{ .Scratch.Get "logoImage_width" }}",
"height": "{{ .Scratch.Get "logoImage_height" }}"
}
},
"url": {{ .Permalink }},
"width": "{{ .Width }}",
"height": "{{ .Height }}"
}{{ end }}
}{{ with .Scratch.Get "pageImage" }},
"image": {
"@type": "ImageObject",
"url": {{ .Scratch.Get "socialImage_url" | absURL }},
"width": "{{ .Scratch.Get "socialImage_width" }}",
"height": "{{ .Scratch.Get "socialImage_height" }}"
}
"url": {{ .Permalink }},
"width": "{{ .Width }}",
"height": "{{ .Height }}"
}{{ end }}
}
</script>

View File

@ -7,13 +7,13 @@
"name": {{ .name }},
"url": {{ $.Site.BaseURL }},
"description": {{ $.Site.Params.description }},
{{ with .jobtitle }}"jobTitle": {{ . }},{{ end }}
{{ with .jobtitle }}"jobTitle": {{ . }},{{ end }}{{ with $.Scratch.Get "authorImage" }}
"image": {
"@type": "ImageObject",
"url": {{ $.Scratch.Get "defaultImage_url" | absURL }},
"width": "{{ $.Scratch.Get "defaultImage_width" }}",
"height": "{{ $.Scratch.Get "defaultImage_height" }}"
},
"url": {{ .Permalink }},
"width": "{{ .Width }}",
"height": "{{ .Height }}"
},{{ end }}
"sameAs": [
{{ $.Site.BaseURL }},
{{ with .github }}{{ printf "%s%s" "https://github.com/" . }},{{ end }}

View File

@ -2,9 +2,9 @@
<link rel="stylesheet" href="{{ $style.Permalink }}">
{{/* Page-specific styles set via front matter, scoped via SCSS and inlined */}}
{{ with .Params.css }}
{{- with .Params.css -}}
{{/* NOTE: This file doesn't end up getting published (which is good) */}}
{{- $target := path.Join $.File.Dir "css/inline.scss" }}
{{- $target := path.Join $.File.Dir "css/inline.scss" -}}
{{- $css := . | resources.FromString $target | resources.ToCSS | resources.PostCSS (dict "config" "postcss.config.js") -}}
{{/* Already being minified to my taste by PostCSS above */}}
@ -13,4 +13,4 @@
{{ $css.Content | safeCSS }}
</style>
{{- printf "<!-- htmlmin:ignore -->" | safeHTML }}
{{ end }}
{{ end -}}

View File

@ -1,4 +1,4 @@
{{ with .Site.Params.webmention }}
{{ with .Site.Params.webmentionIO }}
<link rel="pingback" href="https://webmention.io/{{ . }}/xmlrpc">
<link rel="webmention" href="https://webmention.io/{{ . }}/webmention">
{{ end }}

View File

@ -1,12 +1,10 @@
<footer>
<div class="row">
<div id="copyright">Content <a class="no-underline" href="{{ "license/" | absURL }}"{{ with .Site.Params.licenseFull }} title="{{ . }}"{{ end }}>licensed under {{ .Site.Params.license }}</a>, {{ with .Site.Params.copyrightFirstYear }}<a class="no-underline" href="{{ "previously/" | absURL }}" title="Previously on...">{{ . }} &ndash;</a>{{ end }} {{ now.Format "2006" }}.</div>
<!-- adblock hides images with width="88" and height="31", for some reason? using style="..." gets around it. -->
<!-- TODO: ask about this..? https://github.com/AdguardTeam/AdguardFilters/blob/ba4db91022dbebe48967a447b5f818064ee60167/SpywareFilter/sections/general_elemhide.txt#L18 -->
<div id="y2k"><a class="no-underline" href="https://y2k.land/" title="Made for Internet Explorer&reg;" target="_blank" rel="noopener"><img src="{{ "img/ie.gif" | absURL }}" style="width: 88px; height: 31px;" alt="Made for Internet Explorer&reg;"></a></div>
<div id="poweredby">
<a class="no-underline" href="https://gohugo.io/" title="Powered by Hugo" id="hugo" target="_blank" rel="noopener">Made with <span class="beat">&#x2764;</span> and Hugo.</a>
{{ with .Site.Params.github }}<a class="no-underline" href="https://github.com/{{ . }}" title="View Source on GitHub" id="source" target="_blank" rel="noopener">View source.</a>{{ end }}
{{ with .Site.Params.githubRepo }}<a class="no-underline" href="https://github.com/{{ . }}" title="View Source on GitHub" id="source" target="_blank" rel="noopener">View source.</a>{{ end }}
</div>
</div>
</footer>

View File

@ -1,13 +1,13 @@
<header>
<nav>
<a class="no-underline" href="{{ .Site.BaseURL }}" id="logo" rel="me author" aria-label="{{ .Site.Title }}">
{{ partial "functions/inline-svg" (dict "src" "img/logo.svg" "width" 28 "height" 40) }}
{{ if fileExists "assets/img/logo.svg" }}{{ partial "functions/inline-svg" (dict "src" "img/logo.svg" "width" 28 "height" 40) }}{{ end }}
<h1 id="name">{{ .Site.Title }}</h1>
</a>
<ul>
{{- range .Site.Menus.main }}
<li><a class="no-underline" {{ printf "href=%q" .URL | safeHTMLAttr }} aria-label="{{ .Name }}"{{ if strings.HasPrefix .URL "http" }} target="_blank" rel="me noopener"{{ end }}><span class="icon">{{ .Pre }}</span><span class="text">{{ .Name }}</span></a></li>
{{ end -}}
{{- end }}
<li><button class="dark-mode-toggle" title="Toggle Dark Mode" aria-label="Toggle Dark Mode"></button></li>
</ul>
</nav>

View File

@ -1,20 +1,20 @@
{{ $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" . }}
{{- $darkmode := resources.Get "js/dark-mode.js" | resources.ExecuteAsTemplate "js/dark-mode.js" . -}}
{{- $twemoji := resources.Get "js/vendor/twemoji.js" | resources.ExecuteAsTemplate "js/vendor/twemoji.js" . -}}
{{ $bundle := slice $darkmode $twemoji }}
{{- $bundle := slice $darkmode $twemoji -}}
{{/* only parse and append analytics script on production site */}}
{{ $includeAnalytics := eq hugo.Environment "production" }}
{{- $includeAnalytics := eq hugo.Environment "production" -}}
{{ if $includeAnalytics }}
{{ $analytics := resources.Get "js/simple-analytics.js" | resources.ExecuteAsTemplate "js/simple-analytics.js" . }}
{{ $bundle = slice $darkmode $twemoji $analytics }}
{{ end }}
{{- if $includeAnalytics }}
{{- $analytics := resources.Get "js/analytics.js" | resources.ExecuteAsTemplate "js/analytics.js" . }}
{{- $bundle = slice $darkmode $twemoji $analytics }}
{{- end }}
{{ $js := $bundle | resources.Concat "/js/app.js" }}
{{- $js := $bundle | resources.Concat "/js/app.js" -}}
<script async defer src="{{ $js.Permalink }}"></script>
{{/* proxy to simple analytics noscript on production */}}
{{ if $includeAnalytics }}
{{- if $includeAnalytics }}
<noscript><img src="{{ "sa/manual.gif" | absURL }}" alt=""></noscript>
{{ end }}
{{ end -}}

View File

@ -1,3 +1,4 @@
{{- $img := partial "functions/social-images" . -}}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ .Site.Title }}</title>
@ -8,9 +9,9 @@
<managingEditor>{{ . }}{{ with $.Site.Author.name }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with .Site.Author.email }}
<webMaster>{{ . }}{{ with $.Site.Author.name }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
<copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}{{ with .Site.Params.defaultImage }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}{{ with .Scratch.Get "authorImage" }}
<image>
<url>{{ . | absURL }}</url>
<url>{{ .Permalink }}</url>
<title>{{ $.Site.Title }}</title>
<link>{{ $.Permalink }}</link>
</image>{{ end }}{{ with .OutputFormats.Get "RSS" }}

View File

@ -1,6 +1,6 @@
<amp-video
layout="responsive"
width="{{ with .Get "width" }}{{ . }}{{ else }}{{ .Site.Params.pageMaxWidth }}{{ end }}"
width="{{ with .Get "width" }}{{ . }}{{ else }}{{ .Site.Params.maxWidth }}{{ end }}"
height="{{ with .Get "height" }}{{ . }}{{ else }}600{{ end }}"
{{- with .Page.Resources.GetMatch (.Get "poster") }} poster="{{ .Permalink }}"{{ end }}
{{- if .Get "autoplay" }} autoplay{{ end }}

View File

@ -59,7 +59,7 @@
Content-Type = "text/plain; charset=UTF-8"
Content-Disposition = "inline; filename=\"jarvis.asc\""
# AMP cache invalidation key requirements
# AMP cache invalidation key requirements:
# https://developers.google.com/amp/cache/update-cache#update-cache-guidelines
[[headers]]
for = "/.well-known/amphtml/apikey.pub"
@ -108,6 +108,37 @@
from = "/archives/*"
to = "/notes/"
status = 301
[[redirects]]
# Not sure if these XML-RPC requests are malicious but forward them to
# webmention.io anyway.
from = "/xmlrpc.php"
to = "https://webmention.io/jarv.is/xmlrpc"
status = 302
# Proxy data to Simple Analytics endpoints:
[[redirects]]
from = "/sa/send*"
to = "https://queue.simpleanalyticscdn.com/simple.gif:splat"
status = 200
[[redirects]]
from = "/sa/append*"
to = "https://queue.simpleanalyticscdn.com/append:splat"
status = 200
[[redirects]]
from = "/sa/post*"
to = "https://api.simpleanalytics.io/post:splat"
status = 200
[[redirects]]
# This noscript pixel needs to pass unknown arguments along for AMP pages:
# https://amp.dev/documentation/components/amp-pixel/
from = "/sa/noscript.gif*"
to = "https://queue.simpleanalyticscdn.com/noscript.gif:splat"
status = 200
[[redirects]]
# Same noscript.gif as above but with no arguments, except `ignore-dnt`.
from = "/sa/manual.gif"
to = "https://queue.simpleanalyticscdn.com/noscript.gif?ignore-dnt=true"
status = 200
# More miscellaneous mirrors/redirects:
[[redirects]]
@ -130,6 +161,10 @@
from = "/apple-touch-icon.png"
to = "/img/apple-touch-icon.png"
status = 200
[[redirects]]
from = "/safari-pinned-tab.svg"
to = "/img/safari-pinned-tab.svg"
status = 200
[[redirects]]
from = "/keybase.txt"
to = "/.well-known/keybase.txt"
@ -139,31 +174,6 @@
to = "/vendor/emoji/svg/:splat"
status = 301
# Proxy data to Simple Analytics endpoints:
[[redirects]]
from = "/sa/send*"
to = "https://queue.simpleanalyticscdn.com/simple.gif:splat"
status = 200
[[redirects]]
from = "/sa/append*"
to = "https://queue.simpleanalyticscdn.com/append:splat"
status = 200
[[redirects]]
from = "/sa/post*"
to = "https://api.simpleanalytics.io/post:splat"
status = 200
[[redirects]]
# this noscript pixel needs to pass unknown arguments along for AMP pages
# https://amp.dev/documentation/components/amp-pixel/
from = "/sa/noscript.gif*"
to = "https://queue.simpleanalyticscdn.com/noscript.gif:splat"
status = 200
[[redirects]]
# same noscript img as above but with no arguments, except `ignore-dnt`
from = "/sa/manual.gif"
to = "https://queue.simpleanalyticscdn.com/noscript.gif?ignore-dnt=true"
status = 200
# Mirror these directories from elsewhere to mimic GitHub Pages behavior and
# keep this main repository squeaky clean.
# https://github.com/jakejarvis/random-sites (private)
@ -221,9 +231,3 @@
from = "*/wlwmanifest.xml"
to = "/403.html"
status = 403
# not sure if these xmlrpc requests are malicious but forward them to
# webmention.io anyway
[[redirects]]
from = "/xmlrpc.php"
to = "https://webmention.io/jarv.is/xmlrpc"
status = 302

View File

@ -1224,9 +1224,9 @@ duplexer3@^0.1.4:
integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=
electron-to-chromium@^1.3.481:
version "1.3.481"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.481.tgz#0d59e72a0aaeb876b43fb1d6e84bf0dfc99617e8"
integrity sha512-q2PeCP2PQXSYadDo9uNY+uHXjdB9PcsUpCVoGlY8TZOPHGlXdevlqW9PkKeqCxn2QBkGB8b6AcMO++gh8X82bA==
version "1.3.483"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.483.tgz#9269e7cfc1c8e72709824da171cbe47ca5e3ca9e"
integrity sha512-+05RF8S9rk8S0G8eBCqBRBaRq7+UN3lDs2DAvnG8SBSgQO3hjy0+qt4CmRk5eiuGbTcaicgXfPmBi31a+BD3lg==
emoji-regex@^7.0.1:
version "7.0.3"