This file contains 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
/** | |
* Escape double and single quotes inside a string | |
* @param {String} string The string | |
* @returns {String} The string with quotes escaped | |
*/ | |
function escapeQuotes (string) { | |
return string.replace(/"/g, """).replace(/'/g, "'"); | |
} |
This file contains 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 |
This file contains 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 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 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 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 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 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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(); | |
} |
OlderNewer