on master help sign in
lib: documenting getLinksinSubdirs
844f55fMatilde Park
lib/lib.js+10
@@ -161,6 +161,16 @@ function set(obj, path, value) {
161 return obj;
161 return obj;
162}
162}
163
163
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+
164export function getLinksinSubdirs(path) {
174export function getLinksinSubdirs(path) {
165 const allFiles = getAllFiles(path);
175 const allFiles = getAllFiles(path);
166 const fileTree = {};
176 const fileTree = {};