This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get the last word in a string | |
* @param {String} str The string | |
* @returns {String} The last word | |
*/ | |
function getLastWord (str) { | |
return str.trim().split(/\s+/).pop(); | |
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[redirects]] | |
from = "/:year/:month/:date/:slug" | |
to = "/blog/:slug" | |
status = 301 | |
force = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Returns a collection of blog posts in reverse date order | |
config.addCollection('blog', collection => { | |
const isLive = post => !post.data.draft && post.date <= new Date(); | |
return collection.getFilteredByGlob('./src/posts/*.md').filter(isLive).reverse(); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
layout: 'layouts/post.html', | |
eleventyComputed: { | |
permalink(data) { | |
if (!data.draft && new Date(data.date) <= new Date()) { | |
return data.permalink || '/blog/{{ title | slug }}/index.html'; | |
} | |
return false; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = config => { | |
return { | |
markdownTemplateEngine: 'njk', | |
dataTemplateEngine: 'njk', | |
htmlTemplateEngine: 'njk', | |
dir: { | |
input: 'src', | |
output: 'dist' | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add a class to an element | |
* @param {Object|String} selector A reference to an element or a CSS selector string | |
* @param {String} className The class name | |
*/ | |
function addClass (selector, className) { | |
if (selector instanceof Element) { | |
selector.classList.add(className); | |
} else if (typeof selector === "string") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Check if a string is a valid email address | |
* {@link https://gist.github.com/kieranbarker/55a12cac034c386a5b3669b991290bf6} | |
* @param {String} str The string | |
* @returns {Boolean} Whether the string is a valid email address | |
*/ | |
function isValidEmail (str) { | |
// The regular expression used by [type="email"] | |
// https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address | |
const regex = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Misc | |
*.log | |
npm-debug.* | |
*.scssc | |
*.swp | |
.DS_Store | |
Thumbs.db | |
.sass-cache | |
.env | |
.cache |