50 lines
1.8 KiB
Plaintext
50 lines
1.8 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.
|
|
*/
|
|
// allfiles: allfiles.sh() //reads MD files.
|
|
// pubfiles: pubfiles.sh(allfiles)
|
|
(list): ..
|
|
allfiles: Tree.filter(list, (val, key) => key.endsWith('.md') && !key.startsWith('_'))
|
|
pubfiles: Tree.filter(allfiles, (val, key) => key.includes('_pub'))
|
|
files: Tree.map( all ? allfiles : pubfiles, {value: (val) => Origami.document(val)})
|
|
asHtml: Tree.map(files, (value) => Origami.mdHtml(value))
|
|
→ (values) => Tree.mapExtension(values, '.md→.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/
|
|
}
|