diff --git a/blognow.go b/blognow.go index 6a1f77e..3a7697d 100644 --- a/blognow.go +++ b/blognow.go @@ -19,13 +19,11 @@ import ( "gitlab.com/golang-commonmark/markdown" ) -const sampleConfig string = ` -baseURL = "https://example.org/" +const sampleConfig string = `baseURL = "https://example.org/" title = "My Blog" tagline = "Don't sail too close to the wind" ` -const samplePost string = ` ---- +const samplePost string = `--- title = "My First Post" date = 2019-05-05 --- @@ -73,6 +71,14 @@ func makeBlogDir(path string) { fmt.Println("Created a new blog: " + path) createFile(path+"/config.toml", sampleConfig) createFile(postsPath+"/sample.md", samplePost) + + // Template files + templatesPath := filepath.Join(path, "templates") + os.MkdirAll(templatesPath, os.ModePerm) + createFile(filepath.Join(templatesPath, "base.html"), baseTmpl) + createFile(filepath.Join(templatesPath, "header.html"), headerTmpl) + createFile(filepath.Join(templatesPath, "post.html"), postTmpl) + createFile(filepath.Join(templatesPath, "archive.html"), archiveTmpl) } // build collects all the necessary information from configuration files diff --git a/templates.go b/templates.go new file mode 100644 index 0000000..e67bb6f --- /dev/null +++ b/templates.go @@ -0,0 +1,48 @@ +package main + +const baseTmpl string = `{{define "base"}} + + +
+ + +{{.Blog.Tagline}}
+{{end}} +` + +const postTmpl string = `{{define "title"}} + {{.Post.Title}} - {{.Blog.Title}} +{{end}} + +{{define "body"}} +Posted: {{.Post.Date | formatDate}}
+ See all posts » +{{end}} +` + +const archiveTmpl string = `{{define "title"}} +All Posts - {{.Blog.Title}} +{{end}} + +{{define "body"}} +{{.Blog.Tagline}}
-{{end}} diff --git a/templates/post.html b/templates/post.html deleted file mode 100644 index 9a09557..0000000 --- a/templates/post.html +++ /dev/null @@ -1,10 +0,0 @@ -{{define "title"}} - {{.Post.Title}} - {{.Blog.Title}} -{{end}} - -{{define "body"}} -Posted: {{.Post.Date | formatDate}}
- See all posts » -{{end}}