eleventy-riksolo-com/eleventy.config.js

64 lines
1.4 KiB
JavaScript
Raw Normal View History

2025-01-31 02:18:17 +01:00
import * as sass from "sass";
import { eleventyImageTransformPlugin } from "@11ty/eleventy-img";
import { DateTime } from "luxon";
2025-02-13 00:02:33 +01:00
import markdownit from "markdown-it";
import syntaxHighlight from '@11ty/eleventy-plugin-syntaxhighlight';
2025-01-28 03:12:25 +01:00
export default async function (eleventyConfig) {
2025-01-31 02:18:17 +01:00
// Filters
eleventyConfig.addFilter("dateLocale", function (value) {
return DateTime.fromISO(new Date(value).toISOString()).toLocaleString({
year: 'numeric',
month: 'short',
day: '2-digit',
});
});
// SCSS
2025-01-28 03:12:25 +01:00
eleventyConfig.addTemplateFormats("scss");
eleventyConfig.addExtension("scss", {
outputFileExtension: "css",
compile: async function (inputContent) {
let result = sass.compileString(inputContent);
return async (data) => {
return result.css;
};
}
});
2025-01-31 02:18:17 +01:00
//Images
eleventyConfig.addPlugin(eleventyImageTransformPlugin);
2025-02-11 21:11:06 +01:00
eleventyConfig.addShortcode("figure", (url, alt, caption) => {
return `
<figure>
<img src="${url}" alt="${alt}" />
<figcaption>${caption}</figcaption>
</figure>
`;
});
2025-02-04 19:38:08 +01:00
2025-02-13 00:02:33 +01:00
//Markdown
const md = markdownit({
html: true,
breaks: true
});
eleventyConfig.setLibrary("md", md);
// Syntax Highlighting
eleventyConfig.addPlugin(syntaxHighlight);
//File passthrough
2025-02-04 19:38:08 +01:00
eleventyConfig.addPassthroughCopy("content/robots.txt");
2025-01-28 03:12:25 +01:00
}
2025-01-26 23:42:53 +01:00
export const config = {
dir: {
input: "content",
2025-01-26 23:42:53 +01:00
includes: "includes",
layouts: "layouts",
output: "dist"
}
};