2019-11-07 10:00:24 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func writeFrontMatter(entry *Entry) string {
|
|
|
|
var buff bytes.Buffer
|
|
|
|
t := time.Now().Format(time.RFC3339)
|
|
|
|
buff.WriteString("---\n")
|
2019-11-08 18:46:07 +00:00
|
|
|
if len(entry.title) > 0 {
|
|
|
|
buff.WriteString("title: \"" + entry.title + "\"\n")
|
2019-11-07 10:00:24 +00:00
|
|
|
}
|
|
|
|
buff.WriteString("date: " + t + "\n")
|
|
|
|
buff.WriteString("tags:\n")
|
2019-11-08 18:46:07 +00:00
|
|
|
for _, tag := range entry.tags {
|
2019-11-07 10:00:24 +00:00
|
|
|
buff.WriteString("- " + tag + "\n")
|
|
|
|
}
|
2019-11-08 18:46:07 +00:00
|
|
|
if len(entry.link) > 0 {
|
|
|
|
buff.WriteString("externalURL: " + entry.link + "\n")
|
|
|
|
}
|
2019-11-07 10:00:24 +00:00
|
|
|
buff.WriteString("indieweb:\n")
|
2019-11-08 18:46:07 +00:00
|
|
|
if len(entry.replyLink) > 0 {
|
|
|
|
buff.WriteString(" reply:\n link: " + entry.replyLink + "\n")
|
|
|
|
if len(entry.replyTitle) > 0 {
|
|
|
|
buff.WriteString(" title: " + entry.replyTitle + "\n")
|
|
|
|
}
|
2019-11-07 10:00:24 +00:00
|
|
|
}
|
|
|
|
buff.WriteString("---\n")
|
|
|
|
return buff.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
func WriteHugoPost(entry *Entry) string {
|
|
|
|
var buff bytes.Buffer
|
|
|
|
buff.WriteString(writeFrontMatter(entry))
|
2019-11-08 18:46:07 +00:00
|
|
|
if len(entry.content) > 0 {
|
|
|
|
buff.WriteString(entry.content)
|
2019-11-07 10:00:24 +00:00
|
|
|
}
|
|
|
|
return buff.String()
|
|
|
|
}
|