parent
47f6532171
commit
68b5d33f54
|
@ -24,11 +24,3 @@ $> npm run dev:server
|
||||||
# Build the template in `dist/` for deployment
|
# Build the template in `dist/` for deployment
|
||||||
$> npm run deploy
|
$> npm run deploy
|
||||||
```
|
```
|
||||||
|
|
||||||
### Publishing
|
|
||||||
```shell script
|
|
||||||
# Log in to npm
|
|
||||||
$> npm login
|
|
||||||
# Push to npm
|
|
||||||
$> npm publish --access public
|
|
||||||
```
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"name": "@fwdekker/template",
|
"name": "@fwdekker/template",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"description": "The base template for pages on fwdekker.com.",
|
"description": "The base template for pages on fwdekker.com.",
|
||||||
"author": "Felix W. Dekker (https://fwdekker.com)",
|
"author": "Felix W. Dekker",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "https://git.fwdekker.com/FWDekker/fwdekker-template",
|
"homepage": "https://git.fwdekker.com/FWDekker/fwdekker-template",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -21,8 +21,7 @@
|
||||||
"clean": "grunt clean",
|
"clean": "grunt clean",
|
||||||
"dev": "grunt dev",
|
"dev": "grunt dev",
|
||||||
"dev:server": "grunt dev:server",
|
"dev:server": "grunt dev:server",
|
||||||
"deploy": "grunt deploy",
|
"deploy": "grunt deploy"
|
||||||
"prepare": "grunt clean deploy"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"milligram": "^1.4.1",
|
"milligram": "^1.4.1",
|
||||||
|
|
|
@ -84,7 +84,7 @@ const nav = function (highlightPath = "") {
|
||||||
*/
|
*/
|
||||||
const unpackEntry = function (entry, path = "/", highlightPath = "") {
|
const unpackEntry = function (entry, path = "/", highlightPath = "") {
|
||||||
const shouldHighlight = highlightPath.startsWith(`${path + entry.name}/`);
|
const shouldHighlight = highlightPath.startsWith(`${path + entry.name}/`);
|
||||||
const isExternalLink = !entry.link.startsWith("https://fwdekker.com/") && entry.link !== "#";
|
const isExternalLink = !entry.link.startsWith("https://fwdekker.com/") && entry.link !== "#";
|
||||||
const formattedName = (isExternalLink ? "⎋ " : "") + entry.name;
|
const formattedName = (isExternalLink ? "⎋ " : "") + entry.name;
|
||||||
|
|
||||||
if (entry.entries.length === 0)
|
if (entry.entries.length === 0)
|
||||||
|
@ -125,33 +125,43 @@ const header = function ({title, description}) {
|
||||||
/**
|
/**
|
||||||
* Creates a footer element with the given data.
|
* Creates a footer element with the given data.
|
||||||
*
|
*
|
||||||
* @param [author] {string|undefined} the author
|
* Setting an argument to `undefined` or not giving that argument will cause the default value to be used. Setting an
|
||||||
* @param [authorURL] {string|undefined} the URL to link the author's name to
|
* argument to `null` will result in a footer without the corresponding element.
|
||||||
* @param [license] {string|undefined} the type of license
|
*
|
||||||
* @param [licenseURL] {string|undefined} the URL to the license file
|
* @param [author] {string|null|undefined} the author
|
||||||
* @param [vcs] {string|undefined} the type of version control
|
* @param [authorURL] {string|null|undefined} the URL to link the author's name to
|
||||||
* @param [vcsURL] {string|undefined} the URL to the repository
|
* @param [license] {string|null|undefined} the type of license
|
||||||
* @param [version] {string|undefined} the page version
|
* @param [licenseURL] {string|null|undefined} the URL to the license file
|
||||||
* @param [privacyPolicyURL] {string|null|undefined} the URL to the privacy policy, or `null` if there should be no
|
* @param [vcs] {string|null|undefined} the type of version control
|
||||||
* privacy policy, or `undefined` if the default privacy policy should be used
|
* @param [vcsURL] {string|null|undefined} the URL to the repository
|
||||||
|
* @param [version] {string|null|undefined} the page version
|
||||||
|
* @param [privacyPolicyURL] {string|null|undefined} the URL to the privacy policy
|
||||||
* @returns {HTMLElement} a footer element
|
* @returns {HTMLElement} a footer element
|
||||||
*/
|
*/
|
||||||
const footer = function (
|
const footer = function (
|
||||||
{
|
{
|
||||||
author, authorURL, license, licenseURL, vcs, vcsURL, version,
|
author = undefined,
|
||||||
|
authorURL = undefined,
|
||||||
|
license = undefined,
|
||||||
|
licenseURL = undefined,
|
||||||
|
vcs = undefined,
|
||||||
|
vcsURL = undefined,
|
||||||
|
version = undefined,
|
||||||
privacyPolicyURL = undefined
|
privacyPolicyURL = undefined
|
||||||
}) {
|
}) {
|
||||||
|
if (author === undefined) author = "F.W. Dekker";
|
||||||
|
if (authorURL === undefined) authorURL = "https://fwdekker.com/";
|
||||||
|
if (license === undefined) license = "MIT License";
|
||||||
|
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(
|
return stringToHtml(
|
||||||
`<footer class="footer"><section class="container">` +
|
`<footer class="footer"><section class="container">` +
|
||||||
footerLink("Made by ", author, authorURL, ". ") +
|
footerLink("Made by ", author, authorURL, ". ") +
|
||||||
footerLink("Licensed under the ", license, licenseURL, ". ") +
|
footerLink("Licensed under the ", license, licenseURL, ". ") +
|
||||||
footerLink("Source code available on ", vcs, vcsURL, ". ") +
|
footerLink("Source code available on ", vcs, vcsURL, ". ") +
|
||||||
footerLink(
|
footerLink("Consider reading the ", privacyPolicyURL && "privacy policy", privacyPolicyURL, ". ") +
|
||||||
"Consider reading the ",
|
|
||||||
privacyPolicyURL === null ? undefined : "privacy policy",
|
|
||||||
privacyPolicyURL === undefined ? "https://fwdekker.com/privacy/" : privacyPolicyURL,
|
|
||||||
". "
|
|
||||||
) +
|
|
||||||
`<div style="float: right;">${version || ""}</div>` +
|
`<div style="float: right;">${version || ""}</div>` +
|
||||||
`</section></footer>`,
|
`</section></footer>`,
|
||||||
"footer");
|
"footer");
|
||||||
|
@ -161,15 +171,15 @@ const footer = function (
|
||||||
* Constructs a link that is used in footers.
|
* Constructs a link that is used in footers.
|
||||||
*
|
*
|
||||||
* @param prefix {string} the text to display before the text if the text is not undefined
|
* @param prefix {string} the text to display before the text if the text is not undefined
|
||||||
* @param text {string|undefined} the text to display, or `undefined` if the returned element should be empty
|
* @param text {string|null} the text to display, or `null` if the returned element should be empty
|
||||||
* @param url {string|undefined} the URL to link the text to, or `undefined` if the text should not be a link
|
* @param url {string|null} the URL to link the text to, or `null` if the text should not be a link
|
||||||
* @param suffix {string} the text to display after the text if the text is not undefined
|
* @param suffix {string} the text to display after the text if the text is not undefined
|
||||||
* @returns {string} a footer link element
|
* @returns {string} a footer link element
|
||||||
*/
|
*/
|
||||||
const footerLink = function (prefix, text, url, suffix) {
|
const footerLink = function (prefix, text, url, suffix) {
|
||||||
if (text === undefined) return "";
|
if (text === null) return "";
|
||||||
|
|
||||||
return `${prefix}${url !== undefined ? `<a href="${url}">${text}</a>` : text}${suffix}`;
|
return `${prefix}${url !== null ? `<a href="${url}">${text}</a>` : text}${suffix}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue