readme (view raw)
1vite
2----
3
4A fast (this time, actually) and minimal static site generator.
5
6INSTALLING
7
8 go install git.icyphox.sh/vite@latest
9
10
11USAGE
12
13 usage: vite [options]
14
15 A simple and minimal static site generator.
16
17 options:
18 init PATH create vite project at PATH
19 build builds the current project
20 new PATH create a new markdown post
21 serve [HOST:PORT] serves the 'build' directory
22
23
24CONFIG
25
26The configuration is unmarshalled from a config.yaml file, into the
27below struct:
28
29 type ConfigYaml struct {
30 Title string `yaml:"title"`
31 Desc string `yaml:"description"`
32 DefaultTemplate string `yaml:"-"`
33 Author struct {
34 Name string `yaml:"name"`
35 Email string `yaml:"email"`
36 } `yaml:"author"`
37 URL string `yaml:"url"`
38 PreBuild []string `yaml:"preBuild"`
39 PostBuild []string `yaml:"postBuild"`
40 }
41
42Example config: https://git.icyphox.sh/site/tree/config.yaml
43
44
45SYNTAX HIGHLIGHTING
46
47vite uses chroma (https://github.com/alecthomas/chroma) for syntax
48highlighting. Note that CSS is not provided, and will have to be
49included by the user in the templates. A sample style can be generated
50by running:
51
52 go run contrib/style.go > syntax.css
53
54
55TEMPLATING
56
57Non-index templates have access to the below objects:
58• Cfg: object of ConfigYaml
59• Meta: map[string]string of the page's frontmatter metadata
60• Body: Contains the HTML
61
62Index templates have access to everything above, and a Posts object,
63which is a slice containing HTML and Meta. This is useful for iterating
64through to generate an index page.
65Example: https://git.icyphox.sh/site/tree/templates/index.html
66
67Templates are written as standard Go templates (ref:
68https://godocs.io/text/template), and can be loaded recursively.
69Consider the below template structure:
70
71 templates/
72 |-- blog.html
73 |-- index.html
74 |-- project/
75 |-- index.html
76 `-- project.html
77
78The templates under project/ are referenced as project/index.html.
79This deserves mention because Go templates don't recurse into
80subdirectories by default (template.ParseGlob uses filepath.Glob, and
81doesn't support deep-matching, i.e. **).
82
83vite also supports templating generic YAML files. Take for instance,
84pages/reading.yaml (https://git.icyphox.sh/site/blob/master/pages/reading.yaml):
85
86 meta:
87 template: reading.html
88 title: reading
89 subtitle: Tracking my reading.
90 description: I use this page to track my reading.
91
92 books:
93 - 2024:
94 - name: Dune Messiah
95 link: https://en.wikipedia.org/wiki/Dune_Messiah
96 author: Frank Herbert
97 status: now reading
98 - 2023:
99 - name: Dune
100 link: https://en.wikipedia.org/wiki/Dune_(novel)
101 author: Frank Herbert
102 status: finished
103
104vite will look for a 'meta' key in the YAML file, and use the 'template'
105specified to render the page. The rest of the YAML file is available to
106you in the template as a map[string]interface{} called Yaml.
107
108
109More templating examples can be found at:
110https://git.icyphox.sh/site/tree/templates
111
112
113FEEDS
114
115Atom feeds are generated for all directories under pages/. So
116pages/foo will have a Atom feed at build/foo/feed.xml.
117
118
119FILE TREE
120
121 .
122 |-- build/
123 |-- config.yaml
124 |-- pages/
125 |-- static/
126 |-- templates/
127
128The entire static/ directory gets copied over to build/, and can be
129used to reference static assets -- css, images, etc. pages/ supports
130only nesting one directory deep; for example: pages/blog/*.md will
131render, but pages/blog/foo/*.md will not.