source: code/trunk/README.md@ 65

Last change on this file since 65 was 65, checked in by Izuru Yakumo, 2 years ago

Update documentation

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

File size: 3.8 KB
Line 
1# aya
2
3aya is an extremely minimal static site generator written in Go.
4
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)
6
7## Features
8
9* Zero configuration (no configuration file needed)
10* Cross-platform
11* Highly extensible
12* Works well for blogs and generic static websites (landing pages etc)
13* Easy to learn
14* Fast (duh!)
15
16## Installation
17
18Build it manually assuming you have Go installed:
19
20 $ go install marisa.chaotic.ninja/aya/cmd/aya@latest
21 --- or ---
22 $ git clone https://git.chaotic.ninja/yakumo.izuru/aya
23 $ cd aya
24 $ make
25 # make install
26
27## Ideology
28
29Keep your texts in markdown, or HTML format right in the main directory
30of your blog/site.
31
32Keep all service files (extensions, layout pages, deployment scripts etc)
33in the `.aya` subdirectory.
34
35Define variables in the header of the content files using [YAML]:
36
37 title: My web site
38 keywords: best website, hello, world
39 ---
40
41 Markdown text goes after a header *separator*
42
43Use placeholders for variables and plugins in your markdown or html
44files, e.g. `{{ title }}` or `{{ command arg1 arg2 }}.
45
46Write extensions in any language you like and put them into the `.aya`
47subdiretory.
48
49Everything the extensions prints to stdout becomes the value of the
50placeholder.
51
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:
53
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
58
59## Example of RSS generation
60
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
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
82```
83
84## Hooks
85
86There are two special plugin names that are executed every time the build
87happens - `prehook` and `posthook`. You can define some global actions here like
88content generation, or additional commands, like LESS to CSS conversion:
89
90 # .aya/post
91
92 #!/bin/sh
93 lessc < $AYA_OUTDIR/styles.less > $AYA_OUTDIR/styles.css
94 rm -f $AYA_OUTDIR/styles.css
95
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
101## Command line usage
102
103`aya build` re-builds your site.
104
105`aya build <file>` re-builds one file and prints resulting content to stdout.
106
107`aya serve` serves your site over HTTP.
108
109`aya var <filename> [var1 var2...]` prints a list of variables defined in the
110header of a given markdown file, or the values of certain variables (even if
111it's an empty string).
112
113`aya watch` rebuilds your site every time you modify any file.
114
115## License
116
117The software is distributed under the MIT license.
Note: See TracBrowser for help on using the repository browser.