on master help sign in
lib: documenting getLinksinSubdirs
commit844f55f4876ce06a6a23af87ecde4d3c5d4c88e9 authorMatilde Park <matilde@tlon.io> dateThu 17 Jun 2021, 11:23 (5 years ago) parent777ef19
1 file changed+10
lib/lib.js+10
lib/lib.js+10
@@ -161,6 +161,16 @@ function set(obj, path, value) {
161161 return obj;
162162}
163163
164+/**
165+ * getLinksinSubdirs is written to provide a recursive index of posts
166+ * for nested directories for creating sidebars.
167+ * @param {string} path Absolute path to the subdirectory.
168+ * @returns {object} Nested object by directory with name of directory,
169+ * child pages (as an array of objects with title, .md filename, slug, and weight),
170+ * and subdirectories (named simply by the folder name). Iterate through the object
171+ * recursively.
172+ */
173+
164174export function getLinksinSubdirs(path) {
165175 const allFiles = getAllFiles(path);
166176 const fileTree = {};