From 9bb9989fca490bfac69ea4387ccae1e9ec3ec23cf7f47a401e241ee43562f8a3 Mon Sep 17 00:00:00 2001 From: Nicholas Johnson <> Date: Sat, 26 Jul 2025 00:00:00 +0000 Subject: Migrate fully to Hugo's new template system This was the only way I could get term pages to consistently render correctly. --- layouts/_default/_markup/render-image.html | 1 - layouts/_default/_markup/render-link.html | 3 - layouts/_default/baseof.gmi | 7 -- layouts/_default/baseof.html | 9 -- layouts/_default/single.gmi | 132 ----------------------------- layouts/_default/single.html | 12 --- layouts/_default/taxonomy.atom.xml | 56 ------------ layouts/_default/taxonomy.gemini_atom.xml | 55 ------------ layouts/_default/taxonomy.gmi | 17 ---- layouts/_default/taxonomy.html | 16 ---- layouts/_default/term.atom.xml | 56 ------------ layouts/_default/term.gemini_atom.xml | 55 ------------ layouts/_default/term.gmi | 19 ----- layouts/_default/term.html | 14 --- layouts/_markup/render-image.html | 1 + layouts/_markup/render-link.html | 3 + layouts/_partials/footer.gmi | 1 + layouts/_partials/footer.html | 3 + layouts/_partials/head.html | 22 +++++ layouts/_partials/header.gmi | 3 + layouts/_partials/header.html | 5 ++ layouts/_partials/metadata.gmi | 2 + layouts/_partials/metadata.html | 6 ++ layouts/_partials/pageinfo.gmi | 18 ++++ layouts/_partials/pageinfo.html | 23 +++++ layouts/baseof.gmi | 7 ++ layouts/baseof.html | 9 ++ layouts/home.atom.xml | 56 ++++++++++++ layouts/home.gemini_atom.xml | 55 ++++++++++++ layouts/home.gmi | 27 ++++++ layouts/home.html | 22 +++++ layouts/index.atom.xml | 56 ------------ layouts/index.gemini_atom.xml | 55 ------------ layouts/index.gmi | 27 ------ layouts/index.html | 22 ----- layouts/partials/footer.gmi | 1 - layouts/partials/footer.html | 3 - layouts/partials/head.html | 22 ----- layouts/partials/header.gmi | 3 - layouts/partials/header.html | 5 -- layouts/partials/metadata.gmi | 2 - layouts/partials/metadata.html | 6 -- layouts/partials/pageinfo.gmi | 18 ---- layouts/partials/pageinfo.html | 23 ----- layouts/single.gmi | 132 +++++++++++++++++++++++++++++ layouts/single.html | 12 +++ layouts/taxonomy.atom.xml | 56 ++++++++++++ layouts/taxonomy.gemini_atom.xml | 55 ++++++++++++ layouts/taxonomy.gmi | 17 ++++ layouts/taxonomy.html | 16 ++++ layouts/term.atom.xml | 56 ++++++++++++ layouts/term.gemini_atom.xml | 55 ++++++++++++ layouts/term.gmi | 19 +++++ layouts/term.html | 14 +++ 54 files changed, 695 insertions(+), 695 deletions(-) delete mode 100644 layouts/_default/_markup/render-image.html delete mode 100644 layouts/_default/_markup/render-link.html delete mode 100644 layouts/_default/baseof.gmi delete mode 100644 layouts/_default/baseof.html delete mode 100644 layouts/_default/single.gmi delete mode 100644 layouts/_default/single.html delete mode 100644 layouts/_default/taxonomy.atom.xml delete mode 100644 layouts/_default/taxonomy.gemini_atom.xml delete mode 100644 layouts/_default/taxonomy.gmi delete mode 100644 layouts/_default/taxonomy.html delete mode 100644 layouts/_default/term.atom.xml delete mode 100644 layouts/_default/term.gemini_atom.xml delete mode 100644 layouts/_default/term.gmi delete mode 100644 layouts/_default/term.html create mode 100644 layouts/_markup/render-image.html create mode 100644 layouts/_markup/render-link.html create mode 100644 layouts/_partials/footer.gmi create mode 100644 layouts/_partials/footer.html create mode 100644 layouts/_partials/head.html create mode 100644 layouts/_partials/header.gmi create mode 100644 layouts/_partials/header.html create mode 100644 layouts/_partials/metadata.gmi create mode 100644 layouts/_partials/metadata.html create mode 100644 layouts/_partials/pageinfo.gmi create mode 100644 layouts/_partials/pageinfo.html create mode 100644 layouts/baseof.gmi create mode 100644 layouts/baseof.html create mode 100644 layouts/home.atom.xml create mode 100644 layouts/home.gemini_atom.xml create mode 100644 layouts/home.gmi create mode 100644 layouts/home.html delete mode 100644 layouts/index.atom.xml delete mode 100644 layouts/index.gemini_atom.xml delete mode 100644 layouts/index.gmi delete mode 100644 layouts/index.html delete mode 100644 layouts/partials/footer.gmi delete mode 100644 layouts/partials/footer.html delete mode 100644 layouts/partials/head.html delete mode 100644 layouts/partials/header.gmi delete mode 100644 layouts/partials/header.html delete mode 100644 layouts/partials/metadata.gmi delete mode 100644 layouts/partials/metadata.html delete mode 100644 layouts/partials/pageinfo.gmi delete mode 100644 layouts/partials/pageinfo.html create mode 100644 layouts/single.gmi create mode 100644 layouts/single.html create mode 100644 layouts/taxonomy.atom.xml create mode 100644 layouts/taxonomy.gemini_atom.xml create mode 100644 layouts/taxonomy.gmi create mode 100644 layouts/taxonomy.html create mode 100644 layouts/term.atom.xml create mode 100644 layouts/term.gemini_atom.xml create mode 100644 layouts/term.gmi create mode 100644 layouts/term.html diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html deleted file mode 100644 index 590c9bf..0000000 --- a/layouts/_default/_markup/render-image.html +++ /dev/null @@ -1 +0,0 @@ -{{ .Text }} \ No newline at end of file diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html deleted file mode 100644 index 8fb3c26..0000000 --- a/layouts/_default/_markup/render-link.html +++ /dev/null @@ -1,3 +0,0 @@ -{{ $emoji := cond (and (not (.Page.Params.makerefs | default true)) (.Page.Params.showlinkemoji | default true)) (emojify ":link: ") "" -}} -{{ $isExternalLink := (urls.Parse .Destination).IsAbs -}} -{{ $emoji }}{{ .Text }} \ No newline at end of file diff --git a/layouts/_default/baseof.gmi b/layouts/_default/baseof.gmi deleted file mode 100644 index 09cdbac..0000000 --- a/layouts/_default/baseof.gmi +++ /dev/null @@ -1,7 +0,0 @@ -{{ partial "header.gmi" . }} - - -{{ block "main" . }}{{ end }} - - -{{ partial "footer.gmi" . }} \ No newline at end of file diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html deleted file mode 100644 index a36bd49..0000000 --- a/layouts/_default/baseof.html +++ /dev/null @@ -1,9 +0,0 @@ - - - {{ partial "head.html" . }} - - {{ partial "header.html" . }} - {{ block "main" . }}{{ end }} - {{ partial "footer.html" . }} - - \ No newline at end of file diff --git a/layouts/_default/single.gmi b/layouts/_default/single.gmi deleted file mode 100644 index 1502830..0000000 --- a/layouts/_default/single.gmi +++ /dev/null @@ -1,132 +0,0 @@ -{{ define "main" -}} -{{ $emoji := cond (.Page.Params.showlinkemoji | default true) (emojify ":link: ") "" -}} -=> {{ .Site.Home.RelPermalink | strings.TrimSuffix "index.gmi" }} {{ emojify ":link:" }} {{ i18n "returnHome" -}} - -{{ if (.Page.Params.pageinfo | default true) }} - -{{ partial "pageinfo.gmi" . -}} -{{ end }} - - -# {{ .Name }} - -{{ $content := chomp (.RawContent) -}} -{{ $scratch := newScratch -}} - -{{/* if content begins with a heading, add an extra newline */ -}} -{{ if (findRE `^#{1,6} ` $content 1) }} -{{ end -}} - -{{/* split text into chunks, with each chunk containing 3 parts: above, within, and below preformatted text */ -}} -{{/* the regex matching below the preformatted text matches exactly once in the entire text */ -}} -{{ $chunks := findRESubmatch `(?sm)(?:(.+?)(^\x60{3}[^\x60].*?^\x60{3}$))|(.+$)` $content -}} - -{{ $ref_index := 0 -}} - -{{ range $chunks -}} - {{ $above_pre := index . 1 -}} - {{ $pre := index . 2 -}} - {{ $below_pre := index . 3 -}} - - {{/* mux regex matches above and below preformatted text for rendering (the matches are mutually exclusive) */ -}} - {{ $rendered_text := print $above_pre $below_pre -}} - - {{ if ($.Page.Params.makerefs | default true) -}} - - {{/* find all the links within a chunk */ -}} - {{ $chunk_refs := findRESubmatch `!?\[[\t ]*(.+?)[\t ]*\]\([\t ]*(.+?)(?:[\t ]+"(.+?)")?[\t ]*\)` $rendered_text -}} - - {{ range $chunk_refs -}} - {{ $ref_index = add $ref_index 1 -}} - {{ $chunk_ref := dict - "index" $ref_index - "text" (index . 1) - "link" (index . 2) - "title" (index . 3) - -}} - - {{ $scratch.Add "refs" (slice $chunk_ref) -}} - - {{ $ref_index := $chunk_ref.index -}} - {{ $ref_text := $chunk_ref.text -}} - - {{/* create superscript of $ref_index */ -}} - {{ $superscript_map := dict - "0" "⁰" - "1" "¹" - "2" "²" - "3" "³" - "4" "⁴" - "5" "⁵" - "6" "⁶" - "7" "⁷" - "8" "⁸" - "9" "⁹" - -}} - {{ $ref_superscript := "" -}} - {{ range (split $ref_index "") -}} - {{ $ref_superscript = print $ref_superscript (index $superscript_map .) -}} - {{ end -}} - - {{/* replace Markdown links with link text and their superscripted reference numbers */ -}} - {{ $rendered_text = replace $rendered_text (index . 0) (print $ref_text $ref_superscript) 1 -}} - - {{ end -}} - - {{ else -}} - - {{/* render all links directly */ -}} - {{ $rendered_text = $rendered_text | replaceRE `(?m)^!?\[[\t ]*(.+?)[\t ]*\]\([\t ]*(.+?)(?:[\t ]+"(.+?)")?[\t ]*\)$` (print "=> $2 " $emoji "$1") -}} - - {{ end -}} - - {{/* trim extra heading symbols */ -}} - {{ $rendered_text = $rendered_text | replaceRE `(?m)^####{1,3} ` "### " -}} - - {{/* convert Markdown alternative heading syntax to gemtext heading syntax */ -}} - {{ $rendered_text = $rendered_text | replaceRE `(?m)^[\t ]*(\S.+?)[\t ]*\n\=+$` "# $1" -}} - {{ $rendered_text = $rendered_text | replaceRE `(?m)^[\t ]*(\S.+?)[\t ]*\n\-+$` "## $1" -}} - - {{/* convert Markdown alternative unordered list syntax to gemtext unordered list syntax */ -}} - {{ $rendered_text = $rendered_text | replaceRE `(?m)^[-+] ` "* " -}} - - {{/* convert Markdown ordered list items to gemtext unordered list items */ -}} - {{ $rendered_text = $rendered_text | replaceRE `(?m)^[1-9]\d*\.[\t ]+(.*?)[\t ]*$` "* $1" -}} - - {{/* remove bold and italics asterisk symbols */ -}} - {{/* note: this operation is performed in 3 steps to handle nested bold and italics */ -}} - {{/* note: this operation is performed last to avoid incorrectly rendering (un)ordered lists */ -}} - {{ $rendered_text = $rendered_text | replaceRE `\*{3}(\S(?:.*?\S)?)\*{3}` "$1" -}} - {{ $rendered_text = $rendered_text | replaceRE `\*{2}(\S(?:.*?\S)?)\*{2}` "$1" -}} - {{ $rendered_text = $rendered_text | replaceRE `\*{1}(\S(?:.*?\S)?)\*{1}` "$1" -}} - - {{ $rendered_text = $rendered_text | emojify -}} - - {{/* demux regex matches above and below preformatted text */ -}} - {{ if $above_pre -}} - {{ $rendered_text -}} - {{ $pre -}} - {{ else -}} - {{ $pre -}} - {{ $rendered_text -}} - {{ end -}} - -{{ end -}} - -{{ $refs := $scratch.Get "refs" -}} -{{ if and (.Page.Params.makerefs | default true) $refs }} - - -## {{ i18n "refs" }} -{{ range $refs -}} - {{ $ref_index := .index -}} - {{ $ref_text := .text -}} - {{ $ref_link := .link -}} - {{ $ref_title := .title -}} - - {{/* render referenced links */}} -{{ print "=> " $ref_link (emojify " :link: [") $ref_index "]: " (cond (ne (len $ref_title) 0) $ref_title $ref_text) -}} -{{ end -}} - -{{ end -}} -{{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html deleted file mode 100644 index fdfa777..0000000 --- a/layouts/_default/single.html +++ /dev/null @@ -1,12 +0,0 @@ -{{ define "main" -}} - -{{- if (.Page.Params.pageinfo | default true) }} -

