diff --git a/linked-files/pathsToObjs.js b/linked-files/pathsToObjs.js deleted file mode 100644 index 377b718..0000000 --- a/linked-files/pathsToObjs.js +++ /dev/null @@ -1,36 +0,0 @@ -// Original source - https://stackoverflow.com/a/44681235 -// Posted by le_m -// Retrieved 2026-03-11, License - CC BY-SA 3.0 -// Insert path into directory tree structure: -// -//modified to construct an object instead of an array. - -function insert(tree = {}, [head, ...tail]) { - - if (tail.length > 0) { - tree[head] = insert(tree[head], tail) - } else { - tree[head] = true - } - - return tree; -} - -// Example: -let examplepaths = [ - 'css/style.css', - 'about/bird.svg', -]; - -//naive! assumes relative path like in example. -//A more robust implementation would need to resolve paths first, but to what. -export default function process(paths) { - return paths - .map(path => path.split('/') - .slice(1) //if path starts with / or ./ - ) - .reduce((tree, path) => insert(tree, path), {}); -} - -//test: -// console.log(process(examplepaths)); diff --git a/pipeline.ori b/pipeline.ori index dc92e28..c2d8fd6 100644 --- a/pipeline.ori +++ b/pipeline.ori @@ -69,7 +69,9 @@ linksByFile: Tree.map(Tree.map(renderedPages, (a) => a/html), ./linked-files/getLinkedFilesFromHtml.js) uniqueLinks: Tree.flat(linksByFile) → (a) => [...new Set(a)] - linksAsTree: ./linked-files/pathsToObjs.js(uniqueLinks) + //linksAsTree: ./linked-files/pathsToObjs.js(uniqueLinks) + linksAsTree: Tree.inflatePaths(Tree.withKeys(() => true, uniqueLinks)) + onlyLinkedFiles: Tree.mask(list, linksAsTree) index.html: ori-templates/indexPage.ori(final, all)