work.suroh.tk/.eleventy.js

48 lines
1.1 KiB
JavaScript
Raw Normal View History

module.exports = (config) => {
// add collection for pages
config.addCollection('pages', (collection) => {
2021-07-19 17:55:59 +00:00
let sorted = []
let unsorted = []
const pages = collection.getFilteredByGlob('**/*.md')
2021-07-19 17:55:59 +00:00
for (let page of pages) {
if (page.data.sort) {
if (sorted[page.data.sort]) {
sorted.splice(page.data.sort)
} else {
sorted[page.data.sort] = page
}
} else {
unsorted.push(page)
}
}
2021-07-19 17:55:59 +00:00
return sorted.concat(unsorted)
})
2021-07-19 17:55:59 +00:00
// custom filters
config.addFilter("makeLowercase", (value) => {
if (typeof value === 'string' || value instanceof String) {
return value.toLowerCase()
}
})
// added passthrough for global assets
config.addPassthroughCopy("assets")
// added passthrough for images in their respective folders
config.addPassthroughCopy("_content/**/images/**")
// reutrn updated config
return {
dir: {
input: "_content", // content
includes: "../_includes", // templates
output: "_site", // rendered site
data: "../_data" // global data files
}
2021-07-19 17:55:59 +00:00
}
}