Restructure eleventy config

This commit is contained in:
Neil Brommer 2023-07-13 14:31:21 -07:00
parent 2a855f4801
commit f4086ae739

View file

@ -1,25 +1,14 @@
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation"); const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
const eleventySyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight"); const eleventySyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const eleventySass = require("eleventy-sass"); const eleventySass = require("eleventy-sass");
const eleventyRss = require("@11ty/eleventy-plugin-rss");
const eleventyDrafts = require("./eleventy.config.drafts");
const mdDefList = require("markdown-it-deflist"); const mdDefList = require("markdown-it-deflist");
const mdToc = require("markdown-it-table-of-contents"); const mdToc = require("markdown-it-table-of-contents");
const mdAnchor = require("markdown-it-anchor"); const mdAnchor = require("markdown-it-anchor");
const eleventyRss = require("@11ty/eleventy-plugin-rss");
const eleventyDrafts = require("./eleventy.config.drafts");
const nunjucksDate = require("nunjucks-date"); const nunjucksDate = require("nunjucks-date");
module.exports = function (eleventyConfig) { function addEleventyPlugins(eleventyConfig) {
eleventyConfig.setBrowserSyncConfig({
files: "./_site/css/**/*.css",
});
eleventyConfig.addPassthroughCopy({
"node_modules/prism-themes/themes/prism-material-light.min.css":
"css/prism-material-light.min.css",
"node_modules/prism-themes/themes/prism-material-oceanic.min.css":
"css/prism-material-oceanic.min.css",
"node_modules/feather-icons/dist/feather-sprite.svg": "images/feather-sprite.svg",
"src/js/site.js": "js/site.js"
});
eleventyConfig.addPlugin(eleventyNavigationPlugin); eleventyConfig.addPlugin(eleventyNavigationPlugin);
eleventyConfig.addPlugin(eleventySyntaxHighlight); eleventyConfig.addPlugin(eleventySyntaxHighlight);
eleventyConfig.addPlugin(eleventyRss); eleventyConfig.addPlugin(eleventyRss);
@ -29,13 +18,19 @@ module.exports = function (eleventyConfig) {
loadPaths: ["node_modules"], loadPaths: ["node_modules"],
}, },
}); });
}
function configureMarkdown(eleventyConfig) {
eleventyConfig.amendLibrary("md", mdLib => mdLib eleventyConfig.amendLibrary("md", mdLib => mdLib
.use(mdDefList) .use(mdDefList)
.use(mdToc, { .use(mdToc, {
includeLevel: [ 1, 2, 3, 4, 5, 6 ] includeLevel: [ 1, 2, 3, 4, 5, 6 ]
}) })
.use(mdAnchor)); .use(mdAnchor));
}
function addFilters(eleventyConfig) {
eleventyConfig.addFilter("log", (value) => console.log(value));
eleventyConfig.addFilter("date", nunjucksDate); eleventyConfig.addFilter("date", nunjucksDate);
eleventyConfig.addFilter("IsNotPage", (collection, url) => eleventyConfig.addFilter("IsNotPage", (collection, url) =>
collection.filter(item => item.url != url)); collection.filter(item => item.url != url));
@ -56,7 +51,25 @@ module.exports = function (eleventyConfig) {
return true; return true;
}); });
}); });
eleventyConfig.addFilter("log", (value) => console.log(value)); }
module.exports = function (eleventyConfig) {
eleventyConfig.setBrowserSyncConfig({
files: "./_site/css/**/*.css",
});
eleventyConfig.addPassthroughCopy({
"node_modules/prism-themes/themes/prism-material-light.min.css":
"css/prism-material-light.min.css",
"node_modules/prism-themes/themes/prism-material-oceanic.min.css":
"css/prism-material-oceanic.min.css",
"node_modules/feather-icons/dist/feather-sprite.svg": "images/feather-sprite.svg",
"src/js/site.js": "js/site.js"
});
addEleventyPlugins(eleventyConfig);
configureMarkdown(eleventyConfig);
addFilters(eleventyConfig);
return { return {
dir: { dir: {