feat: Support gemini posts listing `posts/index.gmi`

This commit is contained in:
hedy 2024-04-08 21:19:40 +08:00
parent 77a63d9637
commit 2e177f873f
Signed by: hedy
GPG Key ID: B51B5A8D1B176372
12 changed files with 42 additions and 19 deletions

View File

@ -46,6 +46,7 @@ gemini:
$(RSYNC) $(RSYNC_FLAGS) $(GEMINI_DEST) $(GEMINI_DEST)-back --delete
$(RSYNC) $(RSYNC_FLAGS) public/*.gmi public/posts/*.gmi public/gemini/ $(GEMINI_DEST)/ --exclude _index.gmi
$(RSYNC) $(RSYNC_FLAGS) public/posts/gemini/index.xml $(GEMINI_DEST)/feed.xml
$(RSYNC) $(RSYNC_FLAGS) public/posts/gemini/index.gmi $(GEMINI_DEST)/posts/index.gmi
gemini-clean:
@# This is the target that has caused me the most trouble, literally lost my
@ -54,6 +55,7 @@ gemini-clean:
@# manually) before using this!
@#
@# Remove copied post files
find $(GEMINI_DEST) -wholename '*/$(GEMINI_DEST_BASE)/posts/????-??-??-*.gmi' -delete
find $(GEMINI_DEST) -wholename '*/$(GEMINI_DEST_BASE)/????-??-??-*.gmi' -delete
@# Use ugly urls, find the dirs that only contains a single 'index.gmi',
@# excluding the root index.gmi

View File

@ -22,7 +22,7 @@ css](https://simplecss.org) and sometimes [seirdy's site](https://seirdy.one).
## todo
- [ ] let gemini version also have a post page at /posts/index.gmi
- [x] let gemini version also have a post page at /posts/index.gmi
- [ ] minify images and use WebP
- [x] provide atom feed for www
- [x] show post description in list

View File

@ -15,15 +15,15 @@ thoughts.
## Pages
=> /posts/ gemlog
=> about.gmi about.gmi (and methods of contact)
=> misc.gmi misc.gmi
=> //do.hedy.dev/pgp.asc PGP public key
=> //do.hedy.dev/sshkey.txt SSH public key
=> //do.hedy.dev/tinylog.gmi tinylog.gmi
=> //do.hedy.dev/tw.txt twtxt feed
=> misc.gmi misc.gmi
## Services

View File

@ -1,4 +1,5 @@
---
title: home
outputs:
- html
- gemtext

5
content/posts/_index.gmi Normal file
View File

@ -0,0 +1,5 @@
These are my long-form musings. I aim to write at least twice a year, but over the past two years I have clearly failed in this aspect. I'll try to write more often.
Comments can be sent to my public mailing list where I'll also send new posts (after 2023) as plain text to. If you subscribe to the list, it acts like a newsletter where you'll receive new posts from your inbox. Posting and subscribing happen solely through emails. No external auth required.
=> mailto:~hedy.posts@lists.sr.ht

View File

@ -1,5 +1,10 @@
---
title: Posts
outputs:
- html
- gemtext
- gematom
- rss
---

View File

@ -1,5 +1,4 @@
{{ block "content" . -}}{{ end }}
{{- block "content" . }}{{ end }}
=> {{.Site.Params.src}} Source
{{- with .OutputFormats.Get "html" }}
{{- $weburl := .Permalink }}

View File

@ -0,0 +1,4 @@
{{ define "content" -}}
{{ partial "posts.gmi" . }}
--
{{- end }}

View File

@ -1,4 +1,5 @@
{{ define "content" -}}
# {{ .Title }}
{{ $lastmod := .Lastmod -}}
@ -9,5 +10,5 @@ Last updated {{ .Lastmod.Format "2006-01-02" }}{{ end }}
{{ trim (readFile (replace $.File.Path ".md" ".gmi")) "\n" | safeHTML }}
--
=> {{ replace .Site.BaseURL "https:" "" }} Home
=> {{ replace .Site.BaseURL "https:" "gemini:" }} Home
{{- end }}

View File

@ -1,13 +1,7 @@
{{ define "content" }}
{{readFile (replace (replace $.File.Path ".md" ".gmi") ".html" ".gmi") | safeHTML}}
{{ define "content" -}}
{{ readFile (replace (replace $.File.Path ".md" ".gmi") ".html" ".gmi") | safeHTML }}
## Gemlog posts
=> feed.xml atom feed
{{ range (where .Site.RegularPages "Section" "posts") }}
{{- if .OutputFormats.Get "gemtext" }}
=> {{replace (replace .RelPermalink "/gemini" "" 1) "/index.gmi" ".gmi" 1}} {{ .Date.Format "2006-01-02" }}: {{.Title | safeHTML}}{{ end }}{{ end }}
{{ partial "posts.gmi" . }}
--
{{- end }}

View File

@ -0,0 +1,13 @@
{{ if hasPrefix .File.Path "posts" -}}
# Gemlog
{{- else -}}
## Gemlog posts
{{- end }}
{{ trim (readFile (replace (.Site.GetPage "posts").File.Path ".md" ".gmi")) "\n" | safeHTML }}
--
=> /feed.xml Atom feed
{{ range (where .Site.RegularPages "Section" "posts") }}
{{- if .OutputFormats.Get "gemtext" }}
=> {{replace (replace .RelPermalink "/gemini" "" 1) "/index.gmi" ".gmi" 1}} {{ .Date.Format "2006-01-02" }}: {{.Title | safeHTML}}{{ end }}{{- end }}

View File

@ -1,5 +1,5 @@
{{ define "content" }}
# {{$.Title}}
{{ define "content" -}}
# {{ $.Title }}
Posted {{ .Date.Format "2006-01-02" }}
{{ $lastmod := .Lastmod -}}
@ -21,7 +21,6 @@ Tag:
{{ trim (readFile (replace $.File.Path ".md" ".gmi")) "\n" | safeHTML }}
--
Questions/comments:
=> mailto:~hedy/posts@lists.sr.ht Public gemlog mailing list (plain-text only)