source: code/trunk/README.md@ 72

Last change on this file since 72 was 68, checked in by Izuru Yakumo, 21 months ago

bfchroma turned out to be a hassle

Signed-off-by: Izuru Yakumo <yakumo.izuru@…>

File size: 3.9 KB
RevLine 
[56]1# aya
[9]2
[56]3aya is an extremely minimal static site generator written in Go.
[9]4
[65]5Named after [Aya Shameimaru](https://en.touhouwiki.net/wiki/Aya_Shameimaru) from [Touhou 9.5: Shoot the Bullet](https://en.touhouwiki.net/wiki/Shoot_the_Bullet)
[9]6
7## Features
8
9* Zero configuration (no configuration file needed)
10* Cross-platform
11* Highly extensible
[39]12* Works well for blogs and generic static websites (landing pages etc)
[9]13* Easy to learn
[65]14* Fast (duh!)
[9]15
16## Installation
17
[68]18Build it manually assuming you have Go (>=1.17) installed:
[9]19
[61]20 $ go install marisa.chaotic.ninja/aya/cmd/aya@latest
[65]21 --- or ---
22 $ git clone https://git.chaotic.ninja/yakumo.izuru/aya
23 $ cd aya
24 $ make
25 # make install
26
[9]27## Ideology
28
[48]29Keep your texts in markdown, or HTML format right in the main directory
[39]30of your blog/site.
[9]31
32Keep all service files (extensions, layout pages, deployment scripts etc)
[56]33in the `.aya` subdirectory.
[9]34
[39]35Define variables in the header of the content files using [YAML]:
[9]36
37 title: My web site
38 keywords: best website, hello, world
[39]39 ---
[9]40
[39]41 Markdown text goes after a header *separator*
[9]42
43Use placeholders for variables and plugins in your markdown or html
[39]44files, e.g. `{{ title }}` or `{{ command arg1 arg2 }}.
[9]45
[56]46Write extensions in any language you like and put them into the `.aya`
[9]47subdiretory.
48
49Everything the extensions prints to stdout becomes the value of the
50placeholder.
51
[56]52Every variable from the content header will be passed via environment variables like `title` becomes `$AYA_TITLE` and so on. There are some special variables:
[9]53
[56]54* `$AYA` - a path to the `aya` executable
55* `$AYA_OUTDIR` - a path to the directory with generated files
56* `$AYA_FILE` - a path to the currently processed markdown file
57* `$AYA_URL` - a URL for the currently generated page
[9]58
59## Example of RSS generation
60
[39]61Extensions 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:
62
63``` bash
[65]64#!/bin/sh
65echo "Generating RSS feed"
66
67echo '<?xml version="1.0" encoding="utf-8"?>' > $AYA_OUTDIR/blog/rss.xml
68echo '<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">' >> $AYA_OUTDIR/blog/rss.xml
69echo '<channel>' >> $AYA_OUTDIR/blog/rss.xml
70for f in ./blog/*/*.md ; do
71 d=$($AYA var $f date)
72 if [ ! -z $d ] ; then
73 timestamp=`gdate --date "$d" +%s`
74 url=`$AYA var $f url`
75 title=`$AYA var $f title | tr A-Z a-z`
76 descr=`$AYA var $f description`
77 echo $timestamp "<item><title>$title</title><link>https://technicalmarisa.chaotic.ninja/blog/$url</link><description>$descr</description><pubDate>$(gdate --date @$timestamp -R)</pubDate><guid>http://technicalmarisa.chaotic.ninja/blog/$url</guid></item>"
78 fi
79done | sort -r -n | cut -d' ' -f2- >> $AYA_OUTDIR/blog/rss.xml
80echo '</channel>' >> $AYA_OUTDIR/blog/rss.xml
81echo '</rss>' >> $AYA_OUTDIR/blog/rss.xml
[39]82```
83
[9]84## Hooks
85
86There are two special plugin names that are executed every time the build
[39]87happens - `prehook` and `posthook`. You can define some global actions here like
88content generation, or additional commands, like LESS to CSS conversion:
[9]89
[56]90 # .aya/post
[9]91
92 #!/bin/sh
[56]93 lessc < $AYA_OUTDIR/styles.less > $AYA_OUTDIR/styles.css
94 rm -f $AYA_OUTDIR/styles.css
[9]95
[65]96## Extras
97
98`aya` also supports generating `.html` and `.css` by means of using `.amber`
99and `.gcss` files. See more at [eknkc/amber](https://github.com/eknkc/amber) [yosssi/gcss](https://github.com/yosssi/gcss)
100
[9]101## Command line usage
102
[56]103`aya build` re-builds your site.
[9]104
[56]105`aya build <file>` re-builds one file and prints resulting content to stdout.
[39]106
[61]107`aya serve` serves your site over HTTP.
[9]108
[56]109`aya var <filename> [var1 var2...]` prints a list of variables defined in the
[9]110header of a given markdown file, or the values of certain variables (even if
111it's an empty string).
112
[61]113`aya watch` rebuilds your site every time you modify any file.
114
[9]115## License
116
117The software is distributed under the MIT license.
[68]118
119---
120
121Ayaya~
Note: See TracBrowser for help on using the repository browser.