2024-05-06 10:43:37 +00:00
|
|
|
// Installed Plugins
|
2024-04-11 12:18:03 +00:00
|
|
|
const pluginRss = require("@11ty/eleventy-plugin-rss");
|
2024-04-18 12:22:49 +00:00
|
|
|
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
|
2024-04-11 12:17:11 +00:00
|
|
|
const metagen = require('eleventy-plugin-metagen');
|
2024-04-13 07:00:22 +00:00
|
|
|
const emojiReadTime = require("@11tyrocks/eleventy-plugin-emoji-readtime");
|
2024-04-12 17:54:48 +00:00
|
|
|
|
2024-04-06 04:15:14 +00:00
|
|
|
module.exports = function (eleventyConfig) {
|
2024-04-11 12:16:05 +00:00
|
|
|
// Copy files
|
2024-04-06 04:15:14 +00:00
|
|
|
eleventyConfig.addPassthroughCopy("./src/assets/");
|
|
|
|
eleventyConfig.addWatchTarget("./src/assets/");
|
|
|
|
|
2024-05-06 17:01:15 +00:00
|
|
|
// Custom Plugins
|
|
|
|
eleventyConfig.addPlugin(require('./eleventy.config.md.js'));
|
|
|
|
|
|
|
|
// Installed Plugins
|
2024-04-11 12:18:03 +00:00
|
|
|
eleventyConfig.addPlugin(pluginRss);
|
2024-04-18 12:22:49 +00:00
|
|
|
eleventyConfig.addPlugin(eleventyNavigationPlugin);
|
2024-04-11 12:17:11 +00:00
|
|
|
eleventyConfig.addPlugin(metagen);
|
2024-04-13 07:00:22 +00:00
|
|
|
eleventyConfig.addPlugin(emojiReadTime);
|
2024-04-12 17:54:48 +00:00
|
|
|
|
2024-04-16 09:20:34 +00:00
|
|
|
// Add content categories to a collection
|
|
|
|
eleventyConfig.addCollection("categories", function(collectionApi) {
|
|
|
|
let categories = new Set();
|
2024-04-16 14:07:58 +00:00
|
|
|
let contents = collectionApi.getFilteredByTag('contents');
|
2024-04-16 09:20:34 +00:00
|
|
|
contents.forEach(p => {
|
|
|
|
let cats = p.data.categories;
|
|
|
|
cats.forEach(c => categories.add(c));
|
|
|
|
});
|
|
|
|
return Array.from(categories).sort();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Filter contents by category
|
|
|
|
eleventyConfig.addFilter("filterByCategory", function(contents, cat) {
|
|
|
|
cat = cat.toLowerCase();
|
|
|
|
let result = contents.filter(item => {
|
|
|
|
let cats = item.data.categories.map(c => c.toLowerCase());
|
|
|
|
return cats.includes(cat);
|
|
|
|
});
|
|
|
|
return result;
|
|
|
|
});
|
|
|
|
|
2024-04-15 10:21:10 +00:00
|
|
|
// Filter: Format dates
|
|
|
|
const dateOptions = {
|
|
|
|
year: 'numeric',
|
|
|
|
month: 'long',
|
|
|
|
day: 'numeric',
|
|
|
|
};
|
|
|
|
const dateTimeLocale = new Intl.DateTimeFormat("en-GB", dateOptions);
|
|
|
|
eleventyConfig.addFilter("niceDate", function(date) {
|
|
|
|
return dateTimeLocale.format(date);
|
|
|
|
});
|
|
|
|
|
2024-04-16 16:03:41 +00:00
|
|
|
// Filter: Limit number of items displayed
|
|
|
|
eleventyConfig.addFilter("itemLimit", function(array, itemLimit) {
|
|
|
|
return array.slice(0, itemLimit);
|
2024-04-15 10:21:10 +00:00
|
|
|
});
|
|
|
|
|
2024-05-06 14:44:07 +00:00
|
|
|
// Shortcode: <cite> tag
|
|
|
|
eleventyConfig.addShortcode('cite', (str) => `<cite>${str}</cite>`);
|
|
|
|
|
2024-04-06 04:15:14 +00:00
|
|
|
return {
|
|
|
|
dir: {
|
|
|
|
input: "src"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|