Fixed HTML generation ignoring hidden property.

This commit is contained in:
SPT-dev 2023-03-02 21:10:22 -05:00
parent 3a833c8396
commit f878c679d0

View File

@ -80,8 +80,14 @@ class Docs {
});
routes.forEach(routingItem => {
if (!routingItem.hasOwnProperty("hidden") || !routingItem["hidden"]) {
nav.appendChild(routingItem.buildSelf());
if (routingItem["hidden"] === false || typeof routingItem["hidden"] === "undefined") {
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.
*/
buildSelf() {
buildSelf(force = false) {
if (this.hidden === false || typeof this.hidden === "undefined") {
force = true
}
if (force) {
const element = document.createElement("a");
element.href = `#${this.filepath}`;
element.innerText = this.name;
return element;
} else {
return;
}
}
/**
@ -278,19 +294,12 @@ class RoutingNode extends RoutingItem {
/**
* @returns {HTMLUListElement} The RoutingNode as an HTML unordered list.
*/
buildSelf(prefix, suffix) {
if (typeof prefix === 'undefined') {
prefix = '';
} else {
prefix += '/';
}
if (typeof suffix === 'undefined') {
suffix = '';
} else {
suffix += '/';
buildSelf(force = false) {
if (this.hidden === false || typeof this.hidden === "undefined") {
force = true
}
if (force) {
const element = document.createElement('section');
element.classList.add("node", "hide");
@ -303,8 +312,11 @@ class RoutingNode extends RoutingItem {
// list.classList.add("hide");
this.routes.forEach(entry => {
const childEl = document.createElement('li');
const el = entry.buildSelf();
childEl.appendChild(entry.buildSelf());
if (typeof el !== "undefined") {
childEl.appendChild(el);
}
list.appendChild(childEl);
});
@ -313,6 +325,9 @@ class RoutingNode extends RoutingItem {
element.appendChild(list);
return element;
} else {
return;
}
}
}