let Hugo generate gemini files

This commit is contained in:
Wouter Groeneveld 2021-04-03 09:39:40 +02:00
parent 01100eb155
commit 1e8d2bfc13
3 changed files with 105 additions and 0 deletions

View File

@ -91,3 +91,20 @@ enableGitInfo = true
url = "/projects"
weight = 6
[mediaTypes]
[mediaTypes."text/gemini"]
suffixes = ["gmi"]
[outputFormats]
[outputFormats.GEMINI]
name = "GEMINI"
isPlainText = true
isHTML = false
mediaType = "text/gemini"
protocol = "gemini://"
permalinkable = true
path = "gemini/"
[outputs]
home = ["HTML", "RSS", "GEMINI"]
page = ["HTML", "GEMINI"]

View File

@ -0,0 +1,29 @@
# {{ .Title }}{{ $scratch := newScratch }}{{ $scratch.Set "ref" 1 }}
{{ $content := .RawContent -}}
{{ $content := $content | replaceRE "`(.+?)`" "$1" -}}{{ $content := $content | replaceRE "`" "```" -}}
{{ $content := $content | replaceRE `\*\*(.+?)\*\*` "$1" -}}
{{ $content := $content | replaceRE `_(.+?)_` "$1" -}}
{{ $content := $content | replaceRE `\n- (.+?)` "\n* $1" -}}
{{ $content := $content | replaceRE `\n(\d+). (.+?)` "\n* $2" -}}
{{ $content := $content | replaceRE `\[\^(.+?)\]:?` "" -}}
{{ $content := $content | replaceRE `!\[\]\((.+?) \"(.+?)\"\)` "=> $1 Image: $2" -}}
{{ $refs := findRE `\[.+?\]\(.+?\)` $content }}
{{ $scratch.Set "content" $content }}{{ range $refs }}{{ $ref := $scratch.Get "ref" }}{{ $contentInLoop := $scratch.Get "content" }}{{ $url := (printf "%s #%d" . $ref) }}{{ $contentInLoop := replace $contentInLoop . $url -}}{{ $scratch.Set "content" $contentInLoop }}{{ $scratch.Set "ref" (add $ref 1) }}{{ end }}{{ $content := $scratch.Get "content" | replaceRE `\[(.+?)\]\((.+?)\) #(\d+)` "$1 [$3]" -}}
{{ $content }}
---
Written by Wouter Groeneveld on {{ .Lastmod.Format (.Site.Params.dateFormat | default "2 January 2006") }}.
## References
{{ $scratch.Set "ref" 1 }}{{ range $refs }}{{ $ref := $scratch.Get "ref" }}{{ $url := (printf "%s #%d" . $ref) }}
=> {{ $url | replaceRE `\[(.+?)\]\((.+?)\) #(\d+)` "$2 [$3] $1 ($2)" -}}
{{ $scratch.Set "ref" (add $ref 1) }}{{ end}}
{{ $related := first 3 (where (where .Site.RegularPages.ByDate.Reverse ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" .Permalink) }}
{{ if $related }}
## Related articles
{{ range $related }}
=> {{ .RelPermalink }} {{ .Title }}: {{ .Params.Subtitle }}{{ end }}{{ end }}
---
=> {{ replace .Site.BaseURL "https" "gemini" }} Back to the Index

59
layouts/index.gmi Normal file
View File

@ -0,0 +1,59 @@
```
,---. .=-.-..-._ ,---. ,--.-.,-. .=-.-..-._ _,---.
_..---. .-.,.---. .--.' \ /==/_ /==/ \ .-._ _..---. .--.' \ /==/- |\ \ /==/_ /==/ \ .-._ _.='.'-, \
.' .'.-. \ /==/ ` \ \==\-/\ \ |==|, ||==|, \/ /, / .' .'.-. \ \==\-/\ \ |==|_ `/_ /|==|, ||==|, \/ /, /==.'- /
/==/- '=' /|==|-, .=., |/==/-|_\ | |==| ||==|- \| | /==/- '=' / /==/-|_\ | |==| , / |==| ||==|- \| /==/ - .-'
|==|-, ' |==| '=' /\==\, - \ |==|- ||==| , | -| |==|-, ' \==\, - \ |==|- .| |==|- ||==| , | -|==|_ /_,-.
|==| .=. \|==|- , .' /==/ - ,| |==| ,||==| - _ | |==| .=. \ /==/ - ,| |==| _ , \ |==| ,||==| - _ |==| , \_.' )
/==/- '=' ,|==|_ . ,'./==/- /\ - \|==|- ||==| /\ , | /==/- '=' ,/==/- /\ - \/==/ '\ ||==|- ||==| /\ , \==\- , (
|==| - //==/ /\ , )==\ _.\=\.-'/==/. //==/, | |- | |==| - /\==\ _.\=\.-'\==\ /\=\.'/==/. //==/, | |- |/==/ _ , /
`-._`.___,' `--`-`--`--' `--` `--`-` `--`./ `--` `-._`.___,' `--` `--` `--`-` `--`./ `--``--`------'
```
# Brain Baking in Space
> Brain Baking: transforming personal thoughts about thoughts into well-digestible material. The reflective aroma of burnt nervous tissue. Includes a crispy crust of relations between technology, philosophy and the world.
## About The Head Brain Baker
Hey! I'm Wouter Groeneveld, a level {{ .Site.Params.level }} Brain Baker living in Belgium. I currently find myself teaching, writing, programming, researching, and of course baking bread! Brain Baking is my way to inspire myself and others to ponder and learn.
If you found my bakings amusing and/or helpful, you can buy me a coffee - if you don't mind I'll use it to enjoy a cup of tea instead. I also like to hear about your own bakings via Mastodon or e-mail. Thanks!
=> https://ko-fi.com/woutergroeneveld Ko-fi Donations
=> {{ .Site.Author.mastodonlink }} Mastodon
=> mailto:{{ .Site.Author.email }} E-mail
## Freshly Baked Thoughts: The Gemlog
Behold my freshly baked thoughts for you to enjoy. If you'd like, you can subscribe to the RSS feeds. I hear they're lovely in your favorite RSS client.
=> https://brainbaking.com/post/index.xml RSS Feeds (HTTPS)
{{ range (where (where (where .Site.Pages "Section" "in" (slice "post")) ".Params.type" "ne" "archive") ".Params.concept" "ne" "true").GroupByDate "2006" "desc" }}{{ $year := .Key -}}
{{ range .Pages.GroupByDate "January" }}
### {{ .Key }} {{ $year }}
{{ range .Pages.ByDate.Reverse }}
=> {{ replace .Permalink "/gemini" "" 1}} {{ .Date.Format ("02") }} - {{ .Title }}
{{ .Params.Subtitle }}{{ end }}
{{ end }}
{{ end }}
# That's All Folks.
Go on. Have a snack. How about some chocolate?
```
___ ___ ___ ___ ___.---------------.
.'\__\'\__\'\__\'\__\'\__,` . ____ ___ \
|\/ __\/ __\/ __\/ __\/ _:\ |`. \ \___ \
\\'\__\'\__\'\__\'\__\'\_`.__|""`. \ \___ \
\\/ __\/ __\/ __\/ __\/ __: \
\\'\__\'\__\'\__\ \__\'\_;-----------------`
\\/ \/ \/ \/ \/ : hh|
\|______________________;________________|
```