diff --git a/layouts/_default/single.gmi b/layouts/_default/single.gmi index 1944a50..8992c36 100644 --- a/layouts/_default/single.gmi +++ b/layouts/_default/single.gmi @@ -1,52 +1,51 @@ +{{- $scratch := newScratch -}}{{- $scratch.Set "ref" 1 -}} => / 💻 [runtimeterror $] -# {{ .Title }}{{ $scratch := newScratch }} -{{- if .Params.Date }} +{{ if .Params.Date }} {{- $postDate := .Date.Format "2006-01-02" }} {{- $updateDate := .Lastmod.Format "2006-01-02" }} - {{ $postDate }}{{ if ne $postDate $updateDate }} ~ {{ $updateDate }}{{ end }} + {{- $postDate }}{{ if ne $postDate $updateDate }} ~ {{ $updateDate }}{{ end }} {{- end }} -{{/* The bulk of this regex magic is derived from https://brainbaking.com/post/2021/04/using-hugo-to-launch-a-gemini-capsule/ */}} -{{ $content := .RawContent -}} -{{- $content := $content | replaceRE `#{4,} ` "### " -}}{{/* reduce headings to a max of 3 levels */}} -{{- $content := $content | replaceRE `(?m:^- (.+?)$)` "\n* $1" -}}{{/* convert unordered lists */}} -{{- $content := $content | replaceRE `(?m:^(?:\d+). (.+?)$)` "* $1" -}}{{/* convert ordered lists */}} -{{- $content := $content | replaceRE `\n\[\^(.+?)\]:\s.*` "" -}}{{/* remove footnote definitions */}} -{{- $content := $content | replaceRE `\[\^(.+?)\]` "" -}}{{/* remove footnote anchors */}} -{{- $content := $content | replaceRE `((?m:^(?:\|.*\|)+\n)+)` "```\n$1\n```\n" -}}{{/* convert markdown tables to plaintext ascii */}} -{{- $content := $content | replaceRE "(?m:^`([^`]*)`$)" "```\n$1\n```\n" -}}{{/* convert single-line inline code to blocks */}} -{{- $content := $content | replaceRE `\{\{%\snotice.*%\}\}` "<-- note -->" -}}{{/* convert hugo notices */}} -{{- $content := $content | replaceRE `\{\{%\s/notice.*%\}\}` "<-- /note -->" -}} -{{- $content := $content | replaceRE `((\/\/)|#)\s*torchlight!.*\n` "" -}}{{/* remove torchlight markup */}} -{{- $content := $content | replaceRE `(?:(?:" -}}{{/* convert hugo notices */}} + {{- $content := $content | replaceRE `\{\{%\s/notice.*%\}\}` "<-- /note -->" -}} + {{- $content := $content | replaceRE `((\/\/)|#)\s*torchlight!.*\n` "" -}}{{/* remove torchlight markup */}} + {{- $content := $content | replaceRE `(?:(?: