From 89db15666a0679116b5a08ffd925e33f9fc0a59d Mon Sep 17 00:00:00 2001 From: James Mills <1290234+prologic@users.noreply.github.com> Date: Sun, 12 Mar 2023 18:04:55 +1000 Subject: [PATCH] Add better README, docs and examples of using extensions (Fixes #1) --- README.md | 99 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 86 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index c36b04a..2470062 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,30 @@ zs is an extremely minimal static site generator written in Go. [![Build Status](https://ci.mills.io/api/badges/prologic/zs/status.svg)](https://ci.mills.io/prologic/zs) +## Quick Start + +```console +go get install go.mills.io/zs@latest +cat > .zs/layout.html < + + {{ title }} + + {{ content }} + +EOF +cat > index.md <\n" "$(basename "$0")" + exit 0 +fi + +if [ -f "$1" ]; then + cat "$1" +else + echo "error: file not found $1" +fi +``` + +### Extension: RSS + +`.zs/rss`: ```bash +#!/bin/sh + for f in ./blog/*.md ; do - d=$($ZS var $f date) + 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` + timestamp="$(date --date "$d" +%s)" + url="$("$ZS" var "$f" url)" + title="$("$ZS" var "$f" title | tr A-Z a-z)" + desc="$("$ZS" var "$f" description)" echo $timestamp \ "" \ "$title" \ "http://zserge.com/$url" \ - "$descr" \ + "$desc" \ "$(date --date @$timestamp -R)" \ "http://zserge.com/$url" \ "" @@ -91,8 +157,14 @@ done | sort -r -n | cut -d' ' -f2- ## Hooks There are two special plugin names that are executed every time the build -happens - `prehook` and `posthook`. You can define some global actions here like -content generation, or additional commands, like to minify CSS or Javascript files. +happens: + +- `prehook` -- executed before the build +- `posthook` -- executed after the build + +You can use these to customize the build before and after. For example you can use the `posthook` to minify CSS or Javascript files. + +`.zs/posthook`: ```bash #!/bin/sh @@ -111,10 +183,11 @@ rm -rf "$ZS_OUTDIR/css/screen.css" - `zs build` re-builds your site. - `zs build ` re-builds one file and prints resulting content to stdout. - `zs watch` rebuilds your site every time you modify any file. +- `zs serve` rebuilds your site and serve it on the network. - `zs var [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 -`zs` is licensed under the terms of the [MIT License](/LICENSE) and was orignally forked from [zserge/zs](https://github.com/zserge/zs) also licensed under the terms of the [MIT License](/LICENSE.old). +`zs` is licensed under the terms of the [MIT License](/LICENSE) and was orignally forked from [zserge/zs](https://github.com/zserge/zs) also licensed under the terms of the [MIT License](/LICENSE.old). \ No newline at end of file -- 2.43.0