2021-09-18 02:32:14 +03:00
# zs
2015-04-10 15:11:37 +03:00
2014-12-06 00:49:42 +03:00
zs is an extremely minimal static site generator written in Go.
It's inspired by `zas` generator, but is even more minimal.
The name stands for 'zen static' as well as it's my initials.
## Features
* Zero configuration (no configuration file needed)
* Cross-platform
* Highly extensible
2015-09-03 00:21:50 +03:00
* Works well for blogs and generic static websites (landing pages etc)
2014-12-06 00:49:42 +03:00
* Easy to learn
* Fast
## Installation
Download the binaries from Github or build it manually:
2021-09-18 02:32:14 +03:00
$ go get git.mills.io/prologic/zs
2014-12-06 00:49:42 +03:00
## Ideology
2021-09-18 02:32:14 +03:00
Keep your texts in markdown, or HTML format right in the main directory
2015-09-03 00:21:50 +03:00
of your blog/site.
2014-12-06 00:49:42 +03:00
Keep all service files (extensions, layout pages, deployment scripts etc)
in the `.zs` subdirectory.
2015-09-03 00:21:50 +03:00
Define variables in the header of the content files using [YAML]:
2014-12-06 00:49:42 +03:00
title: My web site
keywords: best website, hello, world
2015-09-03 00:21:50 +03:00
---
2014-12-06 00:49:42 +03:00
2015-09-03 00:21:50 +03:00
Markdown text goes after a header *separator*
2014-12-06 00:49:42 +03:00
Use placeholders for variables and plugins in your markdown or html
2015-09-03 00:21:50 +03:00
files, e.g. `{{ title }}` or `{{ command arg1 arg2 }}.
2014-12-06 00:49:42 +03:00
Write extensions in any language you like and put them into the `.zs`
subdiretory.
Everything the extensions prints to stdout becomes the value of the
placeholder.
2015-09-03 00:21:50 +03:00
Every variable from the content header will be passed via environment variables like `title` becomes `$ZS_TITLE` and so on. There are some special variables:
2014-12-06 00:49:42 +03:00
* `$ZS` - a path to the `zs` executable
* `$ZS_OUTDIR` - a path to the directory with generated files
* `$ZS_FILE` - a path to the currently processed markdown file
* `$ZS_URL` - a URL for the currently generated page
## Example of RSS generation
2015-09-03 00:21:50 +03:00
Extensions can be written in any language you know (Bash, Python, Lua, JavaScript, Go, even Assembler). Here's an example of how to scan all markdown blog posts and create RSS items:
``` bash
for f in ./blog/*.md ; do
d=$($ZS var $f date)
if [ ! -z $d ] ; then
timestamp=`date --date "$d" +%s`
url=`$ZS var $f url`
title=`$ZS var $f title | tr A-Z a-z`
descr=`$ZS var $f description`
echo $timestamp \
"< item > " \
"< title > $title< / title > " \
"< link > http://zserge.com/$url< / link > " \
"< description > $descr< / description > " \
"< pubDate > $(date --date @$timestamp -R)< / pubDate > " \
"< guid > http://zserge.com/$url< / guid > " \
"< / item > "
fi
done | sort -r -n | cut -d' ' -f2-
```
2014-12-06 00:49:42 +03:00
## Hooks
There are two special plugin names that are executed every time the build
2015-09-03 00:21:50 +03:00
happens - `prehook` and `posthook` . You can define some global actions here like
content generation, or additional commands, like LESS to CSS conversion:
2014-12-06 00:49:42 +03:00
# .zs/post
#!/bin/sh
lessc < $ZS_OUTDIR/styles.less > $ZS_OUTDIR/styles.css
rm -f $ZS_OUTDIR/styles.css
## Command line usage
`zs build` re-builds your site.
2015-09-03 00:21:50 +03:00
`zs build <file>` re-builds one file and prints resulting content to stdout.
2014-12-06 00:49:42 +03:00
`zs watch` rebuilds your site every time you modify any file.
`zs var <filename> [var1 var2...]` prints a list of variables defined in the
header of a given markdown file, or the values of certain variables (even if
it's an empty string).
## License
The software is distributed under the MIT license.