{{ partial "pageinfo.html" . }}

-{{- end }} -
-

{{ .Name }}

- {{ chomp (.Content) }} -
-{{- end }} \ No newline at end of file diff --git a/layouts/_default/taxonomy.atom.xml b/layouts/_default/taxonomy.atom.xml deleted file mode 100644 index cbcbae8..0000000 --- a/layouts/_default/taxonomy.atom.xml +++ /dev/null @@ -1,56 +0,0 @@ -{{/* Deprecate site.Author.name in favor of site.Params.author.name */}} -{{- $authorName := "" }} -{{- with site.Params.author }} - {{- if reflect.IsMap . }} - {{- with .name }} - {{- $authorName = . }} - {{- end }} - {{- else }} - {{- $authorName = . }} - {{- end }} -{{- else }} - {{- with site.Author.name }} - {{- $authorName = . }} - {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} - {{- end }} -{{- end }} - -{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}} -{{- $authorEmail := "" }} -{{- with site.Params.author }} - {{- if reflect.IsMap . }} - {{- with .email }} - {{- $authorEmail = . }} - {{- end }} - {{- end }} -{{- else }} - {{- with site.Author.email }} - {{- $authorEmail = . }} - {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} - {{- end }} -{{- end -}} - -{{ "" | safeHTML }} - - {{ .Permalink }} - {{ .Site.Title }} - {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} - - - {{- with $authorName }} - - {{ . }} - {{- with $authorEmail }} - {{ . }}{{ end }} - {{ end }} - Hugo -- gohugo.io - {{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }} - {{ .Site.Params.Description }}{{ range first .Site.Config.Services.RSS.Limit .Data.Pages }} - - {{ .Permalink }} - {{ .Title }} - {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} - - {{ .Content | html }} - {{ end }} - diff --git a/layouts/_default/taxonomy.gemini_atom.xml b/layouts/_default/taxonomy.gemini_atom.xml deleted file mode 100644 index 76431e3..0000000 --- a/layouts/_default/taxonomy.gemini_atom.xml +++ /dev/null @@ -1,55 +0,0 @@ -{{/* Deprecate site.Author.name in favor of site.Params.author.name */}} -{{- $authorName := "" }} -{{- with site.Params.author }} - {{- if reflect.IsMap . }} - {{- with .name }} - {{- $authorName = . }} - {{- end }} - {{- else }} - {{- $authorName = . }} - {{- end }} -{{- else }} - {{- with site.Author.name }} - {{- $authorName = . }} - {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} - {{- end }} -{{- end }} - -{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}} -{{- $authorEmail := "" }} -{{- with site.Params.author }} - {{- if reflect.IsMap . }} - {{- with .email }} - {{- $authorEmail = . }} - {{- end }} - {{- end }} -{{- else }} - {{- with site.Author.email }} - {{- $authorEmail = . }} - {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} - {{- end }} -{{- end -}} - -{{ "" | safeHTML }} - - {{ .Permalink | strings.TrimSuffix "index.gmi" }} - {{ .Site.Title }} - {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} - - - {{- with $authorName }} - - {{ . }} - {{- with $authorEmail }} - {{ . }}{{ end }} - {{ end }} - Hugo -- gohugo.io - {{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }} - {{ .Site.Params.Description }}{{ range first .Site.Config.Services.RSS.Limit .Data.Pages }} - - {{ .Permalink | strings.TrimSuffix "index.gmi" }} - {{ .Title }} - {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} - - {{ end }} - diff --git a/layouts/_default/taxonomy.gmi b/layouts/_default/taxonomy.gmi deleted file mode 100644 index 9c2a9f0..0000000 --- a/layouts/_default/taxonomy.gmi +++ /dev/null @@ -1,17 +0,0 @@ -{{ define "main" -}} -=> {{ .Site.Home.RelPermalink | strings.TrimSuffix "index.gmi" }} {{ emojify ":link:" }} {{ i18n "returnHome" }} - - -# {{ .Type | humanize }} - - -## {{ i18n "feeds" }} - -=> {{ .RelPermalink | replaceRE `index.gmi$` "atom.xml" }} {{ emojify ":link:" }} {{ i18n "atomFeed" }} - - -## {{ i18n "list" }} -{{ range .Data.Pages }} -=> {{ .RelPermalink | strings.TrimSuffix "index.gmi" }} {{ emojify ":link:" }} {{ .Title -}} -{{ end -}} -{{ end }} \ No newline at end of file diff --git a/layouts/_default/taxonomy.html b/layouts/_default/taxonomy.html deleted file mode 100644 index 86d7f89..0000000 --- a/layouts/_default/taxonomy.html +++ /dev/null @@ -1,16 +0,0 @@ -{{ define "main" -}} - -
-

