3.0.0-RC1 #24
|
@ -1,7 +1,7 @@
|
|||
# FWDekker Template
|
||||
The base template for pages on fwdekker.com.
|
||||
|
||||
This module contains templating functions (e.g. `header`, `footer`), CSS libraries, and some common utility methods that
|
||||
This module contains templating functions (e.g. `nav`, `footer`), CSS libraries, and some common utility methods that
|
||||
are used on nearly all pages anyway.
|
||||
|
||||
The main functionality is provided in `template.js` and `template.css`.
|
||||
|
@ -22,10 +22,8 @@ $> npm ci
|
|||
|
||||
### Building
|
||||
```shell script
|
||||
# Build the template in `dist/` for development
|
||||
$> npm run dev
|
||||
# Run the `dev` task and automatically rerun it whenever files are changed
|
||||
$> npm run dev:server
|
||||
# Build the template in `dist/` for deployment
|
||||
$> npm run deploy
|
||||
# Run the `deploy` task and automatically rerun it whenever files are changed
|
||||
$> npm run deploy:server
|
||||
```
|
||||
|
|
Binary file not shown.
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@fwdekker/template",
|
||||
"version": "2.8.0",
|
||||
"version": "3.0.0-RC1",
|
||||
"description": "The base template for pages on fwdekker.com.",
|
||||
"author": "Florine W. Dekker",
|
||||
"license": "MIT",
|
||||
|
@ -23,8 +23,7 @@
|
|||
"deploy:server": "grunt deploy:server"
|
||||
},
|
||||
"dependencies": {
|
||||
"milligram": "^1.4.1",
|
||||
"normalize.css": "^8.0.1"
|
||||
"@picocss/pico": "^1.5.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt": "^1.5.3",
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
@import "../../../node_modules/normalize.css/normalize.css";
|
||||
@import "../../../node_modules/milligram/dist/milligram.css";
|
||||
@import "../../../node_modules/@picocss/pico/css/pico.css";
|
||||
@import "snippets/colors.css";
|
||||
@import "snippets/common.css";
|
||||
@import "snippets/nav.css";
|
||||
@import "snippets/toc.css";
|
||||
@import "snippets/overrides.css";
|
||||
|
|
|
@ -1,7 +1,31 @@
|
|||
/* Custom main colors */
|
||||
:root {
|
||||
--fwdekker-theme-color: #0033cc;
|
||||
--fwdekker-theme-color-dark: #0029a3;
|
||||
--fwdekker-theme-color-very-dark: #001f7a;
|
||||
--fwdekker-theme-color-light: #003df5;
|
||||
--fwdekker-theme-color-very-light: #1f57ff;
|
||||
--fwdekker-theme-color-triplet: 0, 51, 204;
|
||||
--fwdekker-theme-color: rgb(var(--fwdekker-theme-color-triplet));
|
||||
|
||||
--fwdekker-theme-color-dark-triplet: 0, 41, 163;
|
||||
--fwdekker-theme-color-dark: rgb(var(--fwdekker-theme-color-dark-triplet));
|
||||
|
||||
--fwdekker-theme-color-very-dark-triplet: 0, 31, 122;
|
||||
--fwdekker-theme-color-very-dark: rgb(var(--fwdekker-theme-color-very-dark-triplet));
|
||||
|
||||
--fwdekker-theme-color-light-triplet: 0, 61, 245;
|
||||
--fwdekker-theme-color-light: rgb(var(--fwdekker-theme-color-light-triplet));
|
||||
|
||||
--fwdekker-theme-color-very-light-triplet: 31, 87, 255;
|
||||
--fwdekker-theme-color-very-light: rgb(var(--fwdekker-theme-color-very-light-triplet));
|
||||
}
|
||||
|
||||
|
||||
/* pico.css overrides, based on https://picocss.com/docs/customization.html */
|
||||
:root {
|
||||
--primary: var(--fwdekker-theme-color) !important;
|
||||
--primary-hover: var(--fwdekker-theme-color-light) !important;
|
||||
--primary-focus: rgba(var(--fwdekker-theme-color-dark-triplet), 0.125) !important;
|
||||
--primary-inverse: white !important;
|
||||
|
||||
--form-element-active-border-color: var(--primary) !important;
|
||||
--form-element-focus-color: var(--primary-focus) !important;
|
||||
--switch-color: var(--primary-inverse) !important;
|
||||
--switch-checked-background-color: var(--primary) !important;
|
||||
}
|
||||
|
|
|
@ -1,75 +1,88 @@
|
|||
/* Base elements */
|
||||
html, body {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
/* External link icon */
|
||||
a[target="_blank"]::after {
|
||||
display: inline-block;
|
||||
|
||||
width: 0.7em;
|
||||
height: 0.7em;
|
||||
margin-left: 0.25rem;
|
||||
|
||||
/* Image from https://icons.getbootstrap.com/icons/box-arrow-up-right/. MIT License. */
|
||||
mask-image: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg fill='currentColor' viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5z' fill-rule='evenodd'/%3E%3Cpath d='M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0v-5z' fill-rule='evenodd'/%3E%3C/svg%3E%0A");
|
||||
mask-size: cover;
|
||||
background-repeat: no-repeat no-repeat;
|
||||
background-position: center center;
|
||||
background-size: cover;
|
||||
background-color: var(--primary);
|
||||
|
||||
content: "";
|
||||
}
|
||||
|
||||
body {
|
||||
color: black;
|
||||
|
||||
/* Hide anything */
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
main {
|
||||
/* Flex-based footer positioning, taken from https://stackoverflow.com/a/12253099 */
|
||||
@media (min-width: 576px) {
|
||||
.hidden-no-mobile {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 576px) {
|
||||
.hidden-on-mobile {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Input with button next to it */
|
||||
.input-with-button {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
#contents {
|
||||
flex: 1;
|
||||
.input-with-button > *:first-child {
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
|
||||
margin-top: 5rem;
|
||||
margin-bottom: 5rem;
|
||||
.input-with-button > *:not(:first-child) {
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
/* Container with table of contents */
|
||||
@media (min-width: 576px) {
|
||||
.container-with-toc {
|
||||
display: grid;
|
||||
grid-template-columns: 200px auto;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 576px) {
|
||||
.container-with-toc aside {
|
||||
margin-bottom: var(--block-spacing-vertical);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Noscript */
|
||||
noscript img {
|
||||
noscript.fwd-js-notice img {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
noscript p {
|
||||
noscript.fwd-js-notice p {
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
/* Generic classes */
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.inputWithButton {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.inputWithButton > *:first-child {
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
|
||||
.inputWithButton > *:not(:first-child) {
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
|
||||
/* Header */
|
||||
header .container {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
header h1 > a {
|
||||
header a[href="."] {
|
||||
color: black;
|
||||
}
|
||||
|
||||
|
||||
/* Footer */
|
||||
footer {
|
||||
margin-bottom: 3rem;
|
||||
}
|
||||
|
||||
#footerVersion {
|
||||
footer.fwd-footer #fwd-footer-version {
|
||||
float: right;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* Base elements */
|
||||
nav {
|
||||
nav.fwd-nav {
|
||||
display: block;
|
||||
z-index: 10;
|
||||
|
||||
margin: 0;
|
||||
|
@ -7,20 +8,29 @@ nav {
|
|||
|
||||
background-color: var(--fwdekker-theme-color);
|
||||
border-bottom: 1px solid #cccccc;
|
||||
font-size: 120%;
|
||||
|
||||
--padding: calc(2em / 3);
|
||||
}
|
||||
|
||||
nav * {
|
||||
nav.fwd-nav * {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
nav a, nav a:link, nav a:visited, nav a:hover, nav a:active {
|
||||
width: 100%; /* Ensures whole li is clickable */
|
||||
nav.fwd-nav a,
|
||||
nav.fwd-nav a:link,
|
||||
nav.fwd-nav a:visited,
|
||||
nav.fwd-nav a:hover,
|
||||
nav.fwd-nav a:active {
|
||||
/* Ensures whole li is clickable */
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
nav a, nav a:link, nav a:visited, nav a:hover, nav a:active, nav #nav-hamburger-label {
|
||||
nav.fwd-nav a,
|
||||
nav.fwd-nav a:link,
|
||||
nav.fwd-nav a:visited,
|
||||
nav.fwd-nav a:hover,
|
||||
nav.fwd-nav a:active,
|
||||
nav.fwd-nav #nav-hamburger-label {
|
||||
display: inline-block;
|
||||
margin: 0;
|
||||
padding: calc(var(--padding)) calc(var(--padding));
|
||||
|
@ -29,15 +39,18 @@ nav a, nav a:link, nav a:visited, nav a:hover, nav a:active, nav #nav-hamburger-
|
|||
color: white;
|
||||
}
|
||||
|
||||
nav #nav-hamburger-label {
|
||||
nav.fwd-nav #nav-hamburger-label {
|
||||
float: right;
|
||||
font-size: unset;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
nav.fwd-nav a[target="_blank"]::after {
|
||||
margin-bottom: 0.2rem;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
|
||||
/* Logo */
|
||||
nav .logo {
|
||||
nav.fwd-nav .logo {
|
||||
width: calc(1em + var(--padding));
|
||||
height: calc(1em + var(--padding));
|
||||
|
||||
|
@ -45,21 +58,22 @@ nav .logo {
|
|||
filter: brightness(0) invert(1);
|
||||
}
|
||||
|
||||
nav div.logo {
|
||||
nav.fwd-nav div.logo {
|
||||
display: inline-block;
|
||||
margin-right: calc(1em / 3);
|
||||
}
|
||||
|
||||
|
||||
/* First level nesting */
|
||||
nav ul {
|
||||
nav.fwd-nav ul {
|
||||
display: block;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
nav ul li {
|
||||
nav.fwd-nav ul li {
|
||||
display: inline-block;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
@ -68,21 +82,21 @@ nav ul li {
|
|||
background-color: var(--fwdekker-theme-color);
|
||||
}
|
||||
|
||||
nav ul li:hover,
|
||||
nav ul li:focus-within,
|
||||
nav #nav-hamburger-label:hover,
|
||||
nav #nav-hamburger-label:focus-within {
|
||||
nav.fwd-nav ul li:hover,
|
||||
nav.fwd-nav ul li:focus-within,
|
||||
nav.fwd-nav #nav-hamburger-label:hover,
|
||||
nav.fwd-nav #nav-hamburger-label:focus-within {
|
||||
cursor: pointer;
|
||||
background-color: var(--fwdekker-theme-color-very-dark);
|
||||
}
|
||||
|
||||
nav li.currentPage {
|
||||
nav.fwd-nav li.currentPage {
|
||||
background-color: var(--fwdekker-theme-color-dark);
|
||||
}
|
||||
|
||||
|
||||
/* Second level nesting */
|
||||
nav ul li ul {
|
||||
nav.fwd-nav ul li ul {
|
||||
z-index: 11;
|
||||
|
||||
display: none;
|
||||
|
@ -90,18 +104,18 @@ nav ul li ul {
|
|||
left: 0;
|
||||
}
|
||||
|
||||
nav ul li ul li ul {
|
||||
nav.fwd-nav ul li ul li ul {
|
||||
left: 100%;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
nav ul li:hover > ul,
|
||||
nav ul li:focus-within > ul,
|
||||
nav ul li ul:hover {
|
||||
nav.fwd-nav ul li:hover > ul,
|
||||
nav.fwd-nav ul li:focus-within > ul,
|
||||
nav.fwd-nav ul li ul:hover {
|
||||
display: block;
|
||||
}
|
||||
|
||||
nav ul li ul li {
|
||||
nav.fwd-nav ul li ul li {
|
||||
min-width: 7em;
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
|
@ -109,18 +123,18 @@ nav ul li ul li {
|
|||
|
||||
|
||||
/* Hide hamburger-related elements */
|
||||
nav input[type="checkbox"] {
|
||||
nav.fwd-nav input[type="checkbox"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (min-width: 600px) {
|
||||
nav #nav-hamburger-label {
|
||||
@media (min-width: 576px) {
|
||||
nav.fwd-nav #nav-hamburger-label {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
nav input[type="checkbox"]:not(:checked) ~ ul li:not(:first-child) {
|
||||
@media (max-width: 576px) {
|
||||
nav.fwd-nav input[type="checkbox"]:not(:checked) ~ ul li:not(:first-child) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,96 +4,3 @@ select {
|
|||
-moz-appearance: menulist;
|
||||
appearance: auto;
|
||||
}
|
||||
|
||||
|
||||
/* Override Milligram color scheme, based on v1.4.1. */
|
||||
/* Replaces #9b4dca with `--fwdekker-theme-color`. */
|
||||
/* Simply look at latest unminimized Milligram release and Ctrl+F where #9b4dca occurs. */
|
||||
.button,
|
||||
button,
|
||||
input[type='button'],
|
||||
input[type='reset'],
|
||||
input[type='submit'] {
|
||||
background-color: var(--fwdekker-theme-color);
|
||||
border: 0.1rem solid var(--fwdekker-theme-color);
|
||||
}
|
||||
|
||||
.button[disabled]:focus, .button[disabled]:hover,
|
||||
button[disabled]:focus,
|
||||
button[disabled]:hover,
|
||||
input[type='button'][disabled]:focus,
|
||||
input[type='button'][disabled]:hover,
|
||||
input[type='reset'][disabled]:focus,
|
||||
input[type='reset'][disabled]:hover,
|
||||
input[type='submit'][disabled]:focus,
|
||||
input[type='submit'][disabled]:hover {
|
||||
background-color: var(--fwdekker-theme-color);
|
||||
border-color: var(--fwdekker-theme-color);
|
||||
}
|
||||
|
||||
.button.button-outline,
|
||||
button.button-outline,
|
||||
input[type='button'].button-outline,
|
||||
input[type='reset'].button-outline,
|
||||
input[type='submit'].button-outline {
|
||||
color: var(--fwdekker-theme-color);
|
||||
}
|
||||
|
||||
.button.button-outline[disabled]:focus, .button.button-outline[disabled]:hover,
|
||||
button.button-outline[disabled]:focus,
|
||||
button.button-outline[disabled]:hover,
|
||||
input[type='button'].button-outline[disabled]:focus,
|
||||
input[type='button'].button-outline[disabled]:hover,
|
||||
input[type='reset'].button-outline[disabled]:focus,
|
||||
input[type='reset'].button-outline[disabled]:hover,
|
||||
input[type='submit'].button-outline[disabled]:focus,
|
||||
input[type='submit'].button-outline[disabled]:hover {
|
||||
color: var(--fwdekker-theme-color);
|
||||
}
|
||||
|
||||
.button.button-clear,
|
||||
button.button-clear,
|
||||
input[type='button'].button-clear,
|
||||
input[type='reset'].button-clear,
|
||||
input[type='submit'].button-clear {
|
||||
color: var(--fwdekker-theme-color);
|
||||
}
|
||||
|
||||
.button.button-clear[disabled]:focus, .button.button-clear[disabled]:hover,
|
||||
button.button-clear[disabled]:focus,
|
||||
button.button-clear[disabled]:hover,
|
||||
input[type='button'].button-clear[disabled]:focus,
|
||||
input[type='button'].button-clear[disabled]:hover,
|
||||
input[type='reset'].button-clear[disabled]:focus,
|
||||
input[type='reset'].button-clear[disabled]:hover,
|
||||
input[type='submit'].button-clear[disabled]:focus,
|
||||
input[type='submit'].button-clear[disabled]:hover {
|
||||
color: var(--fwdekker-theme-color);
|
||||
}
|
||||
|
||||
pre {
|
||||
border-left: 0.3rem solid var(--fwdekker-theme-color);
|
||||
}
|
||||
|
||||
input[type='color']:focus,
|
||||
input[type='date']:focus,
|
||||
input[type='datetime']:focus,
|
||||
input[type='datetime-local']:focus,
|
||||
input[type='email']:focus,
|
||||
input[type='month']:focus,
|
||||
input[type='number']:focus,
|
||||
input[type='password']:focus,
|
||||
input[type='search']:focus,
|
||||
input[type='tel']:focus,
|
||||
input[type='text']:focus,
|
||||
input[type='url']:focus,
|
||||
input[type='week']:focus,
|
||||
input:not([type]):focus,
|
||||
textarea:focus,
|
||||
select:focus {
|
||||
border-color: var(--fwdekker-theme-color);
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--fwdekker-theme-color);
|
||||
}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
#toc {
|
||||
position: fixed;
|
||||
}
|
|
@ -82,7 +82,7 @@ const nav = function(highlightPath = "", cb = undefined) {
|
|||
});
|
||||
|
||||
const nav = stringToHtml(
|
||||
`<nav>` +
|
||||
`<nav class="fwd-nav">` +
|
||||
`<input id="nav-hamburger-checkbox" type="checkbox" hidden />` +
|
||||
`<label id="nav-hamburger-label" for="nav-hamburger-checkbox">☰</label>` +
|
||||
`</nav>`,
|
||||
|
@ -104,44 +104,24 @@ const nav = function(highlightPath = "", cb = undefined) {
|
|||
const unpackEntry = function(entry, path = "/", highlightPath = "") {
|
||||
const shouldHighlight = highlightPath.startsWith(`${path + entry.name}/`);
|
||||
const isExternalLink = !(/^https:\/\/.*fwdekker.com/.test(entry.link)) && entry.link !== "#";
|
||||
const formattedName = (isExternalLink ? "⎋ " : "") + entry.name;
|
||||
|
||||
if (entry.entries.length === 0)
|
||||
return "" +
|
||||
`<li ${shouldHighlight ? "class=\"currentPage\"" : ""}><a href="${entry.link}">${formattedName}</a></li>`;
|
||||
`<li ${shouldHighlight ? "class=\"currentPage\"" : ""}>` +
|
||||
`<a href="${entry.link}" ${isExternalLink ? "target=\"_blank\"" : ""}>${entry.name}</a>` +
|
||||
`</li>`;
|
||||
|
||||
const depth = path.split("/").length - 2; // -1 because count parts, then another -1 because of leading `/`
|
||||
const arrow = depth === 0 ? "▾" : "▸";
|
||||
|
||||
return "" +
|
||||
`<li class="${shouldHighlight ? "currentPage" : ""}">` +
|
||||
`<a href="${entry.link}">${formattedName} ${arrow}</a>` +
|
||||
`<a href="${entry.link}">${entry.name} ${arrow}</a>` +
|
||||
`<ul>${entry.entries.map(it => unpackEntry(it, `${path + entry.name}/`, highlightPath)).join("")}</ul>` +
|
||||
`</li>`;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Creates a header element with the given title and description.
|
||||
*
|
||||
* @param [title] {string} the title to display, possibly including HTML
|
||||
* @param [description] {string} the description to display, possibly including HTML
|
||||
* @returns {HTMLElement} a header element
|
||||
*/
|
||||
const header = function({title, description}) {
|
||||
if (title === undefined && description === undefined)
|
||||
return stringToHtml(`<header></header>`, "header");
|
||||
|
||||
return stringToHtml(
|
||||
`<header><section class="container">` +
|
||||
(title !== undefined ? `<h1><a href="./">${title}</a></h1>` : "") +
|
||||
(description !== undefined ? `<p><em>${description}</em></p>` : "") +
|
||||
`</section></header>`,
|
||||
"header"
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Creates a footer element with the given data.
|
||||
*
|
||||
|
@ -171,19 +151,22 @@ const footer = function(
|
|||
}) {
|
||||
if (author === undefined) author = "Florine W. Dekker";
|
||||
if (authorURL === undefined) authorURL = "https://fwdekker.com/";
|
||||
if (license === undefined) license = "MIT License";
|
||||
if (license === undefined) license = "MIT";
|
||||
if (licenseURL === undefined && vcsURL !== undefined) licenseURL = `${vcsURL}src/branch/master/LICENSE`;
|
||||
if (vcs === undefined && vcsURL !== undefined) vcs = "git";
|
||||
if (privacyPolicyURL === undefined) privacyPolicyURL = "https://fwdekker.com/privacy/";
|
||||
|
||||
return stringToHtml(
|
||||
`<footer><section class="container">` +
|
||||
`<footer class="fwd-footer">` +
|
||||
`<hr />` +
|
||||
`<small>` +
|
||||
footerLink("Made by ", author, authorURL, ". ") +
|
||||
footerLink("Licensed under the ", license, licenseURL, ". ") +
|
||||
footerLink("Source code and issue tracker on ", vcs, vcsURL, ". ") +
|
||||
footerLink("Consider reading the ", privacyPolicyURL && "privacy policy", privacyPolicyURL, ". ") +
|
||||
`<div id="footerVersion">${version || ""}</div>` +
|
||||
`</section></footer>`,
|
||||
footerLink("Licensed ", license, licenseURL, ". ") +
|
||||
footerLink("Source and support on ", vcs, vcsURL, ". ") +
|
||||
footerLink("Read the ", privacyPolicyURL && "privacy policy", privacyPolicyURL, ". ") +
|
||||
`</small>` +
|
||||
`<div id="fwd-footer-version"><small>${version || ""}</small></div>` +
|
||||
`</footer>`,
|
||||
"footer");
|
||||
};
|
||||
|
||||
|
@ -204,24 +187,13 @@ const footerLink = function(prefix, text, url, suffix) {
|
|||
|
||||
|
||||
/**
|
||||
* Runs the functions `nav`, `header`, and `footer` after the page has loaded using properties defined in the meta tags.
|
||||
* Runs the functions `nav` and `footer` after the page has loaded using properties defined in the meta tags.
|
||||
*
|
||||
* The remaining functions are invoked only if the corresponding `target` meta property is set to select an existing
|
||||
* element. The HTML element returned by the function is then added as a child to the element specified by the query
|
||||
* selector in the `target` property. The parameters to the function invocation can be set using other meta properties.
|
||||
* The format of meta properties is `fwd:<function>:<property>`, where `property` is the same as the name of the
|
||||
* parameter of that function, except that instead of camelcase words are separated by dashes. For example, `vcsURL`
|
||||
* becomes `vcs-url`.
|
||||
*
|
||||
* Meta properties can be set by including `<meta name="fwd:<function>:<property>" content="<value>" />` in the HTML
|
||||
* page on which this module is included. The `<value>` is then passed without modification as a parameter to the
|
||||
* function. Leaving out the `<value>` by writing `<meta name="fwd:<function>:property" />` instead results in passing
|
||||
* `null` as the value. Not including the meta tag at all corresponds to passing `undefined` to the function. See the
|
||||
* documentation of the respective functions for more details on the parameters that they accept.
|
||||
*
|
||||
* Note that the function is invoked only if `fwd:<function>:target` is a query selector for an existing element. This
|
||||
* means that it is possible to mix how the functions are invoked; for example, one can use meta properties to pass
|
||||
* parameters to `nav`, but also invoke `header` in a separate function manually.
|
||||
* Meta tags are read as interpreted as `<meta name="fwd:<function>:<property>" content="<value>" />` from the
|
||||
* document's head. Given a `function` of `nav` or `footer`, if the `value` of `fwd:<function>:target` is the ID of an
|
||||
* element in the page, that element is replaced by the output of `function`. The `function` is invoked with parameters
|
||||
* also read from meta elements, where each `property` is the same as the name of the parameter of that function, except
|
||||
* that instead of camelcase words are separated by dashes. For example, `vcsURL` becomes `vcs-url`.
|
||||
*/
|
||||
doAfterLoad(() => {
|
||||
const getMetaProperty = (name) => {
|
||||
|
@ -231,32 +203,30 @@ doAfterLoad(() => {
|
|||
|
||||
const navTarget = $(getMetaProperty("fwd:nav:target"));
|
||||
if (navTarget !== null) {
|
||||
navTarget.appendChild(nav(getMetaProperty("fwd:nav:highlight-path")));
|
||||
}
|
||||
|
||||
const headerTarget = $(getMetaProperty("fwd:header:target"));
|
||||
if (headerTarget !== null) {
|
||||
headerTarget.appendChild(header({
|
||||
title: getMetaProperty("fwd:header:title"),
|
||||
description: getMetaProperty("fwd:header:description"),
|
||||
}));
|
||||
navTarget.parentElement.replaceChild(
|
||||
nav(getMetaProperty("fwd:nav:highlight-path")),
|
||||
navTarget
|
||||
);
|
||||
}
|
||||
|
||||
const footerTarget = $(getMetaProperty("fwd:footer:target"));
|
||||
if (footerTarget !== null) {
|
||||
footerTarget.appendChild(footer({
|
||||
author: getMetaProperty("fwd:footer:author"),
|
||||
authorURL: getMetaProperty("fwd:footer:author-url"),
|
||||
license: getMetaProperty("fwd:footer:license"),
|
||||
licenseURL: getMetaProperty("fwd:footer:license-url"),
|
||||
vcs: getMetaProperty("fwd:footer:vcs"),
|
||||
vcsURL: getMetaProperty("fwd:footer:vcs-url"),
|
||||
version: getMetaProperty("fwd:footer:version"),
|
||||
privacyPolicyURL: getMetaProperty("fwd:footer:privacy-policy-url"),
|
||||
}));
|
||||
footerTarget.parentElement.replaceChild(
|
||||
footer({
|
||||
author: getMetaProperty("fwd:footer:author"),
|
||||
authorURL: getMetaProperty("fwd:footer:author-url"),
|
||||
license: getMetaProperty("fwd:footer:license"),
|
||||
licenseURL: getMetaProperty("fwd:footer:license-url"),
|
||||
vcs: getMetaProperty("fwd:footer:vcs"),
|
||||
vcsURL: getMetaProperty("fwd:footer:vcs-url"),
|
||||
version: getMetaProperty("fwd:footer:version"),
|
||||
privacyPolicyURL: getMetaProperty("fwd:footer:privacy-policy-url"),
|
||||
}),
|
||||
footerTarget
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Export to namespace
|
||||
window.fwdekker = {stringToHtml, $, $a, doAfterLoad, nav, header, footer};
|
||||
window.fwdekker = {stringToHtml, $, $a, doAfterLoad, nav, footer};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="en" data-theme="light">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
@ -10,85 +10,50 @@
|
|||
|
||||
<meta name="fwd:nav:target" content="#nav" />
|
||||
<meta name="fwd:nav:highlight-path" content="/Tools/Dice/" />
|
||||
<meta name="fwd:header:target" content="#header" />
|
||||
<meta name="fwd:header:title" content="Test" />
|
||||
<meta name="fwd:header:description" content="A test page" />
|
||||
<meta name="fwd:footer:target" content="#footer" />
|
||||
<meta name="fwd:footer:vcs-url" content="https://git.fwdekker.com/FWDekker/fwdekker-template/" />
|
||||
<meta name="fwd:footer:version" content="vTEST" />
|
||||
|
||||
<title>Tools | FWDekker</title>
|
||||
<title>Template test | FWDekker</title>
|
||||
|
||||
<link rel="stylesheet" href="https://static.fwdekker.com/fonts/roboto/roboto.css" />
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<link rel="stylesheet" href="../../dist/template.css" />
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
<noscript class="fwd-js-notice">
|
||||
<p>
|
||||
This website does not function if JavaScript is disabled.
|
||||
Please check the <a href="https://www.enable-javascript.com/">
|
||||
instructions on how to enable JavaScript in your web browser</a>.
|
||||
</p>
|
||||
</noscript>
|
||||
<main>
|
||||
<div id="nav"></div>
|
||||
<div id="contents">
|
||||
<div id="header"></div>
|
||||
<nav id="nav"></nav>
|
||||
<main class="container container-with-toc">
|
||||
<aside>
|
||||
<nav>
|
||||
<b class="hidden-no-mobile">Table of contents</b>
|
||||
<ul>
|
||||
<li>Item 1</li>
|
||||
<li>Item 2</li>
|
||||
</ul>
|
||||
<hr class="hidden-no-mobile" />
|
||||
</nav>
|
||||
</aside>
|
||||
<div role="document">
|
||||
<section>
|
||||
<header id="header">
|
||||
<hgroup>
|
||||
<h1><a href=".">Test</a></h1>
|
||||
<h2>A test page</h2>
|
||||
</hgroup>
|
||||
</header>
|
||||
|
||||
<section class="container">
|
||||
<div class="row">
|
||||
<div class="column column-75">
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
<p>These are some more contents.</p>
|
||||
</div>
|
||||
<div class="column column-25">
|
||||
<div id="toc">
|
||||
<p>These are a TOC</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>This <a href="./" target="_blank">is an external link</a> in a sentence.</p>
|
||||
<p>These are some more contents.</p>
|
||||
<p>These are the page contents.</p>
|
||||
</section>
|
||||
<footer id="footer"></footer>
|
||||
</div>
|
||||
<div id="footer"></div>
|
||||
</main>
|
||||
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
|
|
Loading…
Reference in New Issue