diff --git a/pipeline.ori b/pipeline.ori new file mode 100644 index 0000000..d433796 --- /dev/null +++ b/pipeline.ori @@ -0,0 +1,68 @@ +/* + This 'pipeline' is separate from final site.ori, + to keep parts of the pipeline private while still allowing better debugging. + serve/watch pipeline.ori for debugging. + server or copy site.ori to build final output. +*/ +(all) => { + //put the file selection part in a closure, so that the list of all files is kept private. + /* + 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 `` + 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) + + + renderedPages: Tree.map(final, (page) => (page, all)) + + /* + 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(final, all) +} diff --git a/site.ori b/site.ori index 0380eea..9210863 100644 --- a/site.ori +++ b/site.ori @@ -1,71 +1,6 @@ (all) => { - //put the file selection part in a closure, so that the list of all files is kept private. - /* - 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 `` - 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) - - - renderedPages: Tree.map(final, (page) => (page, all)) - /* - the rendered pages contain links and images. - We want to find those, and insert a tree of their maps into the output. - First test is whether that works. - Second test is whether the paths will be correct. - */ - hast = Tree.map(renderedPages, parseHtml.js) - links: Tree.flat(hast, 2) → (a) => [...new Set(a)] - - /* - 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(final, all) - ...renderedPages/ + (src): pipeline.ori(all) + index.html: src/index.html + ...src/renderedPages + css: src/css }