{{ .Type | humanize }}

-

{{ i18n "feeds" }}

-

{{ emojify ":link:" }} {{ i18n "atomFeed" }}

-

{{ i18n "list" }}

- -
-{{- end }} \ No newline at end of file diff --git a/layouts/_default/term.atom.xml b/layouts/_default/term.atom.xml deleted file mode 100644 index cbcbae8..0000000 --- a/layouts/_default/term.atom.xml +++ /dev/null @@ -1,56 +0,0 @@ -{{/* Deprecate site.Author.name in favor of site.Params.author.name */}} -{{- $authorName := "" }} -{{- with site.Params.author }} - {{- if reflect.IsMap . }} - {{- with .name }} - {{- $authorName = . }} - {{- end }} - {{- else }} - {{- $authorName = . }} - {{- end }} -{{- else }} - {{- with site.Author.name }} - {{- $authorName = . }} - {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} - {{- end }} -{{- end }} - -{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}} -{{- $authorEmail := "" }} -{{- with site.Params.author }} - {{- if reflect.IsMap . }} - {{- with .email }} - {{- $authorEmail = . }} - {{- end }} - {{- end }} -{{- else }} - {{- with site.Author.email }} - {{- $authorEmail = . }} - {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} - {{- end }} -{{- end -}} - -{{ "" | safeHTML }} - - {{ .Permalink }} - {{ .Site.Title }} - {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} - - - {{- with $authorName }} - - {{ . }} - {{- with $authorEmail }} - {{ . }}{{ end }} - {{ end }} - Hugo -- gohugo.io - {{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }} - {{ .Site.Params.Description }}{{ range first .Site.Config.Services.RSS.Limit .Data.Pages }} - - {{ .Permalink }} - {{ .Title }} - {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} - - {{ .Content | html }} - {{ end }} - diff --git a/layouts/_default/term.gemini_atom.xml b/layouts/_default/term.gemini_atom.xml deleted file mode 100644 index 287bcc4..0000000 --- a/layouts/_default/term.gemini_atom.xml +++ /dev/null @@ -1,55 +0,0 @@ -{{/*Deprecate site.Author.name in favor of site.Params.author.name */}} -{{- $authorName := "" }} -{{- with site.Params.author }} - {{- if reflect.IsMap . }} - {{- with .name }} - {{- $authorName = . }} - {{- end }} - {{- else }} - {{- $authorName = . }} - {{- end }} -{{- else }} - {{- with site.Author.name }} - {{- $authorName = . }} - {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} - {{- end }} -{{- end }} - -{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}} -{{- $authorEmail := "" }} -{{- with site.Params.author }} - {{- if reflect.IsMap . }} - {{- with .email }} - {{- $authorEmail = . }} - {{- end }} - {{- end }} -{{- else }} - {{- with site.Author.email }} - {{- $authorEmail = . }} - {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} - {{- end }} -{{- end -}} - -{{ "" | safeHTML }} - - {{ .Permalink | strings.TrimSuffix "index.gmi" }} - {{ .Site.Title }} - {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} - - - {{- with $authorName }} - - {{ . }} - {{- with $authorEmail }} - {{ . }}{{ end }} - {{ end }} - Hugo -- gohugo.io - {{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }} - {{ .Site.Params.Description }}{{ range first .Site.Config.Services.RSS.Limit .Data.Pages }} - - {{ .Permalink | strings.TrimSuffix "index.gmi" }} - {{ .Title }} - {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} - - {{ end }} - diff --git a/layouts/_default/term.gmi b/layouts/_default/term.gmi deleted file mode 100644 index 5d7f7b1..0000000 --- a/layouts/_default/term.gmi +++ /dev/null @@ -1,19 +0,0 @@ -{{ define "main" -}} -=> {{ .Site.Home.RelPermalink | strings.TrimSuffix "index.gmi" }} {{ emojify ":link:" }} {{ i18n "returnHome" }} - - -# {{ .Type | singularize | humanize }} "{{ .Title }}" - - -## {{ i18n "feeds" }} - -=> {{ .RelPermalink | replaceRE `index.gmi$` "atom.xml" }} {{ emojify ":link:" }} {{ i18n "atomFeed" }} - - -## {{ i18n "journalEntries" -}} - -{{ range .Data.Pages.ByPublishDate.Reverse }} - -{{ partial "metadata.gmi" . -}} -{{ end -}} -{{ end }} \ No newline at end of file diff --git a/layouts/_default/term.html b/layouts/_default/term.html deleted file mode 100644 index 3b268dd..0000000 --- a/layouts/_default/term.html +++ /dev/null @@ -1,14 +0,0 @@ -{{ define "main" -}} - -
-

{{ .Type | singularize | humanize }} "{{ .Title }}"

-

{{ i18n "feeds" }}

-

{{ emojify ":link:" }} {{ i18n "atomFeed" }}

-

{{ i18n "journalEntries" }}

