Fixed HTML generation ignoring hidden property.

This commit is contained in:
Atomos821 2020-11-25 15:56:06 +01:00
parent 248738004e
commit 3d567ac263

View File

@ -80,8 +80,14 @@ class Docs {
}); });
routes.forEach(routingItem => { routes.forEach(routingItem => {
if (!routingItem.hasOwnProperty("hidden") || !routingItem["hidden"]) { if (routingItem["hidden"] === false || typeof routingItem["hidden"] === "undefined") {
nav.appendChild(routingItem.buildSelf()); const el = routingItem.buildSelf();
if (typeof el !== "undefined") {
nav.appendChild(el);
}
} else {
console.log(`skipped ${routingItem.name}`);
} }
}); });
@ -214,14 +220,24 @@ class Route extends RoutingItem {
} }
/** /**
* @param {boolean} force Wether to force generation or not despite the hidden property.
* @returns {HTMLAnchorElement} The Route as an HTML link. * @returns {HTMLAnchorElement} The Route as an HTML link.
*/ */
buildSelf() { buildSelf(force = false) {
if (this.hidden === false || typeof this.hidden === "undefined") {
force = true
}
if (force) {
const element = document.createElement("a"); const element = document.createElement("a");
element.href = `#${this.filepath}`; element.href = `#${this.filepath}`;
element.innerText = this.name; element.innerText = this.name;
return element; return element;
} else {
return;
}
} }
/** /**
@ -278,19 +294,12 @@ class RoutingNode extends RoutingItem {
/** /**
* @returns {HTMLUListElement} The RoutingNode as an HTML unordered list. * @returns {HTMLUListElement} The RoutingNode as an HTML unordered list.
*/ */
buildSelf(prefix, suffix) { buildSelf(force = false) {
if (typeof prefix === 'undefined') { if (this.hidden === false || typeof this.hidden === "undefined") {
prefix = ''; force = true
} else {
prefix += '/';
}
if (typeof suffix === 'undefined') {
suffix = '';
} else {
suffix += '/';
} }
if (force) {
const element = document.createElement('section'); const element = document.createElement('section');
element.classList.add("node", "hide"); element.classList.add("node", "hide");
@ -303,8 +312,11 @@ class RoutingNode extends RoutingItem {
// list.classList.add("hide"); // list.classList.add("hide");
this.routes.forEach(entry => { this.routes.forEach(entry => {
const childEl = document.createElement('li'); const childEl = document.createElement('li');
const el = entry.buildSelf();
childEl.appendChild(entry.buildSelf()); if (typeof el !== "undefined") {
childEl.appendChild(el);
}
list.appendChild(childEl); list.appendChild(childEl);
}); });
@ -313,6 +325,9 @@ class RoutingNode extends RoutingItem {
element.appendChild(list); element.appendChild(list);
return element; return element;
} else {
return;
}
} }
} }