mirror of
https://git.tacowolf.net/TacoWolf/mestizo.monster.git
synced 2026-06-12 08:50:04 -04:00
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
import markdownIt from "markdown-it";
|
|
import readingTime from "eleventy-plugin-reading-time";
|
|
|
|
/** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
|
|
export default async function (eleventyConfig) {
|
|
eleventyConfig.addPassthroughCopy("assets");
|
|
eleventyConfig.addPassthroughCopy(".well-known");
|
|
eleventyConfig.addPassthroughCopy("**/*.jpg");
|
|
eleventyConfig.addPassthroughCopy("**/*.png");
|
|
|
|
eleventyConfig.addCollection("redirects", function (collectionApi) {
|
|
let redirects = [];
|
|
// get each post in our posts folder
|
|
const nodes = collectionApi.getFilteredByGlob("**/*.md");
|
|
// iterate over all the nodes
|
|
nodes.forEach((node) =>
|
|
// for each alias
|
|
(node.data.aliases || []).forEach((alias) =>
|
|
// push target url and the old url
|
|
redirects.push([
|
|
node.data.page.url,
|
|
node.data.page.url.replace(/\/[^\/]*?(\..+)?$/, `/${alias}$1`),
|
|
]),
|
|
),
|
|
);
|
|
return redirects;
|
|
});
|
|
|
|
eleventyConfig.addCollection("posts", function (collection) {
|
|
return collection.getFilteredByGlob("posts/**/*.md");
|
|
});
|
|
|
|
let options = {
|
|
html: true,
|
|
breaks: true,
|
|
linkify: true,
|
|
};
|
|
|
|
eleventyConfig.setLibrary("md", markdownIt(options));
|
|
eleventyConfig.addPlugin(readingTime);
|
|
}
|