36 lines
806 B
Go
36 lines
806 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
func writeFrontMatter(entry *Entry) string {
|
||
|
var buff bytes.Buffer
|
||
|
t := time.Now().Format(time.RFC3339)
|
||
|
buff.WriteString("---\n")
|
||
|
if len(entry.Name) > 0 {
|
||
|
buff.WriteString("title: \"" + entry.Name + "\"\n")
|
||
|
}
|
||
|
buff.WriteString("date: " + t + "\n")
|
||
|
buff.WriteString("tags:\n")
|
||
|
for _, tag := range entry.Categories {
|
||
|
buff.WriteString("- " + tag + "\n")
|
||
|
}
|
||
|
buff.WriteString("indieweb:\n")
|
||
|
if len(entry.InReplyTo) > 0 {
|
||
|
buff.WriteString(" reply:\n link: " + entry.InReplyTo + "\n")
|
||
|
}
|
||
|
buff.WriteString("---\n")
|
||
|
return buff.String()
|
||
|
}
|
||
|
|
||
|
func WriteHugoPost(entry *Entry) string {
|
||
|
var buff bytes.Buffer
|
||
|
buff.WriteString(writeFrontMatter(entry))
|
||
|
if len(entry.Content) > 0 {
|
||
|
buff.WriteString(entry.Content + "\n")
|
||
|
}
|
||
|
return buff.String()
|
||
|
}
|