From 88e766e84b241e0e19a3c59c264580c815e4ad84 Mon Sep 17 00:00:00 2001 From: kwajiehao <31984694+kwajiehao@users.noreply.github.com> Date: Fri, 22 Nov 2019 16:58:06 +0800 Subject: [PATCH] feat: add support for false collections (#33) --- classes/Tree.js | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/classes/Tree.js b/classes/Tree.js index c375ce402..266f4eea9 100644 --- a/classes/Tree.js +++ b/classes/Tree.js @@ -47,27 +47,33 @@ class Tree { // If navigation item has a url it links to a simple page / external page // TODO - know if it links to an external page if (item.url) { - this.navHasSimplePage = true; - const fileName = item.title.toLowerCase().replace(" ", "-") + ".md" - return { - type: 'page', - title: item.title, - path: encodeURIComponent(new PageType().getFolderName() + fileName), - url: item.url, - } + this.navHasSimplePage = true; + const fileName = item.title.toLowerCase().replace(" ", "-") + ".md" + return { + type: 'page', + title: item.title, + path: encodeURIComponent(new PageType().getFolderName() + fileName), + url: item.url, + } } else if (item.collection) { - this.collections.push(item.collection) - return { - type: 'collection', - title: item.title, - collection: item.collection, - } + this.collections.push(item.collection) + return { + type: 'collection', + title: item.title, + collection: item.collection, + } } else if (item.resource_room) { - this.navHasResources = true - return { - type: 'resource room', - title: item.title, - } + this.navHasResources = true + return { + type: 'resource room', + title: item.title, + } + } else if (item.sublinks) { + return { + type: 'falseCollection', + title: item.title, + children: item.sublinks.map((item) => (Object.assign(item, { type: 'page' }))), + } } return item });