33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
// noinspection JSUnresolvedVariable
|
|
const {$, doAfterLoad, footer, header, nav, showPage, stringToHtml} = window.fwdekker;
|
|
|
|
|
|
const unpackEntry = function (entry, depth = 0) {
|
|
const subEntries = entry.entries.length === 0
|
|
? ""
|
|
: `<ul>` + entry.entries.map(it => unpackEntry(it, depth + 1)).join("") + `</ul>`;
|
|
|
|
return "" +
|
|
`<h${depth + 4}>` +
|
|
`<a href="${entry.link}">${entry.name}</a>` +
|
|
subEntries +
|
|
`</h${depth + 4}>`;
|
|
};
|
|
|
|
|
|
doAfterLoad(() => {
|
|
$("#nav").appendChild(nav("/Tools/"));
|
|
$("#header").appendChild(header({title: "Tools", description: "An overview of tools I have created"}));
|
|
$("#footer").appendChild(footer({
|
|
vcsURL: "https://git.fwdekker.com/FWDekker/tools/",
|
|
version: "v%%VERSION_NUMBER%%"
|
|
}));
|
|
showPage();
|
|
|
|
fetch("https://fwdekker.com/api/nav/")
|
|
.then(it => it.json())
|
|
.then(json => json.entries.find(it => it.name === "Tools"))
|
|
.then(json => stringToHtml(`<ul>${json.entries.map(entry => unpackEntry(entry)).join("")}</ul>`, "ul"))
|
|
.then(listing => $("#listing").append(listing));
|
|
});
|