source: code/trunk/README.md@ 90

Last change on this file since 90 was 89, checked in by Izuru Yakumo, 7 weeks ago

風神「嵐の日」

File size: 3.8 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)
[75]13* Easy to learn (you literally don't need to)
14* Fast (goes without saying)
[9]15
16## Installation
17
[87]18Build it manually provided you have Go (>=1.17) installed:
[9]19
[89]20 $ go install mahou-no-mori.yakumo.dev/aya/cmd/aya@latest (1)
[65]21 --- or ---
[89]22 $ git clone https://git.yakumo.dev/yakumo.izuru/aya
[65]23 $ cd aya
24 $ make
25 # make install
[80]26
27(1) If you use this method, the `aya version` subcommand may print the wrong string,
28but it should not be a problem unless you use it on a page.
29
[87]30You can also disable certain features at build time, with the `-tags` switch.
31Currently, these tags are available: `noamber`, `nogcss`.
32See `go help buildconstraint` for more details.
33
[9]34## Ideology
35
[80]36Keep your texts in markdown, [amber](https://github.com/eknkc/amber), or html format right in the main directory
[39]37of your blog/site.
[9]38
39Keep all service files (extensions, layout pages, deployment scripts etc)
[56]40in the `.aya` subdirectory.
[9]41
[87]42Define variables in the header of the content files using [YAML](https://noyaml.com) :
[9]43
[80]44```markdown
45title: My web site
46keywords: best website, hello, world
47---
[9]48
[80]49Markdown text goes after a header *separator*
50```
[9]51
52Use placeholders for variables and plugins in your markdown or html
[39]53files, e.g. `{{ title }}` or `{{ command arg1 arg2 }}.
[9]54
[56]55Write extensions in any language you like and put them into the `.aya`
[9]56subdiretory.
57
[80]58Everything the extensions prints to [stdout](https://man.freebsd.org/cgi/man.cgi?fd) becomes the value of the
[9]59placeholder.
60
[81]61Every variable from the content header will be passed via environment variables like `title` becomes `$AYA_TITLE` and so on.
[80]62There are some special variables:
[9]63
[56]64* `$AYA` - a path to the `aya` executable
[81]65* `$AYA_OUTDIR` - a path to the directory with generated files
66* `$AYA_FILE` - a path to the currently processed markdown file
67* `$AYA_URL` - a URL for the currently generated page
[9]68
69## Example of RSS generation
70
[39]71Extensions 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:
72
73``` bash
[65]74#!/bin/sh
75echo "Generating RSS feed"
76
77echo '<?xml version="1.0" encoding="utf-8"?>' > $AYA_OUTDIR/blog/rss.xml
78echo '<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">' >> $AYA_OUTDIR/blog/rss.xml
79echo '<channel>' >> $AYA_OUTDIR/blog/rss.xml
80for f in ./blog/*/*.md ; do
81 d=$($AYA var $f date)
82 if [ ! -z $d ] ; then
83 timestamp=`gdate --date "$d" +%s`
84 url=`$AYA var $f url`
85 title=`$AYA var $f title | tr A-Z a-z`
86 descr=`$AYA var $f description`
[89]87 echo $timestamp "<item><title>$title</title><link>https://technicalmarisa.yakumo.dev/blog/$url</link><description>$descr</description><pubDate>$(gdate --date @$timestamp -R)</pubDate><guid>http://technicalmarisa.yakumo.dev/blog/$url</guid></item>"
[65]88 fi
89done | sort -r -n | cut -d' ' -f2- >> $AYA_OUTDIR/blog/rss.xml
90echo '</channel>' >> $AYA_OUTDIR/blog/rss.xml
91echo '</rss>' >> $AYA_OUTDIR/blog/rss.xml
[39]92```
93
[9]94## Hooks
95There are two special plugin names that are executed every time the build
[39]96happens - `prehook` and `posthook`. You can define some global actions here like
[84]97content generation, or additional commands, like LESS to CSS conversion
[9]98
[80]99Note, you can also place `.gcss` files for [gcss](https://github.com/yosssi/gcss) to process instead
[65]100
[9]101## Command line usage
[84]102Read `aya(1)`
[9]103
[84]104## License
105The software is distributed under the [MIT/X11](LICENSE) license.
[9]106
[68]107---
108
109Ayaya~
Note: See TracBrowser for help on using the repository browser.