kiln/templates.go

42 lines
1.1 KiB
Go
Raw Normal View History

2020-09-29 20:42:27 +00: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>
<link href="{{ .SiteURL }}"/>
<link rel="self" href="{{ .SiteURL }}{{ .Path }}"/>
<updated>{{ .Updated }}</updated>
<id>{{ .SiteURL }}{{ .Path }}</id>
{{ $siteURL := .SiteURL }}
{{ range .Entries }}
<entry>
<title>{{ .Title }}</title>
<link href="{{ $siteURL }}{{ .Permalink }}"/>
<id>{{ $siteURL }}{{ .Permalink }}</id>
<updated>{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}</updated>
<content src="{{ $siteURL }}{{ .Permalink }}" type="text/gemini"></content>
</entry>
{{ end }}
</feed>`
const index_gmi = `# Index of {{ .Permalink }}
{{ range .Directories }}=> {{ .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))
)