Set up basic template

This commit is contained in:
Florine W. Dekker 2020-05-02 23:02:42 +02:00
commit d7315ceffe
Signed by: FWDekker
GPG Key ID: B1B567AF58D6EE0F
8 changed files with 237 additions and 0 deletions

11
.editorconfig Normal file
View File

@ -0,0 +1,11 @@
root = true
[*]
charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
package-lock.json binary

120
.gitignore vendored Normal file
View File

@ -0,0 +1,120 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.pnp.*
## Custom
build/

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Felix W. Dekker
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# FWDekker Template
The template used on many pages on fwdekker.com.

BIN
package-lock.json generated Normal file

Binary file not shown.

19
package.json Normal file
View File

@ -0,0 +1,19 @@
{
"name": "@fwdekker/template",
"version": "0.0.5",
"description": "The template used on many pages on fwdekker.com.",
"author": "Felix W. Dekker (https://fwdekker.com)",
"license": "MIT",
"homepage": "https://git.fwdekker.com/FWDekker/fwdekker-template",
"repository": {
"type": "git",
"url": "git@git.fwdekker.com:FWDekker/fwdekker-template.git"
},
"bugs": {
"url": "https://git.fwdekker.com/FWDekker/fwdekker-template/issues"
},
"main": "src/main/js/Template.js",
"dependencies": {
"hyperscript": "^2.0.2"
}
}

63
src/main/js/Template.js Normal file
View File

@ -0,0 +1,63 @@
const h = require("hyperscript");
/**
* Creates a header element with the given title and description.
*
* @param title {string} the title to display
* @param description {string} the description to display
* @returns {HTMLElement} a header element
*/
exports.header = function ({title, description}) {
return h("header.header",
h("section.container",
h("h1", title),
h("p", h("em", description))
)
);
}
/**
* Creates a footer element with the given data.
*
* @param [author] {string} the author
* @param [authorURL] {string} the URL to link the author's name to
* @param [license] {string} the type of license
* @param [licenseURL] {string} the URL to the license file
* @param [vcs] {string} the type of version control
* @param [vcsURL] {string} the URL to the repository
* @param [version] {string} the page version
* @returns {HTMLElement} a footer element
*/
exports.footer = function ({author, authorURL, license, licenseURL, vcs, vcsURL, version}) {
return h("footer.footer",
h("section.container",
footerLink("Made by ", author, authorURL, ". "),
footerLink("Licensed under the ", license, licenseURL, ". "),
footerLink("Source code available on ", vcs, vcsURL, ". "),
h("div", version || "", {style: {"float": "right"}})
)
);
}
/**
* 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 text {string|undefined} the text to display, or `undefined` 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 suffix {string} the text to display after the text if the text is not undefined
* @returns {HTMLElement} a footer link element
*/
const footerLink = function (prefix, text, url, suffix) {
if (text === undefined) return h("span");
return h("span",
h("span", prefix),
url !== undefined
? h("a", text, {href: url})
: h("span", text),
h("span", suffix)
);
}