aboutsummaryrefslogtreecommitdiff
path: root/layouts/_default/single.gmi
blob: 09456ab5e7d4e79f3ffdcc33ec7c444551070e357840550afae14d8cf7b6f78c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{{ define "main" }}
{{ $emoji := cond (.Page.Params.showlinkemoji | default true) (emojify ":link: ") "" -}}
=> / {{ emojify ":link:" }} Return to homepage


{{ if (.Page.Params.pageinfo | default true) }}{{ partial "pageinfo" . }}

{{ end -}}
# {{ .Name | safeHTML }}
{{ $content := .RawContent }}
{{- $refs := findRE `\[.+?\]\(.+?\)` $content }}
{{- if (.Page.Params.makerefs | default true) }}
	{{- range $ref_index, $ref_val := $refs }}
		{{- $ref_num := add $ref_index 1 }}
		{{- $ref_text := $ref_val | replaceRE `\[(.+?)\]\((.+?)\)` "$1" }}
		{{- $content = replace $content $ref_val (print $ref_text "[" $ref_num "]") 1 }}
	{{- end }}
{{- else }}
	{{- $content = $content | replaceRE `(?m)\[(.+?)\]\((.+?)\)` (print "=> $2 " $emoji "$1") }}
{{- end }}
{{- $content = $content | replaceRE `(?m)^####{1,3}` "###" }}
{{- $content = $content | replaceRE `(?s)\*{3}(.*?)\*{3}|\*{2}(.*?)\*{2}|\*{1}(.*?)\*{1}` "$1$2$3" }}
{{- $content = $content | replaceRE `(?m)^- ` "* " }}
{{- $content = $content | emojify }}
{{- $content | safeHTML }}
{{- if and (.Page.Params.makerefs | default true) $refs }}

## Links
	{{- range $ref_index, $ref_val := $refs }}
		{{- $ref_num := add $ref_index 1 }}
		{{- $ref_text := $ref_val | replaceRE `\[(.+?)\]\((.+?)\)` "$1" }}
		{{- $ref_link := $ref_val | replaceRE `\[(.+?)\]\((.+?)\)` "$2" }}
{{ print "=> " $ref_link " " $emoji $ref_num ": " $ref_text | safeHTML }}
	{{- end }}
{{- end }}
{{- end }}