all repos — vite @ b292ea74a0c25e24be5237225659600fc294df6b

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

Update readme with YAML templating
Anirudh Oppiliappan x@icyphox.sh
Mon, 27 May 2024 22:12:17 +0300
commit

b292ea74a0c25e24be5237225659600fc294df6b

parent

8ff1bc0d8db4dff6ca2070334c8be25316c90f3a

2 files changed, 27 insertions(+), 1 deletions(-)

jump to
M go.modgo.mod

@@ -6,11 +6,11 @@ require (

git.icyphox.sh/grayfriday v0.0.0-20221126034429-23c704183914 github.com/adrg/frontmatter v0.2.0 github.com/alecthomas/chroma v0.10.0 - gopkg.in/yaml.v2 v2.3.0 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b ) require ( github.com/BurntSushi/toml v0.3.1 // indirect github.com/dlclark/regexp2 v1.4.0 // indirect + gopkg.in/yaml.v2 v2.3.0 // indirect )
M readmereadme

@@ -78,6 +78,32 @@ This deserves mention because Go templates don't recurse into

subdirectories by default (template.ParseGlob uses filepath.Glob, and doesn't support deep-matching, i.e. **). +vite also supports templating generic YAML files. Take for instance, +pages/reading.yaml (https://git.icyphox.sh/site/blob/master/pages/reading.yaml): + + meta: + template: reading.html + title: reading + subtitle: Tracking my reading. + description: I use this page to track my reading. + + books: + - 2024: + - name: Dune Messiah + link: https://en.wikipedia.org/wiki/Dune_Messiah + author: Frank Herbert + status: now reading + - 2023: + - name: Dune + link: https://en.wikipedia.org/wiki/Dune_(novel) + author: Frank Herbert + status: finished + +vite will look for a 'meta' key in the YAML file, and use the 'template' +specified to render the page. The rest of the YAML file is available to +you in the template as a map[string]interface{} called Yaml. + + More templating examples can be found at: https://git.icyphox.sh/site/tree/templates