fast and minimal static site generator
ssg

Add new 'atroot' meta directive

anirudh.fi 96a6bc1b f18dcbc5

verified
Changed files
+16
commands
+8
commands/build.go
··· 178 178 if !isDraft || (isDraft && drafts) { 179 179 posts = append(posts, post) 180 180 } 181 + 182 + // Copy the post to the root if it's marked as such. 183 + // ex: build/blog/foo-bar -> build/foo-bar 184 + if post.Meta["atroot"] == "true" { 185 + os.Mkdir(filepath.Join(types.BuildDir, slug), 0755) 186 + dstFile := filepath.Join(types.BuildDir, slug, "index.html") 187 + util.CopyFile(filepath.Join(dstDir, slug, "index.html"), dstFile) 188 + } 181 189 } 182 190 183 191 sort.Slice(posts, func(i, j int) bool {
+1
commands/new.go
··· 14 14 url := strings.TrimSuffix(file, filepath.Ext(file)) 15 15 16 16 content := fmt.Sprintf(`--- 17 + atroot: true 17 18 template: 18 19 slug: %s 19 20 title:
+7
readme
··· 52 52 go run contrib/style.go > syntax.css 53 53 54 54 55 + SPECIAL META DIRECTIVES 56 + 57 + • draft: sets a post to draft (boolean) and will only be rendered if 58 + the build command is run with the --drafts flag. 59 + • atroot: sets a post to be also rendered at the root of the site. 60 + 61 + 55 62 TEMPLATING 56 63 57 64 Non-index templates have access to the below objects: