Gemini: Remove index.gmi suffixes

This commit is contained in:
JP Hastings-Spital 2024-05-01 00:03:17 +01:00
parent 8767a7bc9b
commit 85b9937424
6 changed files with 22 additions and 17 deletions

View file

@ -4,14 +4,14 @@
{{- $type := .Type -}}
{{- $paginateType := (partial "article-type.txt" (default "page" $type)) -}}
{{- with .NextInSection }}
=> {{ .RelPermalink }} Next {{ $paginateType }}: {{ partial "page-title.txt" . }}{{ end }}
=> {{ partial "noindex.gmi" .RelPermalink }} Next {{ $paginateType }}: {{ partial "page-title.txt" . }}{{ end }}
{{- with .PrevInSection }}
=> {{ .RelPermalink }} Previous {{ $paginateType }}: {{ partial "page-title.txt" . }}{{ end }}
=> {{ partial "noindex.gmi" .RelPermalink }} Previous {{ $paginateType }}: {{ partial "page-title.txt" . }}{{ end }}
{{ if eq .Kind "section" }}{{ with .Paginator.Next }}
=> {{ .URL }} Next page of {{ $paginateType | pluralize }}{{ end }}
=> {{ partial "noindex.gmi" .URL }} Next page of {{ $paginateType | pluralize }}{{ end }}
{{- with .Paginator.Prev }}
=> {{ .URL }} Previous page of {{ $paginateType | pluralize }}{{ end }}{{ end }}
=> https://www.byjp.me{{ replace .RelPermalink "index.gmi" "" }} View this page on the WWW
=> {{ partial "noindex.gmi" .URL }} Previous page of {{ $paginateType | pluralize }}{{ end }}{{ end }}
=> https://www.byjp.me{{ partial "noindex.gmi" .RelPermalink }} View this page on the WWW
{{ $dateType := "published" -}}
{{- $date := .Date -}}
@ -34,5 +34,5 @@ You may also want to visit:
=> / 🏡 Home
{{ range .Site.Menus.main -}}
=> {{ .URL | relURL }} {{ .Name }}
=> {{ partial "noindex.gmi" (.URL | relURL) }} {{ .Name }}
{{ end -}}

View file

@ -10,7 +10,7 @@
{{- range $paginatorGroup }}
## {{ .Key }}
{{ range .Pages -}}
=> {{ .RelPermalink }} {{ with .Params.emoji }}{{ . }} {{ end }}{{ partial "page-title.txt" . }}
=> {{ partial "noindex.gmi" .RelPermalink }} {{ with .Params.emoji }}{{ . }} {{ end }}{{ partial "page-title.txt" . }}
{{ end -}}
{{- end -}}
{{- end -}}

View file

@ -5,6 +5,6 @@
{{- partial "markdown.gmi" . -}}{{ end }}
{{ range .Pages.ByTitle -}}
=> {{ .RelPermalink }} {{ with .Params.emoji }}{{ . }} {{ end }}{{ partial "page-title.txt" . }}
=> {{ partial "noindex.gmi" .RelPermalink }} {{ with .Params.emoji }}{{ . }} {{ end }}{{ partial "page-title.txt" . }}
{{ end -}}
{{- end -}}

View file