- {{- range .Data.Pages.ByPublishDate.Reverse }} - {{ partial "metadata.html" . -}} - {{ end }} -
-{{- end }} \ No newline at end of file diff --git a/layouts/_markup/render-image.html b/layouts/_markup/render-image.html new file mode 100644 index 0000000..590c9bf --- /dev/null +++ b/layouts/_markup/render-image.html @@ -0,0 +1 @@ +{{ .Text }} \ No newline at end of file diff --git a/layouts/_markup/render-link.html b/layouts/_markup/render-link.html new file mode 100644 index 0000000..8fb3c26 --- /dev/null +++ b/layouts/_markup/render-link.html @@ -0,0 +1,3 @@ +{{ $emoji := cond (and (not (.Page.Params.makerefs | default true)) (.Page.Params.showlinkemoji | default true)) (emojify ":link: ") "" -}} +{{ $isExternalLink := (urls.Parse .Destination).IsAbs -}} +{{ $emoji }}{{ .Text }} \ No newline at end of file diff --git a/layouts/_partials/footer.gmi b/layouts/_partials/footer.gmi new file mode 100644 index 0000000..06b0678 --- /dev/null +++ b/layouts/_partials/footer.gmi @@ -0,0 +1 @@ +{{ replace $.Site.Copyright "{currentYear}" (now.Format "2006") }} \ No newline at end of file diff --git a/layouts/_partials/footer.html b/layouts/_partials/footer.html new file mode 100644 index 0000000..5f8ffc6 --- /dev/null +++ b/layouts/_partials/footer.html @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/layouts/_partials/head.html b/layouts/_partials/head.html new file mode 100644 index 0000000..8250e19 --- /dev/null +++ b/layouts/_partials/head.html @@ -0,0 +1,22 @@ + + + + + {{- if $.Site.Params.description }} + + {{- end -}} + {{ if $.Site.Params.keywords }} + + {{- end -}} + {{ if .Site.Params.custom_css -}} + {{ range .Site.Params.custom_css }} + + {{- end -}} + {{ else }} + + {{- end -}} + {{ if (not (fileExists "static/favicon.ico")) }} + + {{- end }} + {{ .Title }} + \ No newline at end of file diff --git a/layouts/_partials/header.gmi b/layouts/_partials/header.gmi new file mode 100644 index 0000000..c70f84a --- /dev/null +++ b/layouts/_partials/header.gmi @@ -0,0 +1,3 @@ +```plaintext +{{ chomp (readFile "templates/logo.txt") }} +``` \ No newline at end of file diff --git a/layouts/_partials/header.html b/layouts/_partials/header.html new file mode 100644 index 0000000..d8ec881 --- /dev/null +++ b/layouts/_partials/header.html @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/layouts/_partials/metadata.gmi b/layouts/_partials/metadata.gmi new file mode 100644 index 0000000..48d3db4 --- /dev/null +++ b/layouts/_partials/metadata.gmi @@ -0,0 +1,2 @@ +{{ partial "pageinfo.gmi" . }} +=> {{ .RelPermalink | strings.TrimSuffix "index.gmi" }} {{ emojify ":link:" }} {{ .Title }} \ No newline at end of file diff --git a/layouts/_partials/metadata.html b/layouts/_partials/metadata.html new file mode 100644 index 0000000..ed091b8 --- /dev/null +++ b/layouts/_partials/metadata.html @@ -0,0 +1,6 @@ +
+
+

{{ partial "pageinfo.html" . }}
+ {{ emojify ":link:" }} {{ .Title }}

