Fix taxonomy pages

This commit is contained in:
JP Hastings-Spital 2024-04-30 09:40:43 +01:00
parent 76cf7da9ad
commit 26e57ca402
8 changed files with 42 additions and 15 deletions

3
.gitignore vendored
View file

@ -3,4 +3,5 @@
/.hugo_build.lock
/.lycheecache
.env
*.der
# Ignore Agate gemini server's files
/.certificates

View file

@ -3,7 +3,7 @@
version: '3'
vars:
domain: https://www.byjp.me
domain: www.byjp.me
puma_dev_tld: .test
env:
@ -26,15 +26,15 @@ tasks:
port: 1313
cmds:
- |
[ -d "$HOME/.puma-dev/" ] && (echo {{ .port }} > $HOME/.puma-dev/www.byjp.me) || echo "Puma dev not installed, https://{{ .domain }}{{ .puma_dev_tld }} will not work"
- hugo server -p {{ .port }} --minify --printUnusedTemplates -D --baseURL "{{ .domain }}{{ .puma_dev_tld }}" --appendPort=false
[ -d "$HOME/.puma-dev/" ] && (echo {{ .port }} > $HOME/.puma-dev/{{ .domain }}) || echo "Puma dev not installed, https://{{ .domain }}{{ .puma_dev_tld }} will not work"
- hugo server -p {{ .port }} --minify --printUnusedTemplates -D --baseURL "https://{{ .domain }}{{ .puma_dev_tld }}" --appendPort=false
build:
desc: Builds the production-ready site in ./public/
vars:
cache: /tmp/hugo/cache
cmds:
- hugo --cacheDir {{ .cache }} --gc --minify --baseURL "{{ .domain }}"
- hugo --cacheDir {{ .cache }} --gc --minify --baseURL "https://{{ .domain }}"
- pagefind
import:
@ -48,4 +48,4 @@ tasks:
desc: Builds the site & starts a gemini server (on the default port) for it.
deps: [ build ]
cmds:
- agate --content public --lang en-GB --hostname localhost --central-conf
- agate --content public --lang en-GB --hostname "{{ .domain }}{{ .puma_dev_tld }}" --central-conf

View file

@ -198,6 +198,8 @@ date = ["date", "publishDate", "lastmod", ":git"]
[outputs]
home = ["html", "rss", "gemini"]
section = ["html", "rss", "gemini"]
taxonomy = ["html", "rss", "gemini"]
term = ["html", "rss", "gemini"]
page = ["html", "gemini"]
[minify]

View file

@ -6,7 +6,8 @@
{{- $paginator := .Paginate .Pages -}}
{{- range $paginator.Pages.GroupByDate "2006" }}
{{- $paginatorGroup := $paginator.Pages.GroupByDate "2006" -}}
{{- range $paginatorGroup }}
## {{ .Key }}
{{ range .Pages -}}
=> {{ .RelPermalink }} {{ with .Params.emoji }}{{ . }} {{ end }}{{ partial "page-title.txt" . }}

View file

@ -0,0 +1,10 @@
{{- define "main" -}}
# {{ with .Params.emoji }}{{.}} {{end}}{{ title (replace .Title "-" " ") }}
{{- with .Page.RenderShortcodes }}
{{- partial "markdown.gmi" . -}}{{ end }}
{{ range .Pages.ByTitle -}}
=> {{ .RelPermalink }} {{ with .Params.emoji }}{{ . }} {{ end }}{{ partial "page-title.txt" . }}
{{ end -}}
{{- end -}}

View file

@ -1,6 +1,7 @@
{{- $src := path.Join (path.Dir .Page.RelPermalink) .src -}}
{{- $title := "An untitled image" -}}
{{- if hasSuffix $src ".mp4" }}{{ $title = "An untitled video" }}{{ end -}}
{{- $emoji := "🖼️" -}}
{{- $title := "Linked image" -}}
{{- if hasSuffix $src ".mp4" }}{{ $title = "Linked video" }}{{- $emoji = "📼" -}}{{ end -}}
{{- $caption := .caption -}}
{{- $captionChunks := split $caption "." -}}
{{- $shortCap := index $captionChunks 0 }}
@ -9,6 +10,6 @@
{{- $caption = delimit (after 1 $captionChunks) "." -}}
{{- end -}}
{{- with .title }}{{if gt (len .) 0 }}{{ $title = . }}{{ end }}{{ end -}}
{{ "\n=>" }} {{ $src }} {{ $title }}
{{ "\n=>" }} {{ $src }} {{ $emoji }} {{ $title }}
{{- with $caption }}{{ if ne $title . }}
> {{ . }}{{ end }}{{ end -}}

View file

@ -15,19 +15,24 @@
{{/* Swap out forced newlines */}}
{{- $content := $content | replaceRE `<br/??>` "\n" -}}
{{- $content := $content | replaceRE `\\\n` "\n" -}}
{{/* Links */}}
{{- $content := $content | replaceRE `<a .*href="(.+?)".*>(.+?)</a>` "[$2]($1)" -}}
{{- $content := $content | replaceRE `\sgemini://(\S*)` " [gemini://$1](gemini://$1)" -}}
{{/* Horizontal rules */}}
{{- $content := $content | replaceRE "\n+---\n+" "\n\n" -}}
{{/* Images */}}
{{- $content := $content | replaceRE `\n\n!\[.*]\((.+?)\)` "\n\n=> $1 An untitled 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 -}}
{{/* Remove lines that are only hashtags */}}
{{- $content := $content | replaceRE `\n(\[.+?\]\(/tags/.*\) *)+\n` "" -}}
{{/* Give hashtags a hash */}}
{{- $content := $content | replaceRE `\[(.+?)\]\(/tags/.*\)` "#$1" -}}
{{/* Give other links a subscript indicator */}}
{{- $content := $content | replaceRE `\[(.+?)\]\((.+?)\)` "$1⁺" -}}
{{- $content | safeHTML -}}
{{- if gt (len $refs) 0 -}}
{{- "\n" -}}
{{- range $refs -}}
@ -35,6 +40,7 @@
{{- $title := substr (index $parts 0) 1 | strings.FirstUpper -}}
{{- $link := 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 -}}
{{- end -}}
{{- end -}}

View file

@ -19,6 +19,12 @@ Things I might work on within my personal blog's software.
- [ ] Add links to memex from §refs
- [ ] Switch Memex to single file (easier to post to)
- [ ] Remove http://gowal.la & https://4sq.com links and/or posts that are useless without them
- [ ] Gemini?!
- [x] Tags pages
- [ ] Calendar page
- [ ] Include link, location, date on event page
- [ ] Handle `<details>` in posts (example: ChefGPT)
- [ ] Actually serve it up
### Working