1
0
Fork 0
mirror of https://git.sr.ht/~adnano/kiln synced 2024-05-29 02:26:07 +02:00
kiln/templates.go

42 lines
1.0 KiB
Go
Raw Normal View History

2020-09-29 22:42:27 +02:00
package main
import "text/template"
// Default templates
const atom_xml = `<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ .Title }}</title>
2020-09-30 03:30:50 +02:00
<link href="{{ .URL }}"/>
<link rel="self" href="{{ .URL }}{{ .Path }}"/>
2020-09-29 22:42:27 +02:00
<updated>{{ .Updated }}</updated>
2020-09-30 03:30:50 +02:00
<id>{{ .URL }}{{ .Path }}</id>
{{- $url := .URL -}}
{{- range .Entries }}
2020-09-29 22:42:27 +02:00
<entry>
<title>{{ .Title }}</title>
2020-09-30 03:30:50 +02:00
<link href="{{ $url }}{{ .Permalink }}"/>
<id>{{ $url }}{{ .Permalink }}</id>
2020-09-29 22:42:27 +02:00
<updated>{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}</updated>
2020-09-30 03:30:50 +02:00
<content src="{{ $url }}{{ .Permalink }}" type="text/gemini"></content>
2020-09-29 22:42:27 +02:00
</entry>
2020-09-30 03:30:50 +02:00
{{ end -}}
2020-09-29 22:42:27 +02:00
</feed>`
const index_gmi = `# Index of {{ .Permalink }}
2020-09-30 03:30:50 +02:00
{{ range .Dirs }}=> {{ .Permalink }}
{{ end -}}
2020-09-29 22:42:27 +02:00
{{ range .Pages }}=> {{ .Permalink }}
2020-09-30 03:30:50 +02:00
{{ end -}}`
2020-09-29 22:42:27 +02:00
const page_gmi = `# {{ .Title }}
{{ .Content }}`
var (
atomTmpl = template.Must(template.New("atom.xml").Parse(atom_xml))
indexTmpl = template.Must(template.New("index.gmi").Parse(index_gmi))
pageTmpl = template.Must(template.New("page.gmi").Parse(page_gmi))
)