Browse Source

Remove un-minifiable whitespace

master
F.W. Dekker 8 months ago
parent
commit
543f65675d
Signed by: FWDekker GPG Key ID: B1B567AF58D6EE0F
  1. 2
      package.json
  2. 71
      src/main/js/Template.js

2
package.json

@ -1,6 +1,6 @@
{
"name": "@fwdekker/template",
"version": "0.0.24",
"version": "0.0.25",
"description": "The base template for pages on fwdekker.com.",
"author": "Felix W. Dekker (https://fwdekker.com)",
"license": "MIT",

71
src/main/js/Template.js

@ -51,14 +51,13 @@ export const doAfterLoad = function (fun) {
* @returns {HTMLElement} a base navigation element that will eventually be filled with contents
*/
export const nav = function (highlightPath = "") {
const base = stringToHtml(`
<ul>
<li><a href="https://fwdekker.com/">
<div class="logo"><img class="logo" src="https://fwdekker.com/favicon.png" alt="FWDekker" /></div>
<b>FWDekker</b>
</a></li>
</ul>
`, "ul");
const base = stringToHtml(
`<ul><li><a href="https://fwdekker.com/">` +
`<div class="logo"><img class="logo" src="https://fwdekker.com/favicon.png" alt="FWDekker" /></div>` +
`<b>FWDekker</b>` +
`</a></li></ul>`,
"ul"
);
fetch("https://fwdekker.com/api/nav/")
.then(it => it.json())
@ -93,12 +92,11 @@ const unpackEntry = function (entry, path = "/", highlightPath = "") {
const depth = path.split("/").length - 2; // -1 because count parts, then another -1 because of leading `/`
const arrow = depth === 0 ? "&#9662;" : "&#9656;";
return `
<li class="${shouldHighlight ? "currentPage" : ""}">
<a href="${entry.link}">${entry.name} ${arrow}</a>
<ul>${entry.entries.map(it => unpackEntry(it, `${path + entry.name}/`, highlightPath)).join("")}</ul>
</li>
`;
return "" +
`<li class="${shouldHighlight ? "currentPage" : ""}">` +
`<a href="${entry.link}">${entry.name} ${arrow}</a>` +
`<ul>${entry.entries.map(it => unpackEntry(it, `${path + entry.name}/`, highlightPath)).join("")}</ul>` +
`</li>`;
};
@ -113,14 +111,13 @@ export const header = function ({title, description}) {
if (title === undefined && description === undefined)
return stringToHtml(`<header class="header"></header>`, "header");
return stringToHtml(`
<header class="header">
<section class="container">
${(title !== undefined ? `<h1>${title}</h1>` : "")}
${(description !== undefined ? `<p><em>${description}</em></p>` : "")}
</section>
</header>
`, "header");
return stringToHtml(
`<header class="header"><section class="container">` +
(title !== undefined ? `<h1>${title}</h1>` : "") +
(description !== undefined ? `<p><em>${description}</em></p>` : "") +
`</section></header>`,
"header"
);
};
@ -143,22 +140,20 @@ export const footer = function (
author, authorURL, license, licenseURL, vcs, vcsURL, version,
privacyPolicyURL = undefined
}) {
return stringToHtml(`
<footer class="footer">
<section class="container">
${footerLink("Made by ", author, authorURL, ". ")}
${footerLink("Licensed under the ", license, licenseURL, ". ")}
${footerLink("Source code available on ", vcs, vcsURL, ". ")}
${footerLink(
"Consider reading the ",
privacyPolicyURL === null ? undefined : "privacy policy",
privacyPolicyURL === undefined ? "https://fwdekker.com/privacy/" : privacyPolicyURL,
". "
)}
<div style="float: right;">${version || ""}</div>
</section>
</footer>
`, "footer");
return stringToHtml(
`<footer class="footer"><section class="container">` +
footerLink("Made by ", author, authorURL, ". ") +
footerLink("Licensed under the ", license, licenseURL, ". ") +
footerLink("Source code available on ", vcs, vcsURL, ". ") +
footerLink(
"Consider reading the ",
privacyPolicyURL === null ? undefined : "privacy policy",
privacyPolicyURL === undefined ? "https://fwdekker.com/privacy/" : privacyPolicyURL,
". "
) +
`<div style="float: right;">${version || ""}</div>` +
`</section></footer>`,
"footer");
};
/**

Loading…
Cancel
Save