-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
18,145 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// 11ty configuration | ||
const dev = (global.dev = process.env.ELEVENTY_ENV === "development"), | ||
now = new Date(); | ||
|
||
module.exports = (config) => { | ||
/* --- PLUGINS --- */ | ||
// navigation | ||
config.addPlugin(require("@11ty/eleventy-navigation")); | ||
|
||
/* --- TRANSFORMS -- */ | ||
// inline assets | ||
config.addTransform("inline", require("./lib/transforms/inline")); | ||
// minify HTML | ||
config.addTransform("htmlminify", require("./lib/transforms/htmlminify")); | ||
// CSS processing | ||
config.addTransform("postcss", require("./lib/transforms/postcss")); | ||
|
||
/* --- FILTERS --- */ | ||
// format dates | ||
const dateformat = require("./lib/filters/dateformat"); | ||
config.addFilter("datefriendly", dateformat.friendly); | ||
config.addFilter("dateymd", dateformat.ymd); | ||
// format word count and reading time | ||
config.addFilter("readtime", require("./lib/filters/readtime")); | ||
|
||
/* --- SHORTCODES --- */ | ||
// page navigation | ||
config.addShortcode("navlist", require("./lib/shortcodes/navlist.js")); | ||
|
||
/* --- CUSTOM COLLECTIONS --- */ | ||
// post collection (in src/episodes) | ||
config.addCollection("post", (collection) => | ||
collection | ||
.getFilteredByGlob("./src/episodes/*.md") | ||
.filter((p) => dev || (!p.data.draft && p.date <= now)) | ||
); | ||
|
||
/* --- WATCH FOLDERS --- */ | ||
config.addWatchTarget("./src/scss/"); | ||
config.addWatchTarget("./src/js/"); | ||
|
||
// 11ty defaults | ||
return { | ||
dir: { | ||
input: "src", | ||
output: "build", | ||
}, | ||
}; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build | ||
node_modules |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Craig Buckler | ||
|
||
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. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Working Code Podcast | ||
|
||
https://workingcode.dev | ||
|
||
Built with [Eleventy](https://www.11ty.dev/). | ||
|
||
--- | ||
|
||
Based on: https://github.com/craigbuckler/11ty-starter | ||
|
||
## Development | ||
|
||
`$ npm start` and navigate to http://localhost:8080 | ||
|
||
## Production | ||
|
||
`npm run production` outputs to `./build` as the hosting root. |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// date formatting functions | ||
const toMonth = new Intl.DateTimeFormat('en', { month: 'long' }); | ||
|
||
|
||
// format a date to YYYY-MM-DD | ||
module.exports.ymd = date => ( | ||
|
||
date instanceof Date ? | ||
`${ date.getUTCFullYear() }-${ String(date.getUTCMonth() + 1).padStart(2, '0') }-${ String(date.getUTCDate()).padStart(2, '0') }` : '' | ||
|
||
); | ||
|
||
|
||
// format a date to DD MMMM, YYYY | ||
module.exports.friendly = date => ( | ||
|
||
date instanceof Date ? | ||
date.getUTCDate() + ' ' + toMonth.format(date) + ', ' + date.getUTCFullYear() : '' | ||
|
||
); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// format number of words and reading time | ||
const | ||
roundTo = 10, | ||
readPerMin = 200, | ||
numFormat = new Intl.NumberFormat('en'); | ||
|
||
module.exports = count => { | ||
|
||
const | ||
words = Math.ceil(count / roundTo) * roundTo, | ||
mins = Math.ceil(count / readPerMin); | ||
|
||
return `${ numFormat.format(words) } words, ${ numFormat.format(mins) }-minute read`; | ||
|
||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// generates a page navigation list | ||
const | ||
listType = 'ul', | ||
elementActive = 'strong', | ||
classActive = 'active', | ||
classOpen = 'open'; | ||
|
||
// pass in collections.all | eleventyNavigation, (current) page, and maximum depth level | ||
module.exports = (pageNav, page, maxLevel = 999) => { | ||
|
||
function navRecurse(entry, level = 1) { | ||
|
||
let childPages = ''; | ||
|
||
if (level < maxLevel) { | ||
for (let child of entry.children) { | ||
childPages += navRecurse(child, level++); | ||
} | ||
} | ||
|
||
let | ||
active = (entry.url === page.url), | ||
classList = []; | ||
|
||
if ((active && childPages) || childPages.includes(`<${ elementActive }>`)) classList.push(classOpen); | ||
if (active) classList.push(classActive); | ||
|
||
return ( | ||
'<li' + | ||
(classList.length ? ` class="${ classList.join(' ') }"` : '') + | ||
'>' + | ||
(active ? `<${ elementActive }>` : `<a href="${ entry.url }">`) + | ||
entry.title + | ||
(active ? `</${ elementActive }>` : '</a>') + | ||
(childPages ? `<${ listType }>${ childPages }</${ listType }>` : '') + | ||
'</li>' | ||
); | ||
|
||
} | ||
|
||
let nav = ''; | ||
for (let entry of pageNav) { | ||
nav += navRecurse(entry); | ||
} | ||
|
||
return `<${ listType }>${ nav }</${ listType }>`; | ||
|
||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// minify HTML | ||
const htmlmin = require('html-minifier'); | ||
|
||
module.exports = (content, outputPath = '.html') => { | ||
|
||
if (!String(outputPath).endsWith('.html')) return content; | ||
|
||
return htmlmin.minify(content, { | ||
useShortDoctype: true, | ||
removeComments: true, | ||
collapseWhitespace: true | ||
}); | ||
|
||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// inline data | ||
const { inlineSource } = require('inline-source'); | ||
|
||
module.exports = async (content, outputPath) => { | ||
|
||
if (!String(outputPath).endsWith('.html')) return content; | ||
|
||
return await inlineSource(content, { | ||
compress: true, | ||
rootpath: './build/' | ||
}); | ||
|
||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// PostCSS CSS processing | ||
|
||
/* global dev */ | ||
|
||
const | ||
postcss = require('postcss'), | ||
postcssPlugins = [ | ||
require('postcss-advanced-variables'), | ||
require('postcss-nested'), | ||
require('cssnano') | ||
], | ||
postcssOptions = { | ||
from: 'src/scss/entry.scss', | ||
syntax: require('postcss-scss'), | ||
map: dev ? { inline: true } : false | ||
}; | ||
|
||
module.exports = async (content, outputPath) => { | ||
|
||
if (!String(outputPath).endsWith('.css')) return content; | ||
|
||
return ( | ||
await postcss(postcssPlugins).process(content, postcssOptions) | ||
).css; | ||
|
||
}; |
Oops, something went wrong.