6. Styles
CopyFrom copies a directory into the build as-is — the escape hatch for anything that isn't a page. Add style/style.css, tell the layout about it, and put it in the tree:
templ
<link rel="stylesheet" href={ prefix + "/style/style.css" }/>go
Children: map[string]ssg.Node{
"about": {Title: "About", Page: ssg.Templ(pages.About)},
"projects": projects(),
"style": {CopyFrom: "style"},
},Try it. Change a colour in style/style.css and rebuild.
What you should see
build/style/style.css updates and nothing else changes. CopyFrom copies as-is: what's in the source directory is what's in the build.
What does CopyFrom do?
CopyFrom is the escape hatch for anything that isn't a page — it copies a directory's contents into the output verbatim.
Where does the style node live?
"style": {CopyFrom: "style"} is a node in the tree — CopyFrom copies the directory into the build as-is.