Add new 'atroot' meta directive
Anirudh Oppiliappan x@icyphox.sh
Sun, 19 Jan 2025 15:15:15 +0200
3 files changed,
16 insertions(+),
0 deletions(-)
M
commands/build.go
→
commands/build.go
@@ -178,6 +178,14 @@ isDraft := post.Meta["draft"] == "true"
if !isDraft || (isDraft && drafts) { posts = append(posts, post) } + + // Copy the post to the root if it's marked as such. + // ex: build/blog/foo-bar -> build/foo-bar + if post.Meta["atroot"] == "true" { + os.Mkdir(filepath.Join(types.BuildDir, slug), 0755) + dstFile := filepath.Join(types.BuildDir, slug, "index.html") + util.CopyFile(filepath.Join(dstDir, slug, "index.html"), dstFile) + } } sort.Slice(posts, func(i, j int) bool {
M
commands/new.go
→
commands/new.go
@@ -14,6 +14,7 @@ _, file := filepath.Split(path)
url := strings.TrimSuffix(file, filepath.Ext(file)) content := fmt.Sprintf(`--- +atroot: true template: slug: %s title:
M
readme
→
readme
@@ -52,6 +52,13 @@
go run contrib/style.go > syntax.css +SPECIAL META DIRECTIVES + +• draft: sets a post to draft (boolean) and will only be rendered if + the build command is run with the --drafts flag. +• atroot: sets a post to be also rendered at the root of the site. + + TEMPLATING Non-index templates have access to the below objects: