build gemini variants
authorxangelo <git@xangelo.ca>
Mon, 21 Jun 2021 21:11:36 +0000 (17:11 -0400)
committerxangelo <git@xangelo.ca>
Mon, 21 Jun 2021 21:11:36 +0000 (17:11 -0400)
config.toml
layouts/_default/single.gmi [new file with mode: 0644]
layouts/index.gmi [new file with mode: 0644]

index 42e16e71543041fcb553f62464bf493af002932e..e5fbde2312d0f81da0580915518892ba497c833d 100644 (file)
@@ -28,3 +28,21 @@ tabWidth = 2
     endLevel = 3
     ordered = true
     startLevel = 2
     endLevel = 3
     ordered = true
     startLevel = 2
+
+[mediaTypes]
+  [mediaTypes."text/gemini"]
+    suffixes = ["gmi"]
+
+[outputFormats]
+[outputFormats.Gemini]
+name = "GEMINI"
+mediaType = "text/gemini"
+isPlainText = true
+isHTML = false
+protocol = "gemini://"
+permalinkable = true
+path = "gemini/"
+
+[outputs]
+home = ["HTML", "RSS", "GEMINI"]
+page = ["HTML", "GEMINI"]
diff --git a/layouts/_default/single.gmi b/layouts/_default/single.gmi
new file mode 100644 (file)
index 0000000..c939202
--- /dev/null
@@ -0,0 +1,33 @@
+# {{ .Title }}{{ $scratch := newScratch }}
+{{ $content := .RawContent -}}
+{{ $content := $content | replaceRE `#### ` "### " -}}
+{{ $content := $content | replaceRE `\n- (.+?)` "\n* $1" -}}
+{{ $content := $content | replaceRE `\n(\d+). (.+?)` "\n* $2" -}}
+{{ $content := $content | replaceRE `\[\^(.+?)\]:?` "" -}}
+{{ $content := $content | replaceRE `<br/??>` "\n" -}}
+{{ $content := $content | replaceRE `<a .*href="(.+?)".*>(.+?)</a>` "[$2]($1)" -}}
+{{ $content := $content | replaceRE `\sgemini://(\S*)` " [gemini://$1](gemini://$1)" -}}
+{{ $content := $content | replaceRE `{{< youtube (.+?) >}}` "=> https://www.youtube.com/watch?v=$1 YouTube Video link to $1" -}}
+{{ $content := $content | replaceRE `{{< vimeo (.+?) >}}` "=> https://vimeo.com/$1 Vimeo Video link to $1" -}}
+{{ $content := $content | replaceRE "([^`])<.*?>([^`])" "$1$2" -}}
+{{ $content := $content | replaceRE `\n\n!\[.*\]\((.+?) \"(.+?)\"\)` "\n\n=> $1 Image: $2" -}}
+{{ $content := $content | replaceRE `\n\n!\[.*]\((.+?)\)` "\n\n=> $1 Embedded Image: $1" -}}
+{{ $links := findRE `\n=> ` $content }}{{ $scratch.Set "ref" (add (len $links) 1) }}
+{{ $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]" -}}
+
+{{ if .Next }}=> {{ replace .Next.Permalink "xangelo.ca/gemini" "gemini.xangelo.ca" 1}} ← Newer: {{ .Next.Title }}{{ end }}
+{{ if .Prev -}}=> {{ replace .Prev.Permalink "xangelo.ca/gemini" "gemini.xangelo.ca" 1}} → Older: {{ .Prev.Title }}{{- end }}
+{{ $content | safeHTML }}
+
+---
+## References
+{{ $scratch.Set "ref" (add (len $links) 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 }}
+=> {{ replace .RelPermalink "xangelo.ca/gemini" "gemini.xangelo.ca" 1}} {{ .Title }}: {{ .Params.Subtitle }}{{ end }}{{ end }}
+---
diff --git a/layouts/index.gmi b/layouts/index.gmi
new file mode 100644 (file)
index 0000000..96bbd24
--- /dev/null
@@ -0,0 +1,9 @@
+## List of posts
+
+{{ range .Site.RegularPages.GroupByDate "2006" }}
+### {{ .Key }}
+{{ range .Pages.ByDate.Reverse }}
+=> {{ replace .Permalink "xangelo.ca/gemini" "gemini.xangelo.ca" 1}} {{ .Title }}
+{{- end }}
+{{ end }}
+