When an Origami template shows data from a folder, by default it’s sorted by file name.
haiku.ori
${ Tree.map(poems/, poem.ori.html) }
http://localhost:5000/haiku.html
[lamp.md] The lamp once out / cool stars enter / the window frame – Soseki, Natsume
[noOne.md] No one travels / along this way but I / this autumn evening – Bashō, Matsuo
[poppy.md] I write, erase, rewrite / erase again, and then / a poppy blooms – Hokusai, Katsushika
To sort by a data field, use Origami’s sort function.
haiku.ori
${ Tree.sort(poems/, (poem) => poem.author)
-> (sorted) => Tree.map(sorted, poem.ori.html) }
http://localhost:5000/haiku.html
[noOne.md] No one travels / along this way but I / this autumn evening – Bashō, Matsuo
[poppy.md] I write, erase, rewrite / erase again, and then / a poppy blooms – Hokusai, Katsushika
[lamp.md] The lamp once out / cool stars enter / the window frame – Soseki, Natsume
Now sorted by author!
For an arbitrary order, create an object with the file names in the order you want them.
ordered.ori
{
poppy.md
lamp.md
noOne.md
}
This can go in the folder with the files.
Use that object as your data source, and the template will use your order to list things.
haiku.ori
${ Tree.map(poems/ordered.ori, poem.ori.html) }
http://localhost:5000/haiku.html
[poppy.md] I write, erase, rewrite / erase again, and then / a poppy blooms – Hokusai, Katsushika
[lamp.md] The lamp once out / cool stars enter / the window frame – Soseki, Natsume
[noOne.md] No one travels / along this way but I / this autumn evening – Bashō, Matsuo
Read more: Tree.sort builtin function
Previous: Generate an exports file for a JavaScript project Comic index