109 lines
3.1 KiB
JavaScript
109 lines
3.1 KiB
JavaScript
import eleventyNavigationPlugin from "@11ty/eleventy-navigation"
|
|
import pluginRss from "@11ty/eleventy-plugin-rss"
|
|
import { eleventyImageTransformPlugin } from "@11ty/eleventy-img"
|
|
import pluginIcons from "eleventy-plugin-icons"
|
|
import { DateTime } from 'luxon'
|
|
|
|
import {
|
|
getAllPosts,
|
|
getCategoryList,
|
|
getCategorisedPosts,
|
|
} from "./config/collections.js"
|
|
|
|
import { readableDate } from "./config/filters.js"
|
|
|
|
const imageConfig = {
|
|
extensions: "html",
|
|
formats: ["webp"],
|
|
widths: [300, 600, 900, "auto"],
|
|
defaultAttributes: {
|
|
loading: "lazy",
|
|
decoding: "async",
|
|
sizes: "100vw",
|
|
},
|
|
urlPath: "/images/",
|
|
}
|
|
|
|
|
|
export default function (eleventyConfig) {
|
|
/*================================*/
|
|
/* plugins and configurations */
|
|
/*================================*/
|
|
eleventyConfig.addPlugin(eleventyNavigationPlugin)
|
|
eleventyConfig.addPlugin(pluginRss)
|
|
eleventyConfig.addPlugin(eleventyImageTransformPlugin, imageConfig)
|
|
|
|
eleventyConfig.setFrontMatterParsingOptions({
|
|
excerpt: true,
|
|
excerpt_separator: "<!-- excerpt -->",
|
|
excerpt_alias: "excerpt",
|
|
})
|
|
|
|
eleventyConfig.addPlugin(pluginIcons, {
|
|
sources: [{ name: "custom", path: "./src/assets/icons" }],
|
|
})
|
|
|
|
/*===================================================*/
|
|
/* files that need to be copied to the build folder */
|
|
/*===================================================*/
|
|
eleventyConfig.addPassthroughCopy("./src/assets/social-image.jpg")
|
|
eleventyConfig.addPassthroughCopy("./src/assets/icons")
|
|
eleventyConfig.addPassthroughCopy("./src/assets/sprite.svg")
|
|
|
|
/*=================*/
|
|
/* Layouts */
|
|
/*=================*/
|
|
eleventyConfig.addLayoutAlias("page", "layouts/page")
|
|
eleventyConfig.addLayoutAlias("article", "layouts/article")
|
|
eleventyConfig.addLayoutAlias("home", "layouts/home")
|
|
|
|
/*=================*/
|
|
/* Collections */
|
|
/*=================*/
|
|
eleventyConfig.addCollection("blog", getAllPosts)
|
|
eleventyConfig.addCollection("categoryList", getCategoryList)
|
|
eleventyConfig.addCollection("categorisedPosts", getCategorisedPosts)
|
|
eleventyConfig.addCollection("activities", (collection) => {
|
|
return collection
|
|
.getFilteredByGlob('**/activity/*.md')
|
|
.reverse();
|
|
});
|
|
/*=================*/
|
|
/* Filters */
|
|
/*=================*/
|
|
eleventyConfig.addFilter("machineDate", (dateObj) => {
|
|
return DateTime.fromJSDate(dateObj).toFormat("yyyy-MM-dd");
|
|
});
|
|
eleventyConfig.addFilter("readableDate", (dateObj) => {
|
|
return DateTime.fromJSDate(dateObj).toFormat("dd LLL yyyy");
|
|
});
|
|
eleventyConfig.addFilter("activityDate", (dateObj) => {
|
|
return DateTime.fromJSDate(dateObj).toFormat("MM.yyyy");
|
|
});
|
|
eleventyConfig.addFilter("activityYear", (dateObj) => {
|
|
return DateTime.fromJSDate(dateObj).toFormat("yyyy");
|
|
});
|
|
|
|
eleventyConfig.addFilter("cleanUrl", (url) => {
|
|
return url.replace(/^(https?:|)\/\//, "");
|
|
});
|
|
|
|
eleventyConfig.addFilter("debug", (obj) => {
|
|
console.log('debug', obj);
|
|
return `debug: ${obj?.toString() || obj}`
|
|
}
|
|
);
|
|
|
|
|
|
|
|
return {
|
|
dir: {
|
|
input: "src",
|
|
output: "_site",
|
|
includes: "_includes",
|
|
data: "_data",
|
|
},
|
|
markdownTemplateEngine: "njk",
|
|
};
|
|
}
|