+
+
\ No newline at end of file diff --git a/layouts/_partials/pageinfo.gmi b/layouts/_partials/pageinfo.gmi new file mode 100644 index 0000000..9993d93 --- /dev/null +++ b/layouts/_partials/pageinfo.gmi @@ -0,0 +1,18 @@ +{{ $dateFormat := .Site.Params.dateFormat | default ":date_long" -}} + +{{ $nonBreakingPublishDate := .Page.PublishDate | time.Format $dateFormat -}} +{{ $nonBreakingPublishDate = replace $nonBreakingPublishDate " " " " -}} +{{ $nonBreakingPublishDate = replace $nonBreakingPublishDate "-" "‑" -}} + +{{ $nonBreakingReadingTime := i18n "readingTime" .ReadingTime -}} +{{ $nonBreakingReadingTime = replace $nonBreakingReadingTime " " " " -}} +{{ $nonBreakingReadingTime = replace $nonBreakingReadingTime "-" "‑" -}} + +{{ $nonBreakingTags := slice -}} +{{ range .Param (lower (i18n "tags")) -}} + {{ $nonBreakingTag := replace . " " " " -}} + {{ $nonBreakingTag = replace $nonBreakingTag "-" "‑" -}} + {{ $nonBreakingTags = $nonBreakingTags | append $nonBreakingTag -}} +{{ end -}} + +{{ emojify ":calendar:" }} {{ $nonBreakingPublishDate }} | {{ emojify ":stopwatch:" }} {{ $nonBreakingReadingTime }}{{ if $nonBreakingTags }} | {{ emojify ":label:" }} {{ end }}{{ range $key, $val := $nonBreakingTags }}{{ if $key }}, {{ end }}{{ $val }}{{ end }} \ No newline at end of file diff --git a/layouts/_partials/pageinfo.html b/layouts/_partials/pageinfo.html new file mode 100644 index 0000000..3ca8fe9 --- /dev/null +++ b/layouts/_partials/pageinfo.html @@ -0,0 +1,23 @@ +{{ $dateFormat := .Site.Params.dateFormat | default ":date_long" -}} + +{{/* user-overridable parameter $dateFormat is escaped pre-insertion so that HTML entities can be inserted */ -}} +{{ $nonBreakingPublishDate := .Page.PublishDate | time.Format $dateFormat | htmlEscape -}} +{{ $nonBreakingPublishDate = replace $nonBreakingPublishDate " " " " -}} +{{ $nonBreakingPublishDate = replace $nonBreakingPublishDate "-" "‑" -}} + +{{/* user-overridable parameter $readingTime is escaped pre-insertion so that HTML entities can be inserted */ -}} +{{ $nonBreakingReadingTime := i18n "readingTime" .ReadingTime | htmlEscape -}} +{{ $nonBreakingReadingTime = replace $nonBreakingReadingTime " " " " -}} +{{ $nonBreakingReadingTime = replace $nonBreakingReadingTime "-" "‑" -}} + +{{ $breakingTags := .Param (lower (i18n "tags")) -}} +{{ $nonBreakingTags := slice -}} +{{ range $breakingTags -}} + {{/* user-defined tags are escaped pre-insertion so that HTML entities can be inserted */ -}} + {{ $nonBreakingTag := htmlEscape . -}} + {{ $nonBreakingTag = replace $nonBreakingTag " " " " -}} + {{ $nonBreakingTag = replace $nonBreakingTag "-" "‑" -}} + {{ $nonBreakingTags = $nonBreakingTags | append $nonBreakingTag -}} +{{ end -}} + +{{ emojify ":calendar:" }}  | {{ emojify ":stopwatch:" }} {{ if $nonBreakingTags }} | {{ emojify ":label:" }} {{ end }}{{ range $key, $val := $nonBreakingTags }}{{ if $key }} {{ end }}{{ $val | safeHTML }}{{ end }} diff --git a/layouts/baseof.gmi b/layouts/baseof.gmi new file mode 100644 index 0000000..09cdbac --- /dev/null +++ b/layouts/baseof.gmi @@ -0,0 +1,7 @@ +{{ partial "header.gmi" . }} + + +{{ block "main" . }}{{ end }} + + +{{ partial "footer.gmi" . }} \ No newline at end of file diff --git a/layouts/baseof.html b/layouts/baseof.html new file mode 100644 index 0000000..a36bd49 --- /dev/null +++ b/layouts/baseof.html @@ -0,0 +1,9 @@ + + + {{ partial "head.html" . }} + + {{ partial "header.html" . }} + {{ block "main" . }}{{ end }} + {{ partial "footer.html" . }} + + \ No newline at end of file diff --git a/layouts/home.atom.xml b/layouts/home.atom.xml new file mode 100644 index 0000000..0d988ee --- /dev/null +++ b/layouts/home.atom.xml @@ -0,0 +1,56 @@ +{{/* Deprecate site.Author.name in favor of site.Params.author.name */}} +{{- $authorName := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .name }} + {{- $authorName = . }} + {{- end }} + {{- else }} + {{- $authorName = . }} + {{- end }} +{{- else }} + {{- with site.Author.name }} + {{- $authorName = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} + {{- end }} +{{- end }} + +{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}} +{{- $authorEmail := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .email }} + {{- $authorEmail = . }} + {{- end }} + {{- end }} +{{- else }} + {{- with site.Author.email }} + {{- $authorEmail = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} + {{- end }} +{{- end -}} + +{{ "" | safeHTML }} + + {{ .Permalink }} + {{ .Site.Title }} + {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} + + + {{- with $authorName }} + + {{ . }} + {{- with $authorEmail }} + {{ . }}{{ end }} + {{ end }} + Hugo -- gohugo.io + {{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }} + {{ .Site.Params.Description }}{{ range first .Site.Config.Services.RSS.Limit .Site.RegularPages }} + + {{ .Permalink }} + {{ .Title }} + {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} + + {{ .Content | html }} + {{ end }} + diff --git a/layouts/home.gemini_atom.xml b/layouts/home.gemini_atom.xml new file mode 100644 index 0000000..446f9f8 --- /dev/null +++ b/layouts/home.gemini_atom.xml @@ -0,0 +1,55 @@ +{{/* Deprecate site.Author.name in favor of site.Params.author.name */}} +{{- $authorName := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .name }} + {{- $authorName = . }} + {{- end }} + {{- else }} + {{- $authorName = . }} + {{- end }} +{{- else }} + {{- with site.Author.name }} + {{- $authorName = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} + {{- end }} +{{- end }} + +{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}} +{{- $authorEmail := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .email }} + {{- $authorEmail = . }} + {{- end }} + {{- end }} +{{- else }} + {{- with site.Author.email }} + {{- $authorEmail = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} + {{- end }} +{{- end -}} + +{{ "" | safeHTML }} + + {{ .Permalink | strings.TrimSuffix "index.gmi" }} + {{ .Site.Title }} + {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} + + + {{- with $authorName }} + + {{ . }} + {{- with $authorEmail }} + {{ . }}{{ end }} + {{ end }} + Hugo -- gohugo.io + {{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }} + {{ .Site.Params.Description }}{{ range first .Site.Config.Services.RSS.Limit .Site.RegularPages }} + + {{ .Permalink | strings.TrimSuffix "index.gmi" }} + {{ .Title }} + {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} + + {{ end }} + diff --git a/layouts/home.gmi b/layouts/home.gmi new file mode 100644 index 0000000..4ce3bf1 --- /dev/null +++ b/layouts/home.gmi @@ -0,0 +1,27 @@ +{{ define "main" -}} +# {{ .Site.Params.indexTitle }} + +{{ .Site.Params.indexIntro }} + +{{- if .Site.Menus.main }} + + +## {{ i18n "navLinks" }} +{{ range .Site.Menus.main }} +=> {{ .URL }} {{ emojify ":link:" }} {{ .Name -}} +{{ end -}} + +{{ end -}} + +{{ if .Site.RegularPages }} + + +## {{ i18n "journalEntries" -}} +{{ range (where .Site.RegularPages.ByTitle "Section" "entry").ByPublishDate.Reverse }} + +{{ partial "metadata.gmi" . -}} +{{ end -}} + +{{ end -}} + +{{ end }} \ No newline at end of file diff --git a/layouts/home.html b/layouts/home.html new file mode 100644 index 0000000..efbebb1 --- /dev/null +++ b/layouts/home.html @@ -0,0 +1,22 @@ +{{ define "main" -}} +
+

{{ .Site.Params.indexTitle }}

+

{{ .Site.Params.indexIntro }}

+ {{ if .Site.Menus.main -}} +

{{ i18n "navLinks" }}

+ + {{ end -}} + {{ if .Site.RegularPages -}} +

{{ i18n "journalEntries" }}

+ {{ range (where .Site.RegularPages.ByTitle "Section" "entry").ByPublishDate.Reverse -}} + {{ partial "metadata.html" . }} + {{ end -}} + {{ end -}} +
+{{- end }} \ No newline at end of file diff --git a/layouts/index.atom.xml b/layouts/index.atom.xml deleted file mode 100644 index 0d988ee..0000000 --- a/layouts/index.atom.xml +++ /dev/null @@ -1,56 +0,0 @@ -{{/* Deprecate site.Author.name in favor of site.Params.author.name */}} -{{- $authorName := "" }} -{{- with site.Params.author }} - {{- if reflect.IsMap . }} - {{- with .name }} - {{- $authorName = . }} - {{- end }} - {{- else }} - {{- $authorName = . }} - {{- end }} -{{- else }} - {{- with site.Author.name }} - {{- $authorName = . }} - {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} - {{- end }} -{{- end }} - -{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}} -{{- $authorEmail := "" }} -{{- with site.Params.author }} - {{- if reflect.IsMap . }} - {{- with .email }} - {{- $authorEmail = . }} - {{- end }} - {{- end }} -{{- else }} - {{- with site.Author.email }} - {{- $authorEmail = . }} - {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} - {{- end }} -{{- end -}} - -{{ "" | safeHTML }} - - {{ .Permalink }} - {{ .Site.Title }} - {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} - - - {{- with $authorName }} - - {{ . }} - {{- with $authorEmail }} - {{ . }}{{ end }} - {{ end }} - Hugo -- gohugo.io - {{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }} - {{ .Site.Params.Description }}{{ range first .Site.Config.Services.RSS.Limit .Site.RegularPages }} - - {{ .Permalink }} - {{ .Title }} - {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} - - {{ .Content | html }} - {{ end }} - diff --git a/layouts/index.gemini_atom.xml b/layouts/index.gemini_atom.xml deleted file mode 100644 index 446f9f8..0000000 --- a/layouts/index.gemini_atom.xml +++ /dev/null @@ -1,55 +0,0 @@ -{{/* Deprecate site.Author.name in favor of site.Params.author.name */}} -{{- $authorName := "" }} -{{- with site.Params.author }} - {{- if reflect.IsMap . }} - {{- with .name }} - {{- $authorName = . }} - {{- end }} - {{- else }} - {{- $authorName = . }} - {{- end }} -{{- else }} - {{- with site.Author.name }} - {{- $authorName = . }} - {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} - {{- end }} -{{- end }} - -{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}} -{{- $authorEmail := "" }} -{{- with site.Params.author }} - {{- if reflect.IsMap . }} - {{- with .email }} - {{- $authorEmail = . }} - {{- end }} - {{- end }} -{{- else }} - {{- with site.Author.email }} - {{- $authorEmail = . }} - {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} - {{- end }} -{{- end -}} - -{{ "" | safeHTML }} - - {{ .Permalink | strings.TrimSuffix "index.gmi" }} - {{ .Site.Title }} - {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} - - - {{- with $authorName }} - - {{ . }} - {{- with $authorEmail }} - {{ . }}{{ end }} - {{ end }} - Hugo -- gohugo.io - {{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }} - {{ .Site.Params.Description }}{{ range first .Site.Config.Services.RSS.Limit .Site.RegularPages }} - - {{ .Permalink | strings.TrimSuffix "index.gmi" }} - {{ .Title }} - {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} - - {{ end }} - diff --git a/layouts/index.gmi b/layouts/index.gmi deleted file mode 100644 index 4ce3bf1..0000000 --- a/layouts/index.gmi +++ /dev/null @@ -1,27 +0,0 @@ -{{ define "main" -}} -# {{ .Site.Params.indexTitle }} - -{{ .Site.Params.indexIntro }} - -{{- if .Site.Menus.main }} - - -## {{ i18n "navLinks" }} -{{ range .Site.Menus.main }} -=> {{ .URL }} {{ emojify ":link:" }} {{ .Name -}} -{{ end -}} - -{{ end -}} - -{{ if .Site.RegularPages }} - - -## {{ i18n "journalEntries" -}} -{{ range (where .Site.RegularPages.ByTitle "Section" "entry").ByPublishDate.Reverse }} - -{{ partial "metadata.gmi" . -}} -{{ end -}} - -{{ end -}} - -{{ end }} \ No newline at end of file diff --git a/layouts/index.html b/layouts/index.html deleted file mode 100644 index efbebb1..0000000 --- a/layouts/index.html +++ /dev/null @@ -1,22 +0,0 @@ -{{ define "main" -}} -
-

