comprofix.com/.eleventy.js

63 lines
1.9 KiB
JavaScript
Raw Permalink Normal View History

2022-08-07 00:57:36 +10:00
const blogTools = require("eleventy-plugin-blog-tools");
2022-08-07 02:18:36 +10:00
const markdownIt = require("markdown-it");
const markdownItAttrs = require("markdown-it-attrs");
2024-09-22 01:27:39 +10:00
const markdownItAnchor = require("markdown-it-anchor");
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
2024-09-18 23:29:53 +10:00
const { DateTime } = require("luxon");
2022-08-07 00:57:36 +10:00
module.exports = function(eleventyConfig) {
2022-08-07 02:18:36 +10:00
const mdOptions = {
html: true,
breaks: true,
linkify: true,
};
2024-09-22 01:27:39 +10:00
2022-08-07 02:18:36 +10:00
const markdownLib = markdownIt(mdOptions)
.use(markdownItAttrs)
2024-09-22 01:27:39 +10:00
.use(markdownItAnchor, {
permalink: markdownItAnchor.permalink.linkInsideHeader({
// Change the symbol to a link icon, e.g., "🔗"
symbol: '🔗', // Change this to whatever symbol you want
class: 'anchor-link', // You can style this class with CSS
ariaHidden: false,
tabIndex: -1,
before: '', // Leave empty to not add anything before the icon
})
})
2022-08-07 02:18:36 +10:00
.disable("code");
2024-09-18 23:29:53 +10:00
eleventyConfig.addFilter("postDate", (dateObj) => {
return DateTime.fromJSDate(dateObj).toLocaleString(DateTime.DATE_MED);
});
2024-09-22 01:27:39 +10:00
2022-08-07 02:18:36 +10:00
eleventyConfig.setLibrary("md", markdownLib);
2022-08-07 00:57:36 +10:00
eleventyConfig.setUseGitIgnore(false);
eleventyConfig.addPassthroughCopy('./src/css');
eleventyConfig.addPassthroughCopy('./src/assets/');
2024-09-15 01:24:32 +10:00
eleventyConfig.addPassthroughCopy('./src/js/');
2022-08-07 00:57:36 +10:00
eleventyConfig.addWatchTarget('./src/css');
2024-09-15 01:24:32 +10:00
eleventyConfig.addWatchTarget('./src/js');
eleventyConfig.addWatchTarget('./src/assets/');
2022-08-07 00:57:36 +10:00
eleventyConfig.setDataDeepMerge(true);
eleventyConfig.setTemplateFormats("html,njk,md");
eleventyConfig.addCollection('posts', function(collectionApi) {
2024-09-22 01:27:39 +10:00
return collectionApi.getFilteredByGlob('src/blog/posts/**/*.md');
2022-08-07 00:57:36 +10:00
});
eleventyConfig.addPlugin(blogTools);
eleventyConfig.addPlugin(syntaxHighlight);
2022-08-07 00:57:36 +10:00
return {
passthroughFileCopy: true,
dir: {
input: 'src',
includes: '_includes',
output: "_site"
}
};
}