Skip to content

Commit

Permalink
Remake directory structure, with _posts, _site, and _templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ifo committed Aug 4, 2015
1 parent 034f3dc commit be94d04
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
goall/**/site
**/_site
goall/goall
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions goall/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import (

func main() {
// ensure example/site directory exists
err := os.MkdirAll("./site/posts", 0755)
err := os.MkdirAll("./_site/posts", 0755)
if err != nil {
log.Printf("Warn: %v\n", err)
}

errIndex := CreateIndexPage(".", "./posts")
errIndex := CreateIndexPage(".", "./_posts")
if errIndex != nil {
log.Fatalln("Could not assemble index page", errIndex)
}

CreatePosts("./posts", "./site/posts")
CreatePosts("./_posts", "./_site/posts")
}

func CreateIndexPage(rootDir, postsDir string) error {
Expand All @@ -29,7 +29,7 @@ func CreateIndexPage(rootDir, postsDir string) error {
return err
}

goall.OverwriteFile("site/index.html", index)
goall.OverwriteFile("_site/index.html", index)
return nil
}

Expand All @@ -38,7 +38,7 @@ func CreatePosts(postsDir, siteDir string) {

for _, p := range posts {
prefix := p[:len(p)-len(path.Ext(p))]
b, err := goall.ParseMarkdown(postsDir + p)
b, err := goall.ParseMarkdown(postsDir + "/" + p)
if err != nil {
log.Println(err)
continue
Expand All @@ -48,6 +48,6 @@ func CreatePosts(postsDir, siteDir string) {
log.Println(err)
continue
}
goall.WriteFile(siteDir+prefix+".html", post)
goall.WriteFile(siteDir+"/"+prefix+".html", post)
}
}
2 changes: 1 addition & 1 deletion templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func AssembleIndex(index Index) ([]byte, error) {
}

func AssemblePost(post []byte) ([]byte, error) {
page, err := template.ParseFiles("post.html")
page, err := template.ParseFiles("_templates/post.html")
if err != nil {
log.Fatalln("template.ParseFiles", err)
}
Expand Down

0 comments on commit be94d04

Please sign in to comment.