-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from AristurtleDev/convert-to-11ty
Convert Site Generator to 11ty
- Loading branch information
Showing
292 changed files
with
7,374 additions
and
3,508 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,29 @@ | ||
# **/.config/** Directory | ||
This directory contains all of the configurations setup for 11ty. 11ty can have various configurations such as which files to ignore, which files to watch, which files to copy only and not process, etc. | ||
|
||
Reference: https://www.11ty.dev/docs/config/ | ||
|
||
Instead of creating a single monolithic configuration file, each of these possible configurations are broken down into their own files in this directory. | ||
|
||
When a specific configuration relies on an external module or plug-in that has been created, that module lives inside of a directory named after the configuration type it is for. For example. 11ty `Filter`s that have been created live inside the `/_config/filters` directory. | ||
|
||
The following table is a demonstration of how the files and directories contained here are structured: | ||
|
||
| File/Directory Name | Description | Reference | | ||
| ------------------------------------- | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | | ||
| eleventy.config.**collections**.js | Contains the 11ty configuration for all collections added | https://www.11ty.dev/docs/collections/ | | ||
| eleventy.config.**dataExtensions**.js | Contains the 11ty configuration logic for all data extensions. | https://www.11ty.dev/docs/data-custom/ | | ||
| eleventy.config.**filters**.js | Contains the 11ty configuration logic for all custom template filters. | https://www.11ty.dev/docs/filters/ | | ||
| eleventy.config.**ignores**.js | Contains the 11ty configuration for all file ignore logic. | https://www.11ty.dev/docs/ignores/ | | ||
| eleventy.config.**libraries**.js | Contains the 11ty configuration logic for all libraries used in 11ty. | https://www.11ty.dev/docs/languages/markdown/#add-your-own-plugins | | ||
| eleventy.config.**passthrough**.js | Contains the 11ty configuration logic for all file pass through copies. | https://www.11ty.dev/docs/copy/ | | ||
| eleventy.config.**plugins**.js | Contains the 11ty configuration for all 11ty plugins used. | https://www.11ty.dev/docs/plugins/#add-the-plugin-to-eleventy-in-your-config-file | | ||
| eleventy.config.**transforms**.js | Contains the 11ty configuration for all transforms. | https://www.11ty.dev/docs/config/#transforms | | ||
| eleventy.config.**watchtargets**.js | Contains the 11ty configuration for all watch targets during development. | https://www.11ty.dev/docs/watch-serve/#add-your-own-watch-targets | | ||
| **/collections/** | Each file contains the logic to build the data for that specific collection | | | ||
| **/filters/** | Each file contains the logic to handle that specific filter. | | | ||
| **/markdownit-plugins/** | Custom plugins written for the markdown-it markdown renderer to handle difference scenarios. | | | ||
| **/transforms/** | Each file contains the transform logic used to transform input data before it is output. | | | ||
|
||
|
||
This directory also contains the `dotnet-tools.json` manifest file for the dotnet tools installation. |
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,62 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const yaml = require('js-yaml'); | ||
|
||
function filterElementsWithoutHref(element) { | ||
if (!element || !element.hasOwnProperty('href')) { | ||
return true; | ||
} | ||
|
||
if (element.items) { | ||
element.items = element.items.filter((item) => !filterElementsWithoutHref(item)); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
function removeMDExtension(json) { | ||
json.forEach((element) => { | ||
if (element.href) { | ||
element.href = element.href.replace(/\.md$/, ''); | ||
} | ||
|
||
if (element.items) { | ||
element.items.forEach((item) => { | ||
if (item.href) { | ||
item.href = item.href.replace(/\.md$/, ''); | ||
} | ||
}); | ||
removeMDExtension(element.items); | ||
} | ||
}); | ||
} | ||
|
||
function sortElements(elements) { | ||
elements.forEach((element) => { | ||
if (element.items) { | ||
element.items.sort((a, b) => a.name.localeCompare(b.name)); | ||
sortElements(element.items); | ||
} | ||
}); | ||
} | ||
|
||
/** @param {import("@11ty/eleventy/src/TemplateCollection")} api */ | ||
function apiToc(api) { | ||
try { | ||
const data = fs.readFileSync('./content/api/toc.yml', 'utf-8'); | ||
let json = yaml.load(data); | ||
json = json.filter((element) => !filterElementsWithoutHref(element)); | ||
removeMDExtension(json); | ||
sortElements(json); | ||
return json; | ||
} catch (err) { | ||
console.warn("'/content/api/toc.yml' is missing. API documentation will not be generated"); | ||
console.warn("If you wanted to include API documentation in your local build run the following command"); | ||
console.warn("npm run docfx"); | ||
console.warn("Note: including API documentation in local builds may increase build times"); | ||
return []; | ||
} | ||
} | ||
|
||
module.exports = apiToc; |
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 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const yaml = require('js-yaml'); | ||
|
||
/** @param {import("@11ty/eleventy/src/TemplateCollection")} api */ | ||
function articlesToc(api) { | ||
try { | ||
const data = fs.readFileSync('./content/articles/toc.yml', 'utf-8'); | ||
return yaml.load(data); | ||
} catch(err) { | ||
console.error(err); | ||
return []; | ||
} | ||
} | ||
|
||
module.exports = articlesToc; |
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,8 @@ | ||
'use strict' | ||
|
||
/** @param {import("@11ty/eleventy/src/TemplateCollection")} api */ | ||
function blogPosts(api) { | ||
return api.getFilteredByGlob('./content/blog/*.md').sort((a, b) => a.date - b.date); | ||
} | ||
|
||
module.exports = blogPosts; |
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,18 @@ | ||
'use strict'; | ||
|
||
/** @param {import("@11ty/eleventy/src/TemplateCollection")} api */ | ||
function blogTags(api) { | ||
let tags = []; | ||
let posts = api.getFilteredByGlob('./content/blog/*.md'); | ||
|
||
posts.forEach((post) => { | ||
if(post.data.tags) { | ||
tags.push(...post.data.tags); | ||
} | ||
}); | ||
|
||
tags = tags.filter((value, index) => tags.indexOf(value) === index).sort(); | ||
return ['all'].concat(tags); | ||
} | ||
|
||
module.exports = blogTags; |
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,19 @@ | ||
'use strict'; | ||
|
||
const games = require('../../_data/games.json'); | ||
|
||
/** @param {import("@11ty/eleventy/src/TemplateCollection")} api */ | ||
function gameTags(api) { | ||
let tags = []; | ||
|
||
games.forEach((game) => { | ||
if(game.tags) { | ||
tags.push(...game.tags); | ||
} | ||
}); | ||
|
||
tags = tags.filter((value, index) => tags.indexOf(value) === index).sort(); | ||
return ['all'].concat(tags); | ||
} | ||
|
||
module.exports = gameTags; |
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
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 @@ | ||
'use strict' | ||
|
||
const blogPosts = require('./collections/blogPosts'); | ||
const blogTags = require('./collections/blogTags'); | ||
const gameTags = require('./collections/gameTags'); | ||
const apiToc = require('./collections/apiToc'); | ||
const articlesToc = require('./collections/articlesToc'); | ||
|
||
|
||
/** @param {import("@11ty/eleventy").UserConfig} config */ | ||
module.exports = function (config) { | ||
config.addCollection('blogPosts', blogPosts); | ||
config.addCollection('blogTags', blogTags); | ||
config.addCollection('gameTags', gameTags); | ||
config.addCollection('apiToc', apiToc); | ||
config.addCollection('articlesToc', articlesToc); | ||
} |
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,10 @@ | ||
'use strict' | ||
|
||
const yaml = require('js-yaml'); | ||
|
||
/** @param {import("@11ty/eleventy").UserConfig} config */ | ||
module.exports = function (config) { | ||
config.addDataExtension('yml', function (content) { | ||
return yaml.load(content); | ||
}); | ||
} |
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,18 @@ | ||
'use strict' | ||
|
||
const readableDate = require('./filters/readableDate'); | ||
const htmlDateString = require('./filters/htmlDateString'); | ||
const tableOfContents = require('./filters/tableOfContents'); | ||
const cssmin = require('./filters/cssmin'); | ||
|
||
/** @param {import("@11ty/eleventy").UserConfig} config */ | ||
module.exports = function (config) { | ||
// Convert date values into human readable dates | ||
config.addFilter('readableDate', readableDate); | ||
config.addFilter('htmlDateString', htmlDateString); | ||
|
||
// Creates a table of contents based on a given toc collection | ||
config.addFilter('tableOfContents', tableOfContents); | ||
|
||
config.addFilter('cssmin', cssmin); | ||
} |
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,6 @@ | ||
/** @param {import("@11ty/eleventy").UserConfig} config */ | ||
module.exports = function(config) { | ||
config.setUseGitIgnore(false); | ||
config.ignores.add('./public/css/**/*.css'); | ||
config.ignores.add('./public/js/**/*.js'); | ||
} |
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,24 @@ | ||
'use strict' | ||
|
||
const mdAnchor = require('markdown-it-anchor'); | ||
const mdLink = require('./markdownit-plugins/link'); | ||
const mdAdmonitions = require('./markdownit-plugins/admonitions'); | ||
|
||
/** @param {import("@11ty/eleventy").UserConfig} config */ | ||
module.exports = function (config) { | ||
config.amendLibrary('md', md => md.use(mdAnchor, { | ||
slugify: (s) => config.getFilter('slugify')(s.replace(/\d+/g, '')), | ||
permalink: mdAnchor.permalink.headerLink() | ||
})); | ||
|
||
// Setup external links to open in new tab | ||
config.amendLibrary('md', md => md.use(mdLink, {eleventyConfig: config})); | ||
|
||
// Setup admonition support | ||
config.amendLibrary('md', md => md.use(mdAdmonitions)); | ||
|
||
// Setup tables to be formatted by default using bootstrap styling | ||
config.amendLibrary('md', md => md.use((m) => { | ||
m.renderer.rules.table_open = (tokens, id) => '<table class="table table-bordered table-condensed">'; | ||
})); | ||
} |
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 @@ | ||
'use strict' | ||
|
||
/** @param {import("@11ty/eleventy").UserConfig} config */ | ||
module.exports = function (config) { | ||
config.addPassthroughCopy({ "static": "/" }); | ||
config.addPassthroughCopy('content/articles/**/*.{png, jpg, jpeg}'); | ||
config.addPassthroughCopy('content/blog/**/*.{png, jpg, jpeg}'); | ||
config.addPassthroughCopy({ "content/public/images": "/images" }); | ||
config.addPassthroughCopy({ "content/static/**/*": "/"}); | ||
config.addPassthroughCopy({ "content/public/js/**/*.js": "/js" }); | ||
config.addPassthroughCopy({ | ||
"node_modules/bootstrap-icons/font/fonts": "/fonts" | ||
}); | ||
config.addPassthroughCopy({ | ||
"node_modules/bootstrap/dist/js/bootstrap.bundle.min.js": "/js/bootstrap.bundle.min.js" | ||
}); | ||
} |
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 @@ | ||
'use strict' | ||
const navigation = require('@11ty/eleventy-navigation'); | ||
const syntaxhighlight = require('@11ty/eleventy-plugin-syntaxhighlight'); | ||
const nesting = require('eleventy-plugin-nesting-toc'); | ||
const { EleventyHtmlBasePlugin } = require('@11ty/eleventy'); | ||
|
||
|
||
/** @param {import("@11ty/eleventy").UserConfig} config */ | ||
module.exports = function (config) { | ||
config.addPlugin(navigation); | ||
config.addPlugin(syntaxhighlight); | ||
config.addPlugin(nesting, { | ||
tags: ['h2', 'h3'], | ||
wrapper: 'nav', | ||
wrapperClass: 'nav flex-column', | ||
headingText: 'In This Article', | ||
headingTag: 'h5' | ||
}); | ||
config.addPlugin(EleventyHtmlBasePlugin); | ||
} |
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 @@ | ||
'use strict' | ||
|
||
const xref = require('./transforms/xref'); | ||
|
||
/** @param {import("@11ty/eleventy").UserConfig} config */ | ||
module.exports = function (config) { | ||
config.addTransform('xref', function(content) { | ||
if(this.page.inputPath.includes('.md') && this.page.outputPath.endsWith('.html')) { | ||
return xref(content); | ||
} | ||
return content; | ||
}); | ||
} |
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,6 @@ | ||
/** @param {import("@11ty/eleventy").UserConfig} config */ | ||
module.exports = function(config) { | ||
config.addWatchTarget('./content/public/css/**/*.css'); | ||
config.addWatchTarget('./content/public/js/**/*.js'); | ||
config.addWatchTarget('./content/public/images/**/*'); | ||
} |
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,9 @@ | ||
'use strict'; | ||
|
||
const cleanCss = require("clean-css"); | ||
|
||
function cssmin(css) { | ||
return new cleanCss({}).minify(css).styles; | ||
} | ||
|
||
module.exports = cssmin; |
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,7 @@ | ||
'use strict'; | ||
|
||
const { DateTime } = require('luxon'); | ||
|
||
module.exports = function(date) { | ||
return DateTime.fromJSDate(date, {zone: 'utc'}).toFormat('yyyy-LL-dd'); | ||
} |
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,7 @@ | ||
'use strict'; | ||
|
||
const { DateTime } = require('luxon'); | ||
|
||
module.exports = function(date) { | ||
return DateTime.fromJSDate(date).toLocaleString(DateTime.DATE_MED); | ||
} |
Oops, something went wrong.