2023-01-25 22:55:28 +01:00
|
|
|
|
const siteURL = "https://tarasis.net";
|
|
|
|
|
|
2023-01-23 01:54:11 +01:00
|
|
|
|
const fs = require("fs-extra");
|
|
|
|
|
const sass = require("sass");
|
|
|
|
|
const { promisify } = require("util");
|
|
|
|
|
const sassRender = promisify(sass.render);
|
|
|
|
|
const postcss = require("postcss");
|
|
|
|
|
const autoprefixer = require("autoprefixer");
|
|
|
|
|
const markdownIt = require("markdown-it");
|
|
|
|
|
const markdownItRenderer = new markdownIt();
|
|
|
|
|
const markdownItAnchor = require("markdown-it-anchor");
|
|
|
|
|
const pluginTOC = require("eleventy-plugin-toc");
|
|
|
|
|
const moment = require("moment");
|
|
|
|
|
const description = require("eleventy-plugin-description");
|
|
|
|
|
const pluginRss = require("@11ty/eleventy-plugin-rss");
|
|
|
|
|
const UpgradeHelper = require("@11ty/eleventy-upgrade-help");
|
|
|
|
|
const xmlFiltersPlugin = require("eleventy-xml-plugin");
|
2023-01-25 22:55:28 +01:00
|
|
|
|
const yaml = require("js-yaml");
|
2023-02-19 00:27:24 +01:00
|
|
|
|
const syntaxHighlight = require("eleventy-plugin-syntaxhighlight-chroma");
|
|
|
|
|
const highlight = require("chroma-highlight");
|
|
|
|
|
const eleventySass = require("@11tyrocks/eleventy-plugin-sass-lightningcss");
|
2023-01-23 01:54:11 +01:00
|
|
|
|
|
2023-01-23 05:50:27 +01:00
|
|
|
|
const inspect = require("node:util").inspect;
|
|
|
|
|
|
2023-01-23 01:54:11 +01:00
|
|
|
|
const path = require("path");
|
|
|
|
|
|
2024-10-18 17:26:55 +02:00
|
|
|
|
module.exports.config = {
|
|
|
|
|
pathPrefix: "/",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = async function (eleventyConfig) {
|
|
|
|
|
// const urlFilter = await import("@11ty/eleventy/src/Filters/Url");
|
|
|
|
|
const indexify = (url) => url.replace(/(\/[^.]*)$/, "$1index.html");
|
|
|
|
|
|
2023-01-23 05:50:27 +01:00
|
|
|
|
let pathPrefix = "/";
|
|
|
|
|
|
2023-02-19 00:27:24 +01:00
|
|
|
|
eleventyConfig.addDataExtension("yaml", (contents) => yaml.load(contents));
|
|
|
|
|
eleventyConfig.addDataExtension("yml", (contents) => yaml.load(contents));
|
2023-01-25 22:55:28 +01:00
|
|
|
|
|
2024-10-18 17:26:55 +02:00
|
|
|
|
// eleventyConfig.addPlugin(UpgradeHelper);
|
|
|
|
|
|
2023-01-23 01:54:11 +01:00
|
|
|
|
eleventyConfig.addPlugin(pluginRss);
|
|
|
|
|
//Blog excerpts
|
|
|
|
|
eleventyConfig.addPlugin(description);
|
|
|
|
|
// Eleventy Navigation (https://www.11ty.dev/docs/plugins/navigation/)
|
|
|
|
|
eleventyConfig.addPlugin(require("@11ty/eleventy-navigation"));
|
|
|
|
|
// Eleventy RSS Feed (https://www.11ty.dev/docs/plugins/rss/)
|
|
|
|
|
eleventyConfig.addPlugin(require("@11ty/eleventy-plugin-rss"));
|
|
|
|
|
// Filter to generate a Table of Contents from page content
|
|
|
|
|
eleventyConfig.addPlugin(pluginTOC, {
|
|
|
|
|
tags: ["h2", "h3"],
|
|
|
|
|
wrapper: "div",
|
|
|
|
|
});
|
|
|
|
|
// TODO https://www.npmjs.com/package/eleventy-plugin-meta-generator
|
|
|
|
|
// Eleventy Syntax Highlighting (https://www.11ty.dev/docs/plugins/syntaxhighlight/)
|
2023-01-25 22:55:28 +01:00
|
|
|
|
// eleventyConfig.addPlugin(require("@11ty/eleventy-plugin-syntaxhighlight"));
|
2023-02-19 00:27:24 +01:00
|
|
|
|
|
2023-01-25 22:55:28 +01:00
|
|
|
|
eleventyConfig.addPlugin(syntaxHighlight, {
|
2023-02-19 00:27:24 +01:00
|
|
|
|
theme: "base16-snazzy",
|
2023-01-25 22:55:28 +01:00
|
|
|
|
|
2023-02-19 00:27:24 +01:00
|
|
|
|
lexerOverrides: {
|
|
|
|
|
njk: "vue",
|
|
|
|
|
liquid: "vue",
|
|
|
|
|
},
|
|
|
|
|
});
|
2023-01-25 22:55:28 +01:00
|
|
|
|
|
2023-02-19 00:27:24 +01:00
|
|
|
|
// eleventyConfig.addPlugin(syntaxHighlight, {
|
2023-01-25 22:55:28 +01:00
|
|
|
|
|
2023-02-19 00:27:24 +01:00
|
|
|
|
// alwaysWrapLineHighlights: true,
|
|
|
|
|
// // Change which Eleventy template formats use syntax highlighters
|
|
|
|
|
// // templateFormats: ["*"], // default
|
2023-01-25 22:55:28 +01:00
|
|
|
|
|
2023-02-19 00:27:24 +01:00
|
|
|
|
// // Use only a subset of template types (11ty.js added in v4.0.0)
|
|
|
|
|
// // templateFormats: ["liquid", "njk", "md", "11ty.js"],
|
2023-01-25 22:55:28 +01:00
|
|
|
|
|
2023-02-19 00:27:24 +01:00
|
|
|
|
// // init callback lets you customize Prism
|
|
|
|
|
// // init: function({ Prism }) {
|
|
|
|
|
// // Prism.languages.myCustomLanguage = /* */;
|
|
|
|
|
// // },
|
|
|
|
|
|
|
|
|
|
// // Added in 3.1.1, add HTML attributes to the <pre> or <code> tags
|
|
|
|
|
// preAttributes: {
|
|
|
|
|
// tabindex: 0,
|
|
|
|
|
|
|
|
|
|
// // Added in 4.1.0 you can use callback functions too
|
|
|
|
|
// "data-language": function({ language, content, options }) {
|
|
|
|
|
// return language;
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// codeAttributes: {},
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// assert(typeof highlight === "function");
|
|
|
|
|
// eleventyConfig.addPlugin(highlight);
|
|
|
|
|
|
|
|
|
|
// eleventyConfig.addMarkdownHighlighter(
|
|
|
|
|
// highlight(
|
|
|
|
|
// `--formatter html --html-only --html-inline-styles --lexer typescript --style base16-snazzy`
|
|
|
|
|
// )
|
|
|
|
|
// );
|
2023-01-23 01:54:11 +01:00
|
|
|
|
|
|
|
|
|
eleventyConfig.addPlugin(xmlFiltersPlugin);
|
|
|
|
|
|
2023-02-19 00:27:24 +01:00
|
|
|
|
// eleventyConfig.addPlugin(eleventySass);
|
|
|
|
|
|
2023-01-23 01:54:11 +01:00
|
|
|
|
// Custom Collections
|
|
|
|
|
eleventyConfig.addCollection("pages", (collection) =>
|
|
|
|
|
collection.getFilteredByGlob("./src/_pages/**/*")
|
|
|
|
|
);
|
|
|
|
|
|
2023-02-20 03:43:09 +01:00
|
|
|
|
eleventyConfig.addCollection("posts", (collection) => {
|
|
|
|
|
availablePages = collection
|
2023-01-23 01:54:11 +01:00
|
|
|
|
.getFilteredByGlob("./src/_posts/**/*")
|
|
|
|
|
.filter(
|
|
|
|
|
(item) => item.data.draft !== true && item.date <= new Date()
|
|
|
|
|
)
|
|
|
|
|
.reverse()
|
|
|
|
|
.map((cur, i, all) => {
|
|
|
|
|
cur.data["siblings"] = {
|
|
|
|
|
next: all[i - 1],
|
|
|
|
|
prev: all[i + 1],
|
|
|
|
|
};
|
|
|
|
|
return cur;
|
2023-02-20 03:43:09 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return availablePages;
|
|
|
|
|
});
|
2023-01-23 01:54:11 +01:00
|
|
|
|
|
|
|
|
|
eleventyConfig.addCollection("projects", (collection) =>
|
|
|
|
|
collection
|
|
|
|
|
.getFilteredByGlob("./src/projects/**/*")
|
|
|
|
|
.sort((a, b) => a.data.weight - b.data.weight)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// eleventyConfig.addCollection("posts", function (collectionApi) {
|
2023-01-23 05:50:27 +01:00
|
|
|
|
// return collectionApi.getFilteredByGlob("./src/_posts/**/*.md");
|
2023-01-23 01:54:11 +01:00
|
|
|
|
// });
|
|
|
|
|
|
2023-01-25 22:55:28 +01:00
|
|
|
|
eleventyConfig.addCollection("drafts", (collection) =>
|
2023-02-19 00:27:24 +01:00
|
|
|
|
collection
|
|
|
|
|
.getFilteredByGlob("./src/_drafts/**/*")
|
|
|
|
|
.sort((a, b) => a.data.weight - b.data.weight)
|
|
|
|
|
);
|
2023-01-25 22:55:28 +01:00
|
|
|
|
|
2023-01-23 01:54:11 +01:00
|
|
|
|
eleventyConfig.addCollection("tags", (collection) => {
|
|
|
|
|
let tags = new Set();
|
|
|
|
|
|
|
|
|
|
collection.getAll().forEach((item) => {
|
|
|
|
|
if ("tags" in item.data) {
|
2023-01-25 22:55:28 +01:00
|
|
|
|
if (item.data.tags != undefined) {
|
|
|
|
|
for (const tag of item.data.tags) {
|
|
|
|
|
tags.add(tag);
|
|
|
|
|
}
|
2023-01-23 01:54:11 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return [...tags];
|
|
|
|
|
});
|
|
|
|
|
|
2023-01-25 22:55:28 +01:00
|
|
|
|
eleventyConfig.addCollection("categories", (collection) => {
|
|
|
|
|
let categories = new Set();
|
|
|
|
|
|
|
|
|
|
collection.getAll().forEach((item) => {
|
|
|
|
|
if ("category" in item.data) {
|
|
|
|
|
if (item.data.category != undefined) {
|
2023-02-19 00:27:24 +01:00
|
|
|
|
for (const category of item.data.category) {
|
2023-01-25 22:55:28 +01:00
|
|
|
|
categories.add(category);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return [...categories];
|
|
|
|
|
});
|
|
|
|
|
|
2023-01-23 01:54:11 +01:00
|
|
|
|
// Filters
|
|
|
|
|
|
|
|
|
|
// eleventyConfig.addFilter("markdownify", (str) => {
|
|
|
|
|
// return markdownItRenderer.renderInline(str);
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
eleventyConfig.addFilter("markdownify", (string) => {
|
|
|
|
|
return md.renderInline(string);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
eleventyConfig.addNunjucksFilter("markdownify", (str) => md.render(str));
|
|
|
|
|
|
|
|
|
|
eleventyConfig.addFilter("jsonify", (variable) => JSON.stringify(variable));
|
|
|
|
|
|
|
|
|
|
eleventyConfig.addFilter("slugify", (str) =>
|
|
|
|
|
require("slugify")(str, {
|
|
|
|
|
lower: true,
|
|
|
|
|
replacement: "-",
|
|
|
|
|
remove: /[*+~.·,()''`´%!?¿:@]/g,
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
eleventyConfig.addFilter("where", (array, key, value) =>
|
|
|
|
|
array.filter((item) => {
|
|
|
|
|
const keys = key.split(".");
|
|
|
|
|
const reducedKey = keys.reduce((object, key) => object[key], item);
|
|
|
|
|
|
|
|
|
|
return reducedKey === value ? item : false;
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
eleventyConfig.addFilter("date", (date, format = "") =>
|
|
|
|
|
require("moment")(date).format(format)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
eleventyConfig.addLiquidFilter("toUTCString", (date) => {
|
|
|
|
|
const utc = date.toUTCString();
|
|
|
|
|
return moment.utc(utc).format("MMMM Do YYYY");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
eleventyConfig.addFilter("number_of_words", numberOfWords);
|
|
|
|
|
|
|
|
|
|
// eleventyConfig.addShortcode("where_exp", function (item, exp) {
|
|
|
|
|
// console.log(exp);
|
|
|
|
|
// return eval(exp);
|
|
|
|
|
// });
|
|
|
|
|
eleventyConfig.addFilter("where_exp", function (value) {
|
|
|
|
|
// where_exp function
|
|
|
|
|
return value.hidden != true;
|
|
|
|
|
});
|
|
|
|
|
|
2023-01-23 05:50:27 +01:00
|
|
|
|
eleventyConfig.addFilter("inspect", function (obj = {}) {
|
2023-02-19 00:27:24 +01:00
|
|
|
|
return inspect(obj, { sorted: true });
|
|
|
|
|
});
|
2023-01-23 05:50:27 +01:00
|
|
|
|
|
2024-10-18 17:26:55 +02:00
|
|
|
|
eleventyConfig.addFilter("debugger", (...args) => {
|
|
|
|
|
console.log(...args);
|
|
|
|
|
debugger;
|
|
|
|
|
});
|
|
|
|
|
|
2023-02-19 00:27:24 +01:00
|
|
|
|
eleventyConfig.addFilter("group_by", groupBy);
|
2023-01-25 22:55:28 +01:00
|
|
|
|
|
2023-01-23 01:54:11 +01:00
|
|
|
|
eleventyConfig.addLayoutAlias(
|
|
|
|
|
"archive-taxonomy",
|
|
|
|
|
"layouts/archive-taxonomy.html"
|
|
|
|
|
);
|
|
|
|
|
eleventyConfig.addLayoutAlias("archive", "layouts/archive.html");
|
|
|
|
|
eleventyConfig.addLayoutAlias("categories", "layouts/categories.html");
|
|
|
|
|
eleventyConfig.addLayoutAlias("category", "layouts/category.html");
|
|
|
|
|
eleventyConfig.addLayoutAlias("collection", "layouts/collection.html");
|
|
|
|
|
eleventyConfig.addLayoutAlias("compress", "layouts/compress.html");
|
|
|
|
|
eleventyConfig.addLayoutAlias("default", "layouts/default.html");
|
|
|
|
|
eleventyConfig.addLayoutAlias("home", "layouts/home.html");
|
|
|
|
|
eleventyConfig.addLayoutAlias("posts", "layouts/posts.html");
|
|
|
|
|
eleventyConfig.addLayoutAlias("search", "layouts/search.html");
|
|
|
|
|
eleventyConfig.addLayoutAlias("single", "layouts/single.html");
|
|
|
|
|
eleventyConfig.addLayoutAlias("splash", "layouts/splash.html");
|
|
|
|
|
eleventyConfig.addLayoutAlias("tag", "layouts/tag.html");
|
|
|
|
|
eleventyConfig.addLayoutAlias("tags", "layouts/tags.html");
|
|
|
|
|
eleventyConfig.addLayoutAlias("gallery", "layouts/gallery");
|
2023-01-25 22:55:28 +01:00
|
|
|
|
eleventyConfig.addLayoutAlias("drafts", "layouts/drafts");
|
2023-01-23 01:54:11 +01:00
|
|
|
|
|
|
|
|
|
// Passthrough copy
|
|
|
|
|
// don't use .gitignore (allows compiling sass to css into a monitored folder WITHOUT committing it to repo)
|
|
|
|
|
eleventyConfig.setUseGitIgnore(false);
|
|
|
|
|
|
|
|
|
|
//Copy CNAME
|
|
|
|
|
eleventyConfig.addPassthroughCopy("src/CNAME");
|
|
|
|
|
|
|
|
|
|
// Processing configuration
|
|
|
|
|
eleventyConfig.addPassthroughCopy("src/favicon.ico");
|
|
|
|
|
eleventyConfig.addPassthroughCopy("src/admin");
|
|
|
|
|
eleventyConfig.addPassthroughCopy("src/assets");
|
|
|
|
|
// eleventyConfig.addPassthroughCopy({ "src/_sass": "assets/css" });
|
|
|
|
|
|
2023-02-20 03:43:09 +01:00
|
|
|
|
let availablePages = [];
|
|
|
|
|
|
|
|
|
|
eleventyConfig.addShortcode("post_url", (slug) => {
|
|
|
|
|
let collection = availablePages;
|
|
|
|
|
|
2023-01-23 01:54:11 +01:00
|
|
|
|
try {
|
|
|
|
|
if (collection.length < 1) {
|
|
|
|
|
throw "Collection appears to be empty";
|
|
|
|
|
}
|
|
|
|
|
if (!Array.isArray(collection)) {
|
|
|
|
|
throw "Collection is an invalid type - it must be an array!";
|
|
|
|
|
}
|
|
|
|
|
if (typeof slug !== "string") {
|
|
|
|
|
throw "Slug is an invalid type - it must be a string!";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const found = collection.find((p) => p.fileSlug == slug);
|
|
|
|
|
if (found === 0 || found === undefined) {
|
|
|
|
|
throw `${slug} not found in specified collection.`;
|
|
|
|
|
} else {
|
|
|
|
|
return found.url;
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error(
|
2023-02-20 03:43:09 +01:00
|
|
|
|
`RMCG:An error occurred while searching for the url to ${slug}. Details:`,
|
2023-01-23 01:54:11 +01:00
|
|
|
|
e
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Set section
|
|
|
|
|
|
|
|
|
|
// Configure BrowserSync to serve the 404 page for missing files
|
2023-02-19 00:27:24 +01:00
|
|
|
|
// eleventyConfig.setBrowserSyncConfig({
|
|
|
|
|
// callbacks: {
|
|
|
|
|
// ready: (_err, browserSync) => {
|
|
|
|
|
// const content_404 = fs.readFileSync("dist/404.html");
|
|
|
|
|
|
|
|
|
|
// browserSync.addMiddleware("*", (_req, res) => {
|
|
|
|
|
// // render the 404 content instead of redirecting
|
|
|
|
|
// res.write(content_404);
|
|
|
|
|
// res.end();
|
|
|
|
|
// });
|
|
|
|
|
// },
|
|
|
|
|
// },
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
eleventyConfig.setServerOptions({
|
|
|
|
|
// Default values are shown:
|
2023-01-23 01:54:11 +01:00
|
|
|
|
|
2023-02-19 00:27:24 +01:00
|
|
|
|
// Whether the live reload snippet is used
|
|
|
|
|
liveReload: true,
|
|
|
|
|
watch: ["dist/assets/css/main.css"],
|
2023-01-23 01:54:11 +01:00
|
|
|
|
});
|
|
|
|
|
|
2023-02-19 00:27:24 +01:00
|
|
|
|
// eleventyConfig.setBrowserSyncConfig({
|
|
|
|
|
// files: "./dist/assets/css/*.css",
|
|
|
|
|
// });
|
|
|
|
|
|
2023-01-23 01:54:11 +01:00
|
|
|
|
// Merge Data (https://www.11ty.dev/docs/data-deep-merge/)
|
|
|
|
|
eleventyConfig.setDataDeepMerge(true);
|
|
|
|
|
|
|
|
|
|
eleventyConfig.setFrontMatterParsingOptions({
|
|
|
|
|
excerpt: true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
eleventyConfig.setLibrary("md", markdownIt().use(markdownItAnchor));
|
|
|
|
|
|
|
|
|
|
eleventyConfig.setLiquidOptions({
|
|
|
|
|
// dynamicPartials: false,
|
|
|
|
|
// strictVariables: false,
|
|
|
|
|
// strictFilters: false,
|
|
|
|
|
jekyllInclude: true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Markdown Configuration
|
|
|
|
|
const md = require("markdown-it")({
|
|
|
|
|
html: true,
|
|
|
|
|
breaks: true,
|
|
|
|
|
linkify: true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
eleventyConfig.setLibrary(
|
|
|
|
|
"md",
|
|
|
|
|
md
|
|
|
|
|
.use(require("markdown-it-attrs"))
|
|
|
|
|
.use(require("markdown-it-container"), "", {
|
|
|
|
|
validate: () => true,
|
|
|
|
|
render: (tokens, idx) => {
|
|
|
|
|
if (tokens[idx].nesting === 1) {
|
|
|
|
|
const classList = tokens[idx].info.trim();
|
|
|
|
|
return `<div ${classList && `class="${classList}"`}>`;
|
|
|
|
|
} else {
|
|
|
|
|
return `</div>`;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
.use(require("markdown-it-fontawesome"))
|
|
|
|
|
.use(require("markdown-it-footnote"))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// override markdown-it-footnote anchor template to use a different unicode character
|
|
|
|
|
md.renderer.rules.footnote_anchor = (tokens, idx, options, env, slf) => {
|
|
|
|
|
var id = slf.rules.footnote_anchor_name(tokens, idx, options, env, slf);
|
|
|
|
|
|
|
|
|
|
if (tokens[idx].meta.subId > 0) {
|
|
|
|
|
id += ":" + tokens[idx].meta.subId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ⇑ with escape code to prevent display as Apple Emoji on iOS */
|
|
|
|
|
return (
|
|
|
|
|
' <a href="#fnref' +
|
|
|
|
|
id +
|
|
|
|
|
'" class="footnote-backref">\u21d1\uFE0E</a>'
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//for upgrade sanity
|
|
|
|
|
//eleventyConfig.addPlugin(UpgradeHelper);
|
|
|
|
|
|
|
|
|
|
// eleventyConfig.addWatchTarget("./assets/css/");
|
|
|
|
|
// eleventyConfig.addTransform(
|
|
|
|
|
// "sass",
|
|
|
|
|
// async function sassTransform(content, outputPath) {
|
|
|
|
|
// if (outputPath?.endsWith(".css")) {
|
|
|
|
|
// const { css } = await sassRender({
|
|
|
|
|
// data: content,
|
|
|
|
|
// outputStyle: "compressed",
|
|
|
|
|
// precision: 3,
|
|
|
|
|
// });
|
|
|
|
|
// return css;
|
|
|
|
|
// }
|
|
|
|
|
// return content;
|
|
|
|
|
// }
|
|
|
|
|
// );
|
|
|
|
|
|
2023-02-19 00:27:24 +01:00
|
|
|
|
// eleventyConfig.addWatchTarget("dist/assets/css/*.css");
|
|
|
|
|
|
2024-10-18 17:26:55 +02:00
|
|
|
|
const { EleventyHtmlBasePlugin } = await import("@11ty/eleventy");
|
|
|
|
|
|
|
|
|
|
eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
|
|
|
|
|
|
|
|
|
|
eleventyConfig.addFilter("relative_url", relativeURLALT2);
|
|
|
|
|
|
2023-01-25 22:55:28 +01:00
|
|
|
|
eleventyConfig.addFilter("absolute_url", absoluteUrl);
|
2023-01-23 05:50:27 +01:00
|
|
|
|
|
2023-01-23 01:54:11 +01:00
|
|
|
|
return {
|
2023-01-23 05:50:27 +01:00
|
|
|
|
templateFormats: ["html", "liquid", "md", "njk"],
|
2023-01-23 01:54:11 +01:00
|
|
|
|
|
2023-01-23 05:50:27 +01:00
|
|
|
|
pathPrefix,
|
2023-01-23 01:54:11 +01:00
|
|
|
|
|
2023-01-25 22:55:28 +01:00
|
|
|
|
environment: "production",
|
|
|
|
|
|
|
|
|
|
// absolute_url: "https://tarasis.net/",
|
2023-01-23 01:54:11 +01:00
|
|
|
|
passthroughFileCopy: true,
|
|
|
|
|
|
|
|
|
|
dir: {
|
|
|
|
|
input: "src",
|
|
|
|
|
includes: "_includes",
|
|
|
|
|
data: "_data",
|
|
|
|
|
output: "dist",
|
|
|
|
|
// input: "./", // Equivalent to Jekyll's source property
|
|
|
|
|
// output: "./_site", // Equivalent to Jekyll's destination property
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function numberOfWords(content) {
|
|
|
|
|
return content.split(/\s+/g).length;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-18 17:26:55 +02:00
|
|
|
|
// Cheat till I can go through
|
|
|
|
|
function relativeURLALT2(url) {
|
|
|
|
|
if (!url.startsWith("/")) {
|
|
|
|
|
throw new Error("URL is already relative");
|
2023-01-23 01:54:11 +01:00
|
|
|
|
}
|
2024-10-18 17:26:55 +02:00
|
|
|
|
return url;
|
2023-01-23 05:50:27 +01:00
|
|
|
|
}
|
2023-01-25 22:55:28 +01:00
|
|
|
|
|
|
|
|
|
function absoluteUrl(url) {
|
|
|
|
|
if (url !== undefined) {
|
2023-02-19 00:27:24 +01:00
|
|
|
|
return siteURL + url;
|
2023-01-25 22:55:28 +01:00
|
|
|
|
} else {
|
2023-02-19 00:27:24 +01:00
|
|
|
|
return siteURL;
|
2023-01-25 22:55:28 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function groupBy(array, key) {
|
2023-02-19 00:27:24 +01:00
|
|
|
|
const get = (entry) => key.split(".").reduce((acc, key) => acc[key], entry);
|
2023-01-25 22:55:28 +01:00
|
|
|
|
|
|
|
|
|
const map = array.reduce((acc, entry) => {
|
2023-02-19 00:27:24 +01:00
|
|
|
|
const value = get(entry);
|
2023-01-25 22:55:28 +01:00
|
|
|
|
|
2023-02-19 00:27:24 +01:00
|
|
|
|
if (typeof acc[value] === "undefined") {
|
|
|
|
|
acc[value] = [];
|
|
|
|
|
}
|
2023-01-25 22:55:28 +01:00
|
|
|
|
|
2023-02-19 00:27:24 +01:00
|
|
|
|
acc[value].push(entry);
|
|
|
|
|
return acc;
|
|
|
|
|
}, {});
|
2023-01-25 22:55:28 +01:00
|
|
|
|
|
|
|
|
|
return Object.keys(map).reduce(
|
2023-02-19 00:27:24 +01:00
|
|
|
|
(acc, key) => [...acc, { name: key, items: map[key] }],
|
|
|
|
|
[]
|
|
|
|
|
);
|
|
|
|
|
}
|