Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial eleventy build - WIP #26

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy({'web/dist/fonts': "fonts"})
eleventyConfig.addPassthroughCopy({'web/dist/images': "images"})
eleventyConfig.addPassthroughCopy({'web/dist/js': "js"})
eleventyConfig.addPassthroughCopy({'web/dist/styles': "styles"})
eleventyConfig.addPassthroughCopy({'web/dist/svg': "svg"})

// Enable custom order in site navigation
eleventyConfig.addCollection("navItems", function (collection) {
return collection.getAll().filter((item) => item.data.navItem)
.sort((a, b) => b.data.navOrder - a.data.navOrder);
})

// Inject nunjucks macro import for components into top level Markdown files
eleventyConfig.addCollection('rootfiles', function (collection) {
const macroImport = `{% from "./_includes/system/components.njk" import pageComponents %}`;
let topLevelCollection = collection.getAll().filter((item) => item.data.root);

topLevelCollection.forEach((item) => {
item.template.frontMatter.content = `${macroImport}\n${item.template.frontMatter.content}`;
})

return topLevelCollection;
})

// Inject nunjucks macro import for components in section-specific Markdown files
eleventyConfig.addCollection('subpages', function (collection) {
const macroImport = `{% from "../_includes/system/components.njk" import pageComponents %}`;
let subPageCollection = collection.getAll().filter((item) => item.data.subpage);

subPageCollection.forEach((item) => {
item.template.frontMatter.content = `${macroImport}\n${item.template.frontMatter.content}`;
})

return subPageCollection;
})
return {
passthroughFileCopy: true,
markdownTemplateEngine: "njk",
dir: {
input: "web/amplify/eleventy",
output: "web/eleventy-dist",
layout: "templates/page.njk"
}
}
}
Loading