all repos — vite @ master

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

readme (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
vite
----

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

INSTALLING

    go install git.icyphox.sh/vite@latest


USAGE

    usage: vite [options]

    A simple and minimal static site generator.

    options:
        init PATH                   create vite project at PATH
        build                       builds the current project
        new PATH                    create a new markdown post
        serve [HOST:PORT]           serves the 'build' directory


CONFIG

The configuration is unmarshalled from a config.yaml file, into the
below struct:

    type ConfigYaml struct {
        Title           string `yaml:"title"`
        Desc            string `yaml:"description"`
        DefaultTemplate string `yaml:"default-template"`
        Author          struct {
            Name  string `yaml:"name"`
            Email string `yaml:"email"`
        } `yaml:"author"`
        URL string `yaml:"url"`
    }

Example config: https://git.icyphox.sh/site/tree/config.yaml


SYNTAX HIGHLIGHTING

vite uses chroma (https://github.com/alecthomas/chroma) for syntax
highlighting. Note that CSS is not provided, and will have to be
included by the user in the templates. A sample style can be generated
by running:

    go run contrib/style.go > syntax.css


TEMPLATING

Non-index templates have access to the below objects:
• Cfg: object of ConfigYaml
• Meta: map[string]string of the page's frontmatter metadata
• Body: Contains the HTML

Index templates have access to everything above, and a Posts object,
which is a slice containing HTML and Meta. This is useful for iterating
through to generate an index page.
Example: https://git.icyphox.sh/site/tree/templates/index.html

Templates are written as standard Go templates (ref:
https://godocs.io/text/template), and can be loaded recursively.
Consider the below template structure:

    templates/
    |-- blog.html
    |-- index.html
    |-- project/
        |-- index.html
        `-- project.html

The templates under project/ are referenced as project/index.html.
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


FEEDS

Atom feeds are generated for all directories under pages/. So
pages/foo will have a Atom feed at build/foo/feed.xml.


FILE TREE

    .
    |-- build/
    |-- config.yaml
    |-- pages/
    |-- static/
    |-- templates/

The entire static/ directory gets copied over to build/, and can be
used to reference static assets -- css, images, etc. pages/ supports
only nesting one directory deep; for example: pages/blog/*.md will
render, but pages/blog/foo/*.md will not.