aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/blogspace/seed.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/cmd/blogspace/seed.go b/cmd/blogspace/seed.go
index 14c378f..44171a3 100644
--- a/cmd/blogspace/seed.go
+++ b/cmd/blogspace/seed.go
@@ -124,14 +124,21 @@ func seed(ctx context.Context, cfg *config.Config, st *store.Store) error {
posts := []struct {
page, title, body string
tags []string
+ html bool // written in HTML mode: stored as is
}{
- {"home", "Welcome to my corner of the web", "This is the **first post**. It lives on the home page.\n\nThings I plan to write about:\n\n- tomatoes\n- Go\n- the occasional recipe\n\n![gradient](/media/" + bg.ID.String() + ")\n\nThat image above was uploaded through the dashboard, and here is a file to download: [notes.txt](/media/" + notes.ID.String() + ").", []string{"Go", "tomatoes", "meta"}},
- {"home", "Why I still like plain HTML", "No frameworks, no build step. Just `<p>` tags and a stylesheet.\n\n> Simplicity is prerequisite for reliability. — Dijkstra\n\n```go\nfunc main() {\n\tfmt.Println(\"hello\")\n}\n```", []string{"Go", "web"}},
- {"news", "Site is up", "The blog is live. Expect sporadic updates.", []string{"meta"}},
- {"news", "Tomato season", "First ripe tomato of the year! Table for the record:\n\n| Variety | Days |\n|---|---|\n| Cherry | 62 |\n| Beefsteak | 85 |", []string{"tomatoes", "garden", "Συνταγές"}},
+ {"home", "Welcome to my corner of the web", "This is the **first post**. It lives on the home page.\n\nThings I plan to write about:\n\n- tomatoes\n- Go\n- the occasional recipe\n\n![gradient](/media/" + bg.ID.String() + ")\n\nThat image above was uploaded through the dashboard, and here is a file to download: [notes.txt](/media/" + notes.ID.String() + ").", []string{"Go", "tomatoes", "meta"}, false},
+ {"home", "Why I still like plain HTML", "No frameworks, no build step. Just `<p>` tags and a stylesheet.\n\n> Simplicity is prerequisite for reliability. — Dijkstra\n\n```go\nfunc main() {\n\tfmt.Println(\"hello\")\n}\n```", []string{"Go", "web"}, false},
+ {"news", "Site is up", "The blog is live. Expect sporadic updates.", []string{"meta"}, false},
+ {"news", "Tomato season", "First ripe tomato of the year! Table for the record:\n\n| Variety | Days |\n|---|---|\n| Cherry | 62 |\n| Beefsteak | 85 |", []string{"tomatoes", "garden", "Συνταγές"}, false},
+ {"home", "A post written in HTML", "<p>This one is <em>raw HTML</em>, not Markdown: the editor's Format switch.</p>\n<style>.seed-box { padding: .6em 1em; border: 2px dashed #c33; }</style>\n<div class=\"seed-box\">Any markup goes — this box has its own inline stylesheet.</div>\n<details><summary>And a folding section</summary><p>Which Markdown alone cannot make.</p></details>", []string{"web", "meta"}, true},
}
for _, p := range posts {
- post := &store.Post{PageID: pages[p.page].ID, Title: p.title, Slug: slug.Make(p.title), BodyMD: p.body, BodyHTML: markdown.Render(p.body), Published: true}
+ post := &store.Post{PageID: pages[p.page].ID, Title: p.title, Slug: slug.Make(p.title), BodyMD: p.body, Published: true}
+ if p.html {
+ post.Format, post.BodyHTML = store.FormatHTML, p.body
+ } else {
+ post.Format, post.BodyHTML = store.FormatMarkdown, markdown.Render(p.body)
+ }
created, err := bs.CreatePost(ctx, post)
if err != nil {
return err