2025-01-31 02:18:17 +01:00
|
|
|
import * as sass from "sass";
|
|
|
|
import { eleventyImageTransformPlugin } from "@11ty/eleventy-img";
|
2025-01-29 01:42:26 +01:00
|
|
|
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
|
2025-01-29 01:42:26 +01:00
|
|
|
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
|
2025-02-13 20:56:23 +01:00
|
|
|
eleventyConfig.addPlugin(eleventyImageTransformPlugin, {
|
|
|
|
widths: ["700"]
|
|
|
|
});
|
|
|
|
eleventyConfig.addShortcode("figure", (url, alt, caption, width) => {
|
2025-02-11 21:11:06 +01:00
|
|
|
return `
|
|
|
|
<figure>
|
2025-02-13 20:56:23 +01:00
|
|
|
<img src="${url}" alt="${alt}" width="${width || "700"}" />
|
2025-02-11 21:11:06 +01:00
|
|
|
<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-02-13 20:56:23 +01:00
|
|
|
|
|
|
|
// Portfolio sort
|
|
|
|
eleventyConfig.addCollection("portfolioSorted", (collectionsAPi) => {
|
|
|
|
const portfolio = collectionsAPi.getFilteredByTag("portfolio");
|
|
|
|
const sorted = portfolio.sort((a, b) => a.data.order - b.data.order);
|
|
|
|
return sorted;
|
|
|
|
});
|
|
|
|
|
2025-01-28 03:12:25 +01:00
|
|
|
}
|
2025-01-26 23:42:53 +01:00
|
|
|
|
|
|
|
export const config = {
|
|
|
|
dir: {
|
2025-01-27 02:17:27 +01:00
|
|
|
input: "content",
|
2025-01-26 23:42:53 +01:00
|
|
|
includes: "includes",
|
|
|
|
layouts: "layouts",
|
|
|
|
output: "dist"
|
|
|
|
}
|
|
|
|
};
|