{{ .Site.Params.indexTitle }}

-

{{ .Site.Params.indexIntro }}

- {{ if .Site.Menus.main -}} -

{{ i18n "navLinks" }}

- - {{ end -}} - {{ if .Site.RegularPages -}} -

{{ i18n "journalEntries" }}

- {{ range (where .Site.RegularPages.ByTitle "Section" "entry").ByPublishDate.Reverse -}} - {{ partial "metadata.html" . }} - {{ end -}} - {{ end -}} -
-{{- end }} \ No newline at end of file diff --git a/layouts/partials/footer.gmi b/layouts/partials/footer.gmi deleted file mode 100644 index 06b0678..0000000 --- a/layouts/partials/footer.gmi +++ /dev/null @@ -1 +0,0 @@ -{{ replace $.Site.Copyright "{currentYear}" (now.Format "2006") }} \ No newline at end of file diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html deleted file mode 100644 index 5f8ffc6..0000000 --- a/layouts/partials/footer.html +++ /dev/null @@ -1,3 +0,0 @@ - \ No newline at end of file diff --git a/layouts/partials/head.html b/layouts/partials/head.html deleted file mode 100644 index 8250e19..0000000 --- a/layouts/partials/head.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {{- if $.Site.Params.description }} - - {{- end -}} - {{ if $.Site.Params.keywords }} - - {{- end -}} - {{ if .Site.Params.custom_css -}} - {{ range .Site.Params.custom_css }} - - {{- end -}} - {{ else }} - - {{- end -}} - {{ if (not (fileExists "static/favicon.ico")) }} - - {{- end }} - {{ .Title }} - \ No newline at end of file diff --git a/layouts/partials/header.gmi b/layouts/partials/header.gmi deleted file mode 100644 index c70f84a..0000000 --- a/layouts/partials/header.gmi +++ /dev/null @@ -1,3 +0,0 @@ -```plaintext -{{ chomp (readFile "templates/logo.txt") }} -``` \ No newline at end of file diff --git a/layouts/partials/header.html b/layouts/partials/header.html deleted file mode 100644 index d8ec881..0000000 --- a/layouts/partials/header.html +++ /dev/null @@ -1,5 +0,0 @@ - \ No newline at end of file diff --git a/layouts/partials/metadata.gmi b/layouts/partials/metadata.gmi deleted file mode 100644 index 48d3db4..0000000 --- a/layouts/partials/metadata.gmi +++ /dev/null @@ -1,2 +0,0 @@ -{{ partial "pageinfo.gmi" . }} -=> {{ .RelPermalink | strings.TrimSuffix "index.gmi" }} {{ emojify ":link:" }} {{ .Title }} \ No newline at end of file diff --git a/layouts/partials/metadata.html b/layouts/partials/metadata.html deleted file mode 100644 index ed091b8..0000000 --- a/layouts/partials/metadata.html +++ /dev/null @@ -1,6 +0,0 @@ -
-
-

{{ partial "pageinfo.html" . }}
- {{ emojify ":link:" }} {{ .Title }}

