/* 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) => { /* 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('_')) documents: Tree.map(allfiles, {value: (value) => Origami.document(value)}) //if I don't use the verbose syntax I get the filename characters as part of value! withfndata: Tree.map(documents, { value: (value, key) => addFilenameData.js(value, Origami.slash.remove(key))}) pubfiles: Tree.filter(withfndata, (val, key) => val.fnd.tags?.includes('pub')) /* Now convert to html. */ asHtml: Tree.map(all ? withfndata: pubfiles, { value: (value) => Origami.mdHtml(value) key: (value, key) => `${value.fnd.name}` }) /* 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 paragraph `

—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 ) /* slightly complex. This adds a property `html` to the page with the rendered content. */ renderedPages: Tree.map(final, {value: (page) => { html: (page, all) ...page }}) /* Then, we can use that html and the trls property to add the translations. */ pagesInFolders: Tree.map(renderedPages, pagesInFoldersWithTranslations.js) /* pagesInFolders: Tree.map(renderedPages, { value: (value) => { index.html: value } }) */ //bug in 0.6.14? linksByFile: Tree.map(renderedPages,getLinkedFilesFromHtml.js) uniqueLinks: Tree.flat(linksByFile, 2) → (a) => [...new Set(a)] //links: Tree.flat(Tree.map(renderedPages, getLinkedFilesFromHtml.js), 2) // → (links) => Tree.flat(links, 2) → (a) => Tree.values([...new Set(a)]/0) linksAsTree: pathsToObjs.js(uniqueLinks) onlyLinkedFiles: Tree.mask(list, linksAsTree) /* 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) }