made pages use a template too
This commit is contained in:
parent
0f0ab8a26d
commit
05c203607d
19
main.go
19
main.go
|
@ -64,12 +64,6 @@ func RemoveIndexFeed(s []*feeds.Item, index int) []*feeds.Item {
|
|||
return append(s[:index], s[index+1:]...)
|
||||
}
|
||||
}
|
||||
// wraps the string in a basic standalone HTML document.
|
||||
func htmlWrap(d *string) string {
|
||||
header := `<!DOCTYPE html><head><link rel=stylesheet href="https://itwont.work/style.css"><title>Nico's site</title></head><body><article>`
|
||||
footer := `</article></body>`
|
||||
return header + *d + footer
|
||||
}
|
||||
|
||||
// publishedAfter returns true if a was updated after b.
|
||||
func publishedAfter(a, b *feeds.Item) bool {
|
||||
|
@ -225,9 +219,9 @@ func processPage(f filePathInfo) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
output := filepath.Join(geminiOutputDir, rel)
|
||||
|
||||
err = ioutil.WriteFile(output, []byte(geminiRender), 0644)
|
||||
output, err := os.Create(filepath.Join(geminiOutputDir, rel))
|
||||
defer output.Close()
|
||||
err = templates.ExecuteTemplate(output, "page.gmi", geminiRender)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -235,8 +229,11 @@ func processPage(f filePathInfo) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
output = strings.Replace(filepath.Join(htmlOutputDir, rel), ".gmi", ".html", -1)
|
||||
err = ioutil.WriteFile(output, []byte(htmlWrap(&htmlRender)), 0644)
|
||||
output, err = os.Create(strings.Replace(filepath.Join(htmlOutputDir, rel), ".gmi", ".html", -1))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = templates.ExecuteTemplate(output, "page.html", htmlRender)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Reference in New Issue
Block a user