all repos — vite @ 96a6bc1beff5862b46f9a7157dd53b8a64e11fff

a fast (this time, actually) and minimal static site generator

Add new 'atroot' meta directive
Anirudh Oppiliappan x@icyphox.sh
Sun, 19 Jan 2025 15:15:15 +0200
commit

96a6bc1beff5862b46f9a7157dd53b8a64e11fff

parent

f18dcbc513dfef8f521ecf3c4bd7ea02ee124aa1

3 files changed, 16 insertions(+), 0 deletions(-)

jump to
M commands/build.gocommands/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.gocommands/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 readmereadme

@@ -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: