Add sites that use zs and a collection of hooks and plugins to contrib

This commit is contained in:
James Mills 2023-03-28 00:26:11 +10:00
parent 6b15486148
commit 1d061592f5
No known key found for this signature in database
GPG Key ID: AC4C014F1440EBD6
8 changed files with 107 additions and 1 deletions

View File

@ -4,6 +4,7 @@
"alecthomas", "alecthomas",
"chromahtml", "chromahtml",
"definitionlist", "definitionlist",
"divs",
"errbuf", "errbuf",
"Furqan", "Furqan",
"goldmark", "goldmark",
@ -11,6 +12,7 @@
"newext", "newext",
"oldext", "oldext",
"outbuf", "outbuf",
"pandoc",
"PUBDIR", "PUBDIR",
"sabhiram", "sabhiram",
"sirupsen", "sirupsen",

View File

@ -50,7 +50,7 @@ EOF
zs serve zs serve
``` ```
For a starter template see the [zs-starter-tempate](https://git.mills.io/prologic/zs-stater-template) which can also be found running live at [zs.mills.io](https://zs.mills.io). For a starter template see the [zs-starter-template](https://git.mills.io/prologic/zs-stater-template) which can also be found running live at [zs.mills.io](https://zs.mills.io).
## Features ## Features
@ -215,6 +215,8 @@ for f in ./blog/*.md ; do
done | sort -r -n | cut -d' ' -f2- done | sort -r -n | cut -d' ' -f2-
``` ```
Looking for more plugins? Check out the [contrib/plugins](https://git.mills.io/prologic/zs/src/branch/main/contrib/plugins) collection!
## 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
@ -234,6 +236,8 @@ minify -o "$ZS_OUTDIR/css/fa.min.css" "$ZS_OUTDIR/css/fa.css"
minify -o "$ZS_OUTDIR/css/site.min.css" "$ZS_OUTDIR/css/site.css" minify -o "$ZS_OUTDIR/css/site.min.css" "$ZS_OUTDIR/css/site.css"
``` ```
Looking for more hooks? Check out the [contrib/hooks](https://git.mills.io/prologic/zs/src/branch/main/contrib/hooks) collection!
## Command line usage ## Command line usage
- `zs build` re-builds your site. - `zs build` re-builds your site.
@ -282,6 +286,17 @@ Flags:
Use "zs [command] --help" for more information about a command. Use "zs [command] --help" for more information about a command.
``` ```
## Who's using zs?
Here's a few sites that use `zs` today:
- https://yarn.social -- Landing page of the decentralized microBlogging ecosystem.
- https://salty.im -- Landing page of the e2e encrypted IndieWeb inspired messaging protocol.
- https://zs.mills.io -- zs starter template demo.
- https://prologic.shortcircuit.net.au -- Home page of James Mills / prologic (author of zs)
Want to add your site here? File an issue or submit a pull-request!
## Frequently Asked Questions ## Frequently Asked Questions
### How do I link to other pages? ### How do I link to other pages?

19
contrib/hooks/posthook Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
set -e
minify_assets() {
p="$1"
t="$2"
find "$p" -type f -name "*.$t" | while read -r file; do
name="${file#"$p"}"
name="${name#"/"}"
#name="${name%.*}"
#minify -o "${p}/${name}.min.$t" "$file"
minify -o "${p}/${name}" "$file"
done
}
minify_assets "$ZS_OUTDIR" "css"
minify_assets "$ZS_OUTDIR" "js"

3
contrib/hooks/prehook Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
exit 0

25
contrib/plugins/importmap Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
if [ $# -ne 1 ]; then
printf "Usage: %s <path>\n" "$(basename "$0")"
exit 1
fi
modpath="$1"
modpath="${modpath%"/"}"
ext=".js"
if [ -n "$ZS_PRODUCTION" ]; then
ext=".min.js"
fi
echo "<script type=\"importmap\">"
{
find "$modpath" -type f -name '*.js' | while read -r file; do
name="${file#"$modpath"}"
name="${name#"/"}"
name="${name%.*}"
echo "${name}=./${modpath}/${name}${ext}"
done
} | jq -Rs '{ imports: split("\n") | [.[] | capture("^(?<name>[^=]+)=(?<src>.*)$") | {(.name): .src}] | add }'
echo "</script>"

12
contrib/plugins/include Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
if [ ! $# = 1 ]; then
printf "Usage: %s <file>\n" "$(basename "$0")"
exit 0
fi
if [ -f "$1" ]; then
cat "$1"
else
echo "error: file not found $1"
fi

21
contrib/plugins/scripts Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
set -e
SCRIPTS="page"
MODULES="globe phenon"
# Load live.js for non-production builds for faster development
if [ -z "$ZS_PRODUCTION" ]; then
SCRIPTS="$SCRIPTS live"
fi
for script in $SCRIPTS; do
printf "<script type=\"application/javascript\" src=\"/js/%s.js\"></script>\n" "$script"
done
for module in $MODULES; do
printf "<script type=\"module\" src=\"/js/modules/%s.js\"></script>\n" "$module"
done
printf "<script defer type=\"module\" src=\"/js/main.js\">main();</script>\n"

9
contrib/plugins/styles Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
set -e
CSS="style triangles"
for css in $CSS; do
printf "<link rel=\"stylesheet\" href=\"/css/%s.css\">\n" "$css"
done