-
-
\ No newline at end of file diff --git a/layouts/partials/pageinfo.gmi b/layouts/partials/pageinfo.gmi deleted file mode 100644 index 9993d93..0000000 --- a/layouts/partials/pageinfo.gmi +++ /dev/null @@ -1,18 +0,0 @@ -{{ $dateFormat := .Site.Params.dateFormat | default ":date_long" -}} - -{{ $nonBreakingPublishDate := .Page.PublishDate | time.Format $dateFormat -}} -{{ $nonBreakingPublishDate = replace $nonBreakingPublishDate " " " " -}} -{{ $nonBreakingPublishDate = replace $nonBreakingPublishDate "-" "‑" -}} - -{{ $nonBreakingReadingTime := i18n "readingTime" .ReadingTime -}} -{{ $nonBreakingReadingTime = replace $nonBreakingReadingTime " " " " -}} -{{ $nonBreakingReadingTime = replace $nonBreakingReadingTime "-" "‑" -}} - -{{ $nonBreakingTags := slice -}} -{{ range .Param (lower (i18n "tags")) -}} - {{ $nonBreakingTag := replace . " " " " -}} - {{ $nonBreakingTag = replace $nonBreakingTag "-" "‑" -}} - {{ $nonBreakingTags = $nonBreakingTags | append $nonBreakingTag -}} -{{ end -}} - -{{ emojify ":calendar:" }} {{ $nonBreakingPublishDate }} | {{ emojify ":stopwatch:" }} {{ $nonBreakingReadingTime }}{{ if $nonBreakingTags }} | {{ emojify ":label:" }} {{ end }}{{ range $key, $val := $nonBreakingTags }}{{ if $key }}, {{ end }}{{ $val }}{{ end }} \ No newline at end of file diff --git a/layouts/partials/pageinfo.html b/layouts/partials/pageinfo.html deleted file mode 100644 index 3ca8fe9..0000000 --- a/layouts/partials/pageinfo.html +++ /dev/null @@ -1,23 +0,0 @@ -{{ $dateFormat := .Site.Params.dateFormat | default ":date_long" -}} - -{{/* user-overridable parameter $dateFormat is escaped pre-insertion so that HTML entities can be inserted */ -}} -{{ $nonBreakingPublishDate := .Page.PublishDate | time.Format $dateFormat | htmlEscape -}} -{{ $nonBreakingPublishDate = replace $nonBreakingPublishDate " " " " -}} -{{ $nonBreakingPublishDate = replace $nonBreakingPublishDate "-" "‑" -}} - -{{/* user-overridable parameter $readingTime is escaped pre-insertion so that HTML entities can be inserted */ -}} -{{ $nonBreakingReadingTime := i18n "readingTime" .ReadingTime | htmlEscape -}} -{{ $nonBreakingReadingTime = replace $nonBreakingReadingTime " " " " -}} -{{ $nonBreakingReadingTime = replace $nonBreakingReadingTime "-" "‑" -}} - -{{ $breakingTags := .Param (lower (i18n "tags")) -}} -{{ $nonBreakingTags := slice -}} -{{ range $breakingTags -}} - {{/* user-defined tags are escaped pre-insertion so that HTML entities can be inserted */ -}} - {{ $nonBreakingTag := htmlEscape . -}} - {{ $nonBreakingTag = replace $nonBreakingTag " " " " -}} - {{ $nonBreakingTag = replace $nonBreakingTag "-" "‑" -}} - {{ $nonBreakingTags = $nonBreakingTags | append $nonBreakingTag -}} -{{ end -}} - -{{ emojify ":calendar:" }}  | {{ emojify ":stopwatch:" }} {{ if $nonBreakingTags }} | {{ emojify ":label:" }} {{ end }}{{ range $key, $val := $nonBreakingTags }}{{ if $key }} {{ end }}{{ $val | safeHTML }}{{ end }} diff --git a/layouts/single.gmi b/layouts/single.gmi new file mode 100644 index 0000000..1502830 --- /dev/null +++ b/layouts/single.gmi @@ -0,0 +1,132 @@ +{{ define "main" -}} +{{ $emoji := cond (.Page.Params.showlinkemoji | default true) (emojify ":link: ") "" -}} +=> {{ .Site.Home.RelPermalink | strings.TrimSuffix "index.gmi" }} {{ emojify ":link:" }} {{ i18n "returnHome" -}} + +{{ if (.Page.Params.pageinfo | default true) }} + +{{ partial "pageinfo.gmi" . -}} +{{ end }} + + +# {{ .Name }} + +{{ $content := chomp (.RawContent) -}} +{{ $scratch := newScratch -}} + +{{/* if content begins with a heading, add an extra newline */ -}} +{{ if (findRE `^#{1,6} ` $content 1) }} +{{ end -}} + +{{/* split text into chunks, with each chunk containing 3 parts: above, within, and below preformatted text */ -}} +{{/* the regex matching below the preformatted text matches exactly once in the entire text */ -}} +{{ $chunks := findRESubmatch `(?sm)(?:(.+?)(^\x60{3}[^\x60].*?^\x60{3}$))|(.+$)` $content -}} + +{{ $ref_index := 0 -}} + +{{ range $chunks -}} + {{ $above_pre := index . 1 -}} + {{ $pre := index . 2 -}} + {{ $below_pre := index . 3 -}} + + {{/* mux regex matches above and below preformatted text for rendering (the matches are mutually exclusive) */ -}} + {{ $rendered_text := print $above_pre $below_pre -}} + + {{ if ($.Page.Params.makerefs | default true) -}} + + {{/* find all the links within a chunk */ -}} + {{ $chunk_refs := findRESubmatch `!?\[[\t ]*(.+?)[\t ]*\]\([\t ]*(.+?)(?:[\t ]+"(.+?)")?[\t ]*\)` $rendered_text -}} + + {{ range $chunk_refs -}} + {{ $ref_index = add $ref_index 1 -}} + {{ $chunk_ref := dict + "index" $ref_index + "text" (index . 1) + "link" (index . 2) + "title" (index . 3) + -}} + + {{ $scratch.Add "refs" (slice $chunk_ref) -}} + + {{ $ref_index := $chunk_ref.index -}} + {{ $ref_text := $chunk_ref.text -}} + + {{/* create superscript of $ref_index */ -}} + {{ $superscript_map := dict + "0" "⁰" + "1" "¹" + "2" "²" + "3" "³" + "4" "⁴" + "5" "⁵" + "6" "⁶" + "7" "⁷" + "8" "⁸" + "9" "⁹" + -}} + {{ $ref_superscript := "" -}} + {{ range (split $ref_index "") -}} + {{ $ref_superscript = print $ref_superscript (index $superscript_map .) -}} + {{ end -}} + + {{/* replace Markdown links with link text and their superscripted reference numbers */ -}} + {{ $rendered_text = replace $rendered_text (index . 0) (print $ref_text $ref_superscript) 1 -}} + + {{ end -}} + + {{ else -}} + + {{/* render all links directly */ -}} + {{ $rendered_text = $rendered_text | replaceRE `(?m)^!?\[[\t ]*(.+?)[\t ]*\]\([\t ]*(.+?)(?:[\t ]+"(.+?)")?[\t ]*\)$` (print "=> $2 " $emoji "$1") -}} + + {{ end -}} + + {{/* trim extra heading symbols */ -}} + {{ $rendered_text = $rendered_text | replaceRE `(?m)^####{1,3} ` "### " -}} + + {{/* convert Markdown alternative heading syntax to gemtext heading syntax */ -}} + {{ $rendered_text = $rendered_text | replaceRE `(?m)^[\t ]*(\S.+?)[\t ]*\n\=+$` "# $1" -}} + {{ $rendered_text = $rendered_text | replaceRE `(?m)^[\t ]*(\S.+?)[\t ]*\n\-+$` "## $1" -}} + + {{/* convert Markdown alternative unordered list syntax to gemtext unordered list syntax */ -}} + {{ $rendered_text = $rendered_text | replaceRE `(?m)^[-+] ` "* " -}} + + {{/* convert Markdown ordered list items to gemtext unordered list items */ -}} + {{ $rendered_text = $rendered_text | replaceRE `(?m)^[1-9]\d*\.[\t ]+(.*?)[\t ]*$` "* $1" -}} + + {{/* remove bold and italics asterisk symbols */ -}} + {{/* note: this operation is performed in 3 steps to handle nested bold and italics */ -}} + {{/* note: this operation is performed last to avoid incorrectly rendering (un)ordered lists */ -}} + {{ $rendered_text = $rendered_text | replaceRE `\*{3}(\S(?:.*?\S)?)\*{3}` "$1" -}} + {{ $rendered_text = $rendered_text | replaceRE `\*{2}(\S(?:.*?\S)?)\*{2}` "$1" -}} + {{ $rendered_text = $rendered_text | replaceRE `\*{1}(\S(?:.*?\S)?)\*{1}` "$1" -}} + + {{ $rendered_text = $rendered_text | emojify -}} + + {{/* demux regex matches above and below preformatted text */ -}} + {{ if $above_pre -}} + {{ $rendered_text -}} + {{ $pre -}} + {{ else -}} + {{ $pre -}} + {{ $rendered_text -}} + {{ end -}} + +{{ end -}} + +{{ $refs := $scratch.Get "refs" -}} +{{ if and (.Page.Params.makerefs | default true) $refs }} + + +## {{ i18n "refs" }} +{{ range $refs -}} + {{ $ref_index := .index -}} + {{ $ref_text := .text -}} + {{ $ref_link := .link -}} + {{ $ref_title := .title -}} + + {{/* render referenced links */}} +{{ print "=> " $ref_link (emojify " :link: [") $ref_index "]: " (cond (ne (len $ref_title) 0) $ref_title $ref_text) -}} +{{ end -}} + +{{ end -}} +{{ end }} diff --git a/layouts/single.html b/layouts/single.html new file mode 100644 index 0000000..fdfa777 --- /dev/null +++ b/layouts/single.html @@ -0,0 +1,12 @@ +{{ define "main" -}} + +{{- if (.Page.Params.pageinfo | default true) }} +

{{ partial "pageinfo.html" . }}

+{{- end }} +
+

{{ .Name }}

