mirror of
https://git.mills.io/prologic/zs
synced 2024-11-25 06:46:11 +03:00
updated README
This commit is contained in:
parent
c866143950
commit
76175692a6
53
README.md
53
README.md
@ -14,6 +14,7 @@ The name stands for 'zen static' as well as it's my initials.
|
|||||||
* Zero configuration (no configuration file needed)
|
* Zero configuration (no configuration file needed)
|
||||||
* Cross-platform
|
* Cross-platform
|
||||||
* Highly extensible
|
* Highly extensible
|
||||||
|
* Works well for blogs and generic static websites (landing pages etc)
|
||||||
* Easy to learn
|
* Easy to learn
|
||||||
* Fast
|
* Fast
|
||||||
|
|
||||||
@ -25,20 +26,22 @@ Download the binaries from Github or build it manually:
|
|||||||
|
|
||||||
## Ideology
|
## Ideology
|
||||||
|
|
||||||
Keep your texts in markdown format in the root directory of your blog/site.
|
Keep your texts in markdown, [amber] or HTML format right in the main directory
|
||||||
|
of your blog/site.
|
||||||
|
|
||||||
Keep all service files (extensions, layout pages, deployment scripts etc)
|
Keep all service files (extensions, layout pages, deployment scripts etc)
|
||||||
in the `.zs` subdirectory.
|
in the `.zs` subdirectory.
|
||||||
|
|
||||||
Define variables in the header of the markdown files:
|
Define variables in the header of the content files using [YAML]:
|
||||||
|
|
||||||
title: My web site
|
title: My web site
|
||||||
keywords: best website, hello, world
|
keywords: best website, hello, world
|
||||||
|
---
|
||||||
|
|
||||||
Markdown text goes after a *newline*
|
Markdown text goes after a header *separator*
|
||||||
|
|
||||||
Use placeholders for variables and plugins in your markdown or html
|
Use placeholders for variables and plugins in your markdown or html
|
||||||
files, e.g. `{{ title }}`.
|
files, e.g. `{{ title }}` or `{{ command arg1 arg2 }}.
|
||||||
|
|
||||||
Write extensions in any language you like and put them into the `.zs`
|
Write extensions in any language you like and put them into the `.zs`
|
||||||
subdiretory.
|
subdiretory.
|
||||||
@ -46,22 +49,42 @@ subdiretory.
|
|||||||
Everything the extensions prints to stdout becomes the value of the
|
Everything the extensions prints to stdout becomes the value of the
|
||||||
placeholder.
|
placeholder.
|
||||||
|
|
||||||
Extensions can use special environment variables, like:
|
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:
|
||||||
|
|
||||||
* `$ZS` - a path to the `zs` executable
|
* `$ZS` - a path to the `zs` executable
|
||||||
* `$ZS_OUTDIR` - a path to the directory with generated files
|
* `$ZS_OUTDIR` - a path to the directory with generated files
|
||||||
* `$ZS_FILE` - a path to the currently processed markdown file
|
* `$ZS_FILE` - a path to the currently processed markdown file
|
||||||
* `$ZS_URL` - a URL for the currently generated page
|
* `$ZS_URL` - a URL for the currently generated page
|
||||||
|
|
||||||
You can also pass command line arguments, e.g: `{{ my-plugin arg1 arg2 }}`
|
|
||||||
|
|
||||||
## Example of RSS generation
|
## Example of RSS generation
|
||||||
|
|
||||||
|
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-
|
||||||
|
```
|
||||||
|
|
||||||
## Hooks
|
## Hooks
|
||||||
|
|
||||||
There are two special plugin names that are executed every time the build
|
There are two special plugin names that are executed every time the build
|
||||||
happens - `pre` and `post`. You can define some global action here like compile
|
happens - `prehook` and `posthook`. You can define some global actions here like
|
||||||
your LESS to CSS etc:
|
content generation, or additional commands, like LESS to CSS conversion:
|
||||||
|
|
||||||
# .zs/post
|
# .zs/post
|
||||||
|
|
||||||
@ -69,10 +92,18 @@ your LESS to CSS etc:
|
|||||||
lessc < $ZS_OUTDIR/styles.less > $ZS_OUTDIR/styles.css
|
lessc < $ZS_OUTDIR/styles.less > $ZS_OUTDIR/styles.css
|
||||||
rm -f $ZS_OUTDIR/styles.css
|
rm -f $ZS_OUTDIR/styles.css
|
||||||
|
|
||||||
|
## Syntax sugar
|
||||||
|
|
||||||
|
By default, `zs` converts each `.amber` file into `.html`, so you can use lightweight Jade-like syntax instead of bloated HTML.
|
||||||
|
|
||||||
|
Also, `zs` converts `.gcss` into `.css`, so you don't really need LESS or SASS. More about GCSS can be found [here][gcss].
|
||||||
|
|
||||||
## Command line usage
|
## Command line usage
|
||||||
|
|
||||||
`zs build` re-builds your site.
|
`zs build` re-builds your site.
|
||||||
|
|
||||||
|
`zs build <file>` re-builds one file and prints resulting content to stdout.
|
||||||
|
|
||||||
`zs watch` rebuilds your site every time you modify any file.
|
`zs watch` rebuilds your site every time you modify any file.
|
||||||
|
|
||||||
`zs var <filename> [var1 var2...]` prints a list of variables defined in the
|
`zs var <filename> [var1 var2...]` prints a list of variables defined in the
|
||||||
@ -82,3 +113,7 @@ it's an empty string).
|
|||||||
## License
|
## License
|
||||||
|
|
||||||
The software is distributed under the MIT license.
|
The software is distributed under the MIT license.
|
||||||
|
|
||||||
|
[amber]: https://github.com/eknkc/amber/
|
||||||
|
[YAML]: https://github.com/go-yaml/yaml
|
||||||
|
[gcss]: https://github.com/yosssi/gcss
|
||||||
|
Loading…
Reference in New Issue
Block a user