1
0
Fork 0
mirror of https://git.sr.ht/~adnano/kiln synced 2024-05-14 08:16:04 +02:00
kiln/templates.go
2020-09-30 00:27:59 -04:00

42 lines
1.1 KiB
Go

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>
<link href="{{ .URL }}"/>
<link rel="self" href="{{ .URL }}{{ .Path }}"/>
<updated>{{ .Updated.Format "2006-01-02T15:04:05Z07:00" }}</updated>
<id>{{ .URL }}{{ .Path }}</id>
{{- $url := .URL -}}
{{- range .Entries }}
<entry>
<title>{{ .Title }}</title>
<link href="{{ $url }}{{ .Permalink }}"/>
<id>{{ $url }}{{ .Permalink }}</id>
<updated>{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}</updated>
<content src="{{ $url }}{{ .Permalink }}" type="text/gemini"></content>
</entry>
{{ end -}}
</feed>`
const index_gmi = `# Index of {{ .Permalink }}
{{ range .Dirs }}=> {{ .Permalink }}
{{ end -}}
{{ range .Pages }}=> {{ .Permalink }}
{{ end -}}`
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))
)