summaryrefslogtreecommitdiff
path: root/src/cmd/export/posts.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/export/posts.go')
-rw-r--r--src/cmd/export/posts.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/cmd/export/posts.go b/src/cmd/export/posts.go
index f54fc2c..569ff6b 100644
--- a/src/cmd/export/posts.go
+++ b/src/cmd/export/posts.go
@@ -31,7 +31,7 @@ func postTargetFormat(p post.StoredPost) post.Format {
return post.FormatGemtext
}
-func writePostBody(post post.StoredPost, path, body string) error {
+func writePostBody(p post.StoredPost, path, body string) error {
f, err := os.Create(path)
if err != nil {
return fmt.Errorf("opening file: %w", err)
@@ -45,11 +45,18 @@ func writePostBody(post post.StoredPost, path, body string) error {
_, err = f.WriteString(str)
}
- writeString(fmt.Sprintf("# %s\n\n", post.Title))
- if post.Description != "" {
- writeString(fmt.Sprintf("> %s\n\n", post.Description))
+ if f := postTargetFormat(p); f == post.FormatGemtext {
+ writeString("=> ../posts/ Back to All Posts\n\n")
+ } else if f == post.FormatMarkdown {
+ writeString(fmt.Sprintf("---\nTitle: %q\n---\n", p.Title))
+ writeString("[Back to All Posts](../posts/)\n\n")
+ }
+ writeString(fmt.Sprintf("# %s\n\n", p.Title))
+ if p.Description != "" {
+ writeString(fmt.Sprintf("> %s\n\n", p.Description))
}
writeString(body)
+ writeString(fmt.Sprintf("\n-----\n\nPublished %s\n", p.PublishedAt.Format("2006-01-02")))
return err
}