@ -10,7 +10,7 @@
Some of my recent (and more substantial) writing.
{{ $posts := where .Site.RegularPages "Section" "in" (slice "posts" "bookmarks" "poetry") -}}
{{- range ($posts.ByPublishDate.Reverse | first 6) }}
=> {{.RelPermalink}} {{ with .Params.emoji }}{{.}}{{ else }}🔗{{end}} {{ with .Title -}}{{ . }}{{ else }}{{ .Type | singularize | title }}{{ end -}}
=> {{ partial "noindex.gmi" .RelPermalink}} {{ with .Params.emoji }}{{.}}{{ else }}🔗{{end}} {{ with .Title -}}{{ . }}{{ else }}{{ .Type | singularize | title }}{{ end -}}
{{- end }}
=> /posts/ 📔 More posts (my longer articles)
@ -33,8 +33,8 @@ Some of my recent (and more substantial) writing.
Maybe you'll see me at **{{ (index $upcomingEvents 0).Title }}** on {{ (partial "year-relative-date.html" (index $upcomingEvents 0).Date) | plainify }}, or **{{ (index $upcomingEvents 1).Title }}** on {{ (partial "year-relative-date.html" (index $upcomingEvents 1).Date) | plainify }}.
Get in touch if you'd like to go to these, or any other events⁺, together!
=> {{ (index $upcomingEvents 0).Page.RelPermalink }} {{ (index $upcomingEvents 0).Title }}
=> {{ (index $upcomingEvents 1).Page.RelPermalink }} {{ (index $upcomingEvents 1).Title }}
=> {{ partial "noindex.gmi" (index $upcomingEvents 0).Page.RelPermalink }} {{ (index $upcomingEvents 0).Title }}
=> {{ partial "noindex.gmi" (index $upcomingEvents 1).Page.RelPermalink }} {{ (index $upcomingEvents 1).Title }}
=> /calendar/ 🗓️ My events calendar
{{ end }}

View file

@ -18,19 +18,19 @@
{{/* Horizontal rules */}}
{{- $content := $content | replaceRE "\n+---\n+" "\n\n" -}}
{{/* Images */}}
{{- $content := $content | replaceRE `\n\n!\[.*]\((.+?)\)` "\n\n=> $1 Linked image" -}}
{{- $content := $content | replaceRE `\n\n!\[.*?]\((.+?)\)` "\n\n=> $1 Linked image" -}}
{{/* Links */}}
{{- $content := $content | replaceRE `<a .*?href="(.+?)".*?>(.+?)</a>` "[$2]($1)" -}}
{{- $content := $content | replaceRE `\sgemini://(\S*)` " [gemini://$1](gemini://$1)" -}}
{{- $refs := findRE `\[.+?\]\([^#].+?\)` $content -}}
{{- $refs := findRE `\[[^]]+?\]\([^#][^)]+?\)` $content -}}
{{/* Remove lines that are only hashtags */}}
{{- $content := $content | replaceRE `\n(\[.+?\]\(/tags/.*\) *)+\n` "" -}}
{{- $content := $content | replaceRE `\n(\[[^]]+?\]\(/tags/[^)]*?\) *)+\n` "" -}}
{{/* Give hashtags a hash */}}
{{- $content := $content | replaceRE `\[(.+?)\]\(/tags/.*\)` "#$1" -}}
{{- $content := $content | replaceRE `\[([^]]+?)\]\(/tags/[^)]*?\)` "#$1" -}}
{{/* Give other links a subscript indicator */}}
{{- $content := $content | replaceRE `\[(.+?)\]\((.+?)\)` "$1⁺" -}}
{{- $content := $content | replaceRE `\[([^]]+?)\]\(([^)]+?)\)` "$1⁺" -}}
{{- $content | safeHTML -}}
{{- if gt (len $refs) 0 -}}
@ -38,7 +38,7 @@
{{- range $refs -}}
{{- $parts := split . "](" -}}
{{- $title := substr (index $parts 0) 1 | strings.FirstUpper -}}
{{- $link := substr (index $parts 1) 0 (sub (len (index $parts 1)) 1) -}}
{{- $link := partial "noindex.gmi" (substr (index $parts 1) 0 (sub (len (index $parts 1)) 1)) -}}
{{- if hasPrefix $link "/twitter/#" }}{{ continue }}{{ end -}}
{{- if hasPrefix $link "/tags/" }}{{ $title = printf "🔗 #%s" $title }}{{ end -}}
=> {{ printf "%s %s\n" $link $title -}}

View file

@ -0,0 +1,5 @@
{{- $url := . -}}
{{- if hasSuffix $url "/index.gmi" -}}
{{- $url = strings.TrimSuffix "index.gmi" $url -}}
{{- end -}}
{{- return $url -}}