+ {{ chomp (.Content) }} +
+{{- end }} \ No newline at end of file diff --git a/layouts/taxonomy.atom.xml b/layouts/taxonomy.atom.xml new file mode 100644 index 0000000..cbcbae8 --- /dev/null +++ b/layouts/taxonomy.atom.xml @@ -0,0 +1,56 @@ +{{/* Deprecate site.Author.name in favor of site.Params.author.name */}} +{{- $authorName := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .name }} + {{- $authorName = . }} + {{- end }} + {{- else }} + {{- $authorName = . }} + {{- end }} +{{- else }} + {{- with site.Author.name }} + {{- $authorName = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} + {{- end }} +{{- end }} + +{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}} +{{- $authorEmail := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .email }} + {{- $authorEmail = . }} + {{- end }} + {{- end }} +{{- else }} + {{- with site.Author.email }} + {{- $authorEmail = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} + {{- end }} +{{- end -}} + +{{ "" | safeHTML }} + + {{ .Permalink }} + {{ .Site.Title }} + {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} + + + {{- with $authorName }} + + {{ . }} + {{- with $authorEmail }} + {{ . }}{{ end }} + {{ end }} + Hugo -- gohugo.io + {{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }} + {{ .Site.Params.Description }}{{ range first .Site.Config.Services.RSS.Limit .Data.Pages }} + + {{ .Permalink }} + {{ .Title }} + {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} + + {{ .Content | html }} + {{ end }} + diff --git a/layouts/taxonomy.gemini_atom.xml b/layouts/taxonomy.gemini_atom.xml new file mode 100644 index 0000000..76431e3 --- /dev/null +++ b/layouts/taxonomy.gemini_atom.xml @@ -0,0 +1,55 @@ +{{/* Deprecate site.Author.name in favor of site.Params.author.name */}} +{{- $authorName := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .name }} + {{- $authorName = . }} + {{- end }} + {{- else }} + {{- $authorName = . }} + {{- end }} +{{- else }} + {{- with site.Author.name }} + {{- $authorName = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} + {{- end }} +{{- end }} + +{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}} +{{- $authorEmail := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .email }} + {{- $authorEmail = . }} + {{- end }} + {{- end }} +{{- else }} + {{- with site.Author.email }} + {{- $authorEmail = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} + {{- end }} +{{- end -}} + +{{ "" | safeHTML }} + + {{ .Permalink | strings.TrimSuffix "index.gmi" }} + {{ .Site.Title }} + {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} + + + {{- with $authorName }} + + {{ . }} + {{- with $authorEmail }} + {{ . }}{{ end }} + {{ end }} + Hugo -- gohugo.io + {{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }} + {{ .Site.Params.Description }}{{ range first .Site.Config.Services.RSS.Limit .Data.Pages }} + + {{ .Permalink | strings.TrimSuffix "index.gmi" }} + {{ .Title }} + {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} + + {{ end }} + diff --git a/layouts/taxonomy.gmi b/layouts/taxonomy.gmi new file mode 100644 index 0000000..9c2a9f0 --- /dev/null +++ b/layouts/taxonomy.gmi @@ -0,0 +1,17 @@ +{{ define "main" -}} +=> {{ .Site.Home.RelPermalink | strings.TrimSuffix "index.gmi" }} {{ emojify ":link:" }} {{ i18n "returnHome" }} + + +# {{ .Type | humanize }} + + +## {{ i18n "feeds" }} + +=> {{ .RelPermalink | replaceRE `index.gmi$` "atom.xml" }} {{ emojify ":link:" }} {{ i18n "atomFeed" }} + + +## {{ i18n "list" }} +{{ range .Data.Pages }} +=> {{ .RelPermalink | strings.TrimSuffix "index.gmi" }} {{ emojify ":link:" }} {{ .Title -}} +{{ end -}} +{{ end }} \ No newline at end of file diff --git a/layouts/taxonomy.html b/layouts/taxonomy.html new file mode 100644 index 0000000..86d7f89 --- /dev/null +++ b/layouts/taxonomy.html @@ -0,0 +1,16 @@ +{{ define "main" -}} + +
+

{{ .Type | humanize }}

+

{{ i18n "feeds" }}

+

{{ emojify ":link:" }} {{ i18n "atomFeed" }}

+

{{ i18n "list" }}

+ +
+{{- end }} \ No newline at end of file diff --git a/layouts/term.atom.xml b/layouts/term.atom.xml new file mode 100644 index 0000000..cbcbae8 --- /dev/null +++ b/layouts/term.atom.xml @@ -0,0 +1,56 @@ +{{/* Deprecate site.Author.name in favor of site.Params.author.name */}} +{{- $authorName := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .name }} + {{- $authorName = . }} + {{- end }} + {{- else }} + {{- $authorName = . }} + {{- end }} +{{- else }} + {{- with site.Author.name }} + {{- $authorName = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} + {{- end }} +{{- end }} + +{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}} +{{- $authorEmail := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .email }} + {{- $authorEmail = . }} + {{- end }} + {{- end }} +{{- else }} + {{- with site.Author.email }} + {{- $authorEmail = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} + {{- end }} +{{- end -}} + +{{ "" | safeHTML }} + + {{ .Permalink }} + {{ .Site.Title }} + {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} + + + {{- with $authorName }} + + {{ . }} + {{- with $authorEmail }} + {{ . }}{{ end }} + {{ end }} + Hugo -- gohugo.io + {{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }} + {{ .Site.Params.Description }}{{ range first .Site.Config.Services.RSS.Limit .Data.Pages }} + + {{ .Permalink }} + {{ .Title }} + {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} + + {{ .Content | html }} + {{ end }} + diff --git a/layouts/term.gemini_atom.xml b/layouts/term.gemini_atom.xml new file mode 100644 index 0000000..287bcc4 --- /dev/null +++ b/layouts/term.gemini_atom.xml @@ -0,0 +1,55 @@ +{{/*Deprecate site.Author.name in favor of site.Params.author.name */}} +{{- $authorName := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .name }} + {{- $authorName = . }} + {{- end }} + {{- else }} + {{- $authorName = . }} + {{- end }} +{{- else }} + {{- with site.Author.name }} + {{- $authorName = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} + {{- end }} +{{- end }} + +{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}} +{{- $authorEmail := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .email }} + {{- $authorEmail = . }} + {{- end }} + {{- end }} +{{- else }} + {{- with site.Author.email }} + {{- $authorEmail = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} + {{- end }} +{{- end -}} + +{{ "" | safeHTML }} + + {{ .Permalink | strings.TrimSuffix "index.gmi" }} + {{ .Site.Title }} + {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} + + + {{- with $authorName }} + + {{ . }} + {{- with $authorEmail }} + {{ . }}{{ end }} + {{ end }} + Hugo -- gohugo.io + {{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }} + {{ .Site.Params.Description }}{{ range first .Site.Config.Services.RSS.Limit .Data.Pages }} + + {{ .Permalink | strings.TrimSuffix "index.gmi" }} + {{ .Title }} + {{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }} + + {{ end }} + diff --git a/layouts/term.gmi b/layouts/term.gmi new file mode 100644 index 0000000..5d7f7b1 --- /dev/null +++ b/layouts/term.gmi @@ -0,0 +1,19 @@ +{{ define "main" -}} +=> {{ .Site.Home.RelPermalink | strings.TrimSuffix "index.gmi" }} {{ emojify ":link:" }} {{ i18n "returnHome" }} + + +# {{ .Type | singularize | humanize }} "{{ .Title }}" + + +## {{ i18n "feeds" }} + +=> {{ .RelPermalink | replaceRE `index.gmi$` "atom.xml" }} {{ emojify ":link:" }} {{ i18n "atomFeed" }} + + +## {{ i18n "journalEntries" -}} + +{{ range .Data.Pages.ByPublishDate.Reverse }} + +{{ partial "metadata.gmi" . -}} +{{ end -}} +{{ end }} \ No newline at end of file diff --git a/layouts/term.html b/layouts/term.html new file mode 100644 index 0000000..3b268dd --- /dev/null +++ b/layouts/term.html @@ -0,0 +1,14 @@ +{{ define "main" -}} + +
+

{{ .Type | singularize | humanize }} "{{ .Title }}"

+

{{ i18n "feeds" }}

+

{{ emojify ":link:" }} {{ i18n "atomFeed" }}

+

{{ i18n "journalEntries" }}

+ {{- range .Data.Pages.ByPublishDate.Reverse }} + {{ partial "metadata.html" . -}} + {{ end }} +
+{{- end }} \ No newline at end of file -- cgit v1.2.3