ad_pubfiles/site.ori

66 lines
2.2 KiB
Plaintext

(all) => {
//put the file selection part in a closure, so that the list of all files is kept private.
pages: {
/*
list is all the files in current directory.
allfiles is all source files: ending with `.md` and not starting with `_`.
pubfiles is the subset containing the string `_pub`.
files selects either of these depending on the argument passed to this file.
NOTES:
- if markdown files are empty, Origami.document() will error.
*/
/*
this is the external filename method.
*/
// allfiles: allfiles.sh() //reads MD files.
// pubfiles: pubfiles.sh(allfiles)
(list): ..
allfiles: Tree.filter(list, (val, key) => key.endsWith('.md') && !key.startsWith('_'))
→ (items) => Tree.map(items, {value: (value) => Origami.document(value)}) //if I don't use the verbose syntax I get the filename characters as part of value!
→ (items) => Tree.map(items, { value: (value, key) => addFilenameData.js(value, key)})
pubfiles: Tree.filter(allfiles, (val, key) => val.fnd.tags?.includes('pub'))
/*
Now convert to html.
*/
asHtml: Tree.map(all ? allfiles: pubfiles, {
value: (value) => Origami.mdHtml(value)
key: (value, key) => `${value.fnd.name}.html`
})
/*
after converting to html, we can extract a 'summary' from the file.
With markdown, the title is taken from the YAML frontmatter,
and ends up in a separate field of the document.
So we dont have to worry about the title being part of the summary.
*/
withSummary: Tree.map(asHtml, extractSummary.js)
/*
Removing private content coming below the html comment `<!--private-below-->`
Only remove this if in public mode. So if this file is called as `site.ori("all")`,
then final output is `withSummary`, otherwise it's `privateRemoved`.
*/
privateRemoved: Tree.map(withSummary, removePrivate.js)
final: (all ? withSummary : privateRemoved)
}.final
renderedPages: Tree.map(pages, page.ori)
/*
assets are relative to the pubfiles directory
*/
css
/*
Now, I think I have enough to build both the individual pages and the index page!
*/
index.html: indexPage.ori(pages)
...renderedPages/
}