Project Layout
Tempblot treats your input directory as a source tree. Static files are copied as-is, and .blot files are compiled into output files by removing the .blot extension.
Static Layouts
Use .blot when a file needs TypeScript-powered templating. Leave everything else as a normal static file.
Directorytemplates
- package.json.blot becomes
package.json - README.md.blot becomes
README.md Directorypublic
- favicon.svg copied as-is
- robots.txt copied as-is
- package.json.blot becomes
Given that input tree, generating into dist produces this output shape:
Directorydist
- package.json
- README.md
Directorypublic
- favicon.svg
- robots.txt
Each regular .blot file should include one <output> block. Add <setup> only when the template needs imports, params, helper functions, or computed values.
<setup>const name = "tempblot";</setup>
<output lang="json">{ "name": <<JSON.stringify(name)>>}</output>Dynamic File Names
Put bracketed params in a .blot file name to generate one output file for each path entry. The same file provides both the getPaths() function and the output template.
Directorytemplates
Directoryposts
[slug].json.blotgenerates one file per slug
<setup>export function getPaths() { return [{ slug: "hello-world" }, { slug: "release-notes" }];}</setup>
<output lang="json">{ "slug": <<JSON.stringify(slug)>>}</output>The generated output keeps the surrounding directory structure and replaces [slug] with each returned value.
Directorydist
Directoryposts
- hello-world.json
- release-notes.json
Dynamic Directories
Put bracketed params in a directory name when a whole folder should be generated more than once. Add a _paths.blot file inside that directory to describe the path entries for the directory.
Directorytemplates
Directorydocs
Directory
[section]_paths.blotprovides section params- index.md.blot
- sidebar.json.blot
Path files are the exception to the regular .blot shape: _paths.blot should contain exactly one <setup> block and no <output> block.
<setup>export function getPaths() { return [{ section: "guides" }, { section: "reference" }];}</setup>Every file inside [section] is generated once for each returned path entry.
Directorydist
Directorydocs
Directoryguides
- index.md
- sidebar.json
Directoryreference
- index.md
- sidebar.json
Rules Of Thumb
- Regular
.blotfiles require one<output>block. - Regular
.blotfiles may include one<setup>block. _paths.blotfiles require one<setup>block._paths.blotfiles must not include an<output>block.- Static files do not need
.blot; they are copied directly.