mirror of
https://github.com/by-jp/www.byjp.me.git
synced 2025-08-10 19:05:41 +01:00
Gemini: Remove index.gmi suffixes
This commit is contained in:
parent
8767a7bc9b
commit
85b9937424
6 changed files with 22 additions and 17 deletions
|
@ -4,14 +4,14 @@
|
||||||
{{- $type := .Type -}}
|
{{- $type := .Type -}}
|
||||||
{{- $paginateType := (partial "article-type.txt" (default "page" $type)) -}}
|
{{- $paginateType := (partial "article-type.txt" (default "page" $type)) -}}
|
||||||
{{- with .NextInSection }}
|
{{- with .NextInSection }}
|
||||||
=> {{ .RelPermalink }} Next {{ $paginateType }}: {{ partial "page-title.txt" . }}{{ end }}
|
=> {{ partial "noindex.gmi" .RelPermalink }} Next {{ $paginateType }}: {{ partial "page-title.txt" . }}{{ end }}
|
||||||
{{- with .PrevInSection }}
|
{{- 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 }}
|
{{ 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 }}
|
{{- with .Paginator.Prev }}
|
||||||
=> {{ .URL }} Previous page of {{ $paginateType | pluralize }}{{ end }}{{ end }}
|
=> {{ partial "noindex.gmi" .URL }} Previous page of {{ $paginateType | pluralize }}{{ end }}{{ end }}
|
||||||
=> https://www.byjp.me{{ replace .RelPermalink "index.gmi" "" }} View this page on the WWW
|
=> https://www.byjp.me{{ partial "noindex.gmi" .RelPermalink }} View this page on the WWW
|
||||||
|
|
||||||
{{ $dateType := "published" -}}
|
{{ $dateType := "published" -}}
|
||||||
{{- $date := .Date -}}
|
{{- $date := .Date -}}
|
||||||
|
@ -34,5 +34,5 @@ You may also want to visit:
|
||||||
|
|
||||||
=> / 🏡 Home
|
=> / 🏡 Home
|
||||||
{{ range .Site.Menus.main -}}
|
{{ range .Site.Menus.main -}}
|
||||||
=> {{ .URL | relURL }} {{ .Name }}
|
=> {{ partial "noindex.gmi" (.URL | relURL) }} {{ .Name }}
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
{{- range $paginatorGroup }}
|
{{- range $paginatorGroup }}
|
||||||
## {{ .Key }}
|
## {{ .Key }}
|
||||||
{{ range .Pages -}}
|
{{ 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 -}}
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
{{- partial "markdown.gmi" . -}}{{ end }}
|
{{- partial "markdown.gmi" . -}}{{ end }}
|
||||||
|
|
||||||
{{ range .Pages.ByTitle -}}
|
{{ 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 -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
Some of my recent (and more substantial) writing.
|
Some of my recent (and more substantial) writing.
|
||||||
{{ $posts := where .Site.RegularPages "Section" "in" (slice "posts" "bookmarks" "poetry") -}}
|
{{ $posts := where .Site.RegularPages "Section" "in" (slice "posts" "bookmarks" "poetry") -}}
|
||||||
{{- range ($posts.ByPublishDate.Reverse | first 6) }}
|
{{- 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 }}
|
{{- end }}
|
||||||
|
|
||||||
=> /posts/ 📔 More posts (my longer articles)
|
=> /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 }}.
|
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!
|
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 }}
|
=> {{ partial "noindex.gmi" (index $upcomingEvents 0).Page.RelPermalink }} {{ (index $upcomingEvents 0).Title }}
|
||||||
=> {{ (index $upcomingEvents 1).Page.RelPermalink }} {{ (index $upcomingEvents 1).Title }}
|
=> {{ partial "noindex.gmi" (index $upcomingEvents 1).Page.RelPermalink }} {{ (index $upcomingEvents 1).Title }}
|
||||||
|
|
||||||
=> /calendar/ 🗓️ My events calendar
|
=> /calendar/ 🗓️ My events calendar
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -18,19 +18,19 @@
|
||||||
{{/* Horizontal rules */}}
|
{{/* Horizontal rules */}}
|
||||||
{{- $content := $content | replaceRE "\n+---\n+" "\n\n" -}}
|
{{- $content := $content | replaceRE "\n+---\n+" "\n\n" -}}
|
||||||
{{/* Images */}}
|
{{/* Images */}}
|
||||||
{{- $content := $content | replaceRE `\n\n!\[.*]\((.+?)\)` "\n\n=> $1 Linked image" -}}
|
{{- $content := $content | replaceRE `\n\n!\[.*?]\((.+?)\)` "\n\n=> $1 Linked image" -}}
|
||||||
|
|
||||||
{{/* Links */}}
|
{{/* Links */}}
|
||||||
{{- $content := $content | replaceRE `<a .*?href="(.+?)".*?>(.+?)</a>` "[$2]($1)" -}}
|
{{- $content := $content | replaceRE `<a .*?href="(.+?)".*?>(.+?)</a>` "[$2]($1)" -}}
|
||||||
{{- $content := $content | replaceRE `\sgemini://(\S*)` " [gemini://$1](gemini://$1)" -}}
|
{{- $content := $content | replaceRE `\sgemini://(\S*)` " [gemini://$1](gemini://$1)" -}}
|
||||||
|
|
||||||
{{- $refs := findRE `\[.+?\]\([^#].+?\)` $content -}}
|
{{- $refs := findRE `\[[^]]+?\]\([^#][^)]+?\)` $content -}}
|
||||||
{{/* Remove lines that are only hashtags */}}
|
{{/* Remove lines that are only hashtags */}}
|
||||||
{{- $content := $content | replaceRE `\n(\[.+?\]\(/tags/.*\) *)+\n` "" -}}
|
{{- $content := $content | replaceRE `\n(\[[^]]+?\]\(/tags/[^)]*?\) *)+\n` "" -}}
|
||||||
{{/* Give hashtags a hash */}}
|
{{/* Give hashtags a hash */}}
|
||||||
{{- $content := $content | replaceRE `\[(.+?)\]\(/tags/.*\)` "#$1" -}}
|
{{- $content := $content | replaceRE `\[([^]]+?)\]\(/tags/[^)]*?\)` "#$1" -}}
|
||||||
{{/* Give other links a subscript indicator */}}
|
{{/* Give other links a subscript indicator */}}
|
||||||
{{- $content := $content | replaceRE `\[(.+?)\]\((.+?)\)` "$1⁺" -}}
|
{{- $content := $content | replaceRE `\[([^]]+?)\]\(([^)]+?)\)` "$1⁺" -}}
|
||||||
|
|
||||||
{{- $content | safeHTML -}}
|
{{- $content | safeHTML -}}
|
||||||
{{- if gt (len $refs) 0 -}}
|
{{- if gt (len $refs) 0 -}}
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
{{- range $refs -}}
|
{{- range $refs -}}
|
||||||
{{- $parts := split . "](" -}}
|
{{- $parts := split . "](" -}}
|
||||||
{{- $title := substr (index $parts 0) 1 | strings.FirstUpper -}}
|
{{- $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 "/twitter/#" }}{{ continue }}{{ end -}}
|
||||||
{{- if hasPrefix $link "/tags/" }}{{ $title = printf "🔗 #%s" $title }}{{ end -}}
|
{{- if hasPrefix $link "/tags/" }}{{ $title = printf "🔗 #%s" $title }}{{ end -}}
|
||||||
=> {{ printf "%s %s\n" $link $title -}}
|
=> {{ printf "%s %s\n" $link $title -}}
|
||||||
|
|
5
layouts/partials/noindex.gmi
Normal file
5
layouts/partials/noindex.gmi
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{{- $url := . -}}
|
||||||
|
{{- if hasSuffix $url "/index.gmi" -}}
|
||||||
|
{{- $url = strings.TrimSuffix "index.gmi" $url -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- return $url -}}
|
Loading…
Reference in a new issue