all repos — vite @ 71bec3e96b175b5960f518aefae0faae433af030

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

readme (view raw)

  1vite
  2----
  3
  4A fast (this time, actually) and minimal static site generator.
  5
  6INSTALLING
  7
  8    go install 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:"default-template"`
 33        Author          struct {
 34            Name  string `yaml:"name"`
 35            Email string `yaml:"email"`
 36        } `yaml:"author"`
 37        URL string `yaml:"url"`
 38    }
 39
 40Example config: https://git.icyphox.sh/site/tree/config.yaml
 41
 42
 43SYNTAX HIGHLIGHTING
 44
 45vite uses chroma (https://github.com/alecthomas/chroma) for syntax
 46highlighting. Note that CSS is not provided, and will have to be
 47included by the user in the templates. A sample style can be generated
 48by running:
 49
 50    go run contrib/style.go > syntax.css
 51
 52
 53TEMPLATING
 54
 55Non-index templates have access to the below objects:
 56• Cfg: object of ConfigYaml
 57• Meta: map[string]string of the page's frontmatter metadata
 58• Body: Contains the HTML
 59
 60Index templates have access to everything above, and a Posts object,
 61which is a slice containing HTML and Meta. This is useful for iterating
 62through to generate an index page.
 63Example: https://git.icyphox.sh/site/tree/templates/index.html
 64
 65Templates are written as standard Go templates (ref:
 66https://godocs.io/text/template), and can be loaded recursively.
 67Consider the below template structure:
 68
 69    templates/
 70    |-- blog.html
 71    |-- index.html
 72    |-- project/
 73        |-- index.html
 74        `-- project.html
 75
 76The templates under project/ are referenced as project/index.html.
 77This deserves mention because Go templates don't recurse into
 78subdirectories by default (template.ParseGlob uses filepath.Glob, and
 79doesn't support deep-matching, i.e. **).
 80
 81More templating examples can be found at:
 82https://git.icyphox.sh/site/tree/templates
 83
 84
 85FEEDS
 86
 87Atom feeds are generated for all directories under pages/. So
 88pages/foo will have a Atom feed at build/foo/feed.xml.
 89
 90
 91FILE TREE
 92
 93    .
 94    |-- build/
 95    |-- config.yaml
 96    |-- pages/
 97    |-- static/
 98    |-- templates/
 99
100The entire static/ directory gets copied over to build/, and can be
101used to reference static assets -- css, images, etc. pages/ supports
102only nesting one directory deep; for example: pages/blog/*.md will
103render, but pages/blog/foo/*.md will not.