49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
import { generateThumbnail } from "./scripts/thumbnails.js";
|
|
|
|
/** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
|
|
export default function (eleventyConfig) {
|
|
// Directory configs
|
|
eleventyConfig.setInputDirectory("content");
|
|
eleventyConfig.setIncludesDirectory("../_includes"); // relative to the input directory, therefore the ../
|
|
eleventyConfig.setDataDirectory("../_data"); // relative to the input directory, therefore the ../
|
|
eleventyConfig.setOutputDirectory("_site");
|
|
|
|
eleventyConfig.setFrontMatterParsingOptions({
|
|
excerpt: true,
|
|
// Optional, default is "---"
|
|
excerpt_separator: "<!-- excerpt -->",
|
|
});
|
|
|
|
// Custom date filter
|
|
eleventyConfig.addFilter("date", (dateObj) => {
|
|
return new Intl.DateTimeFormat("de-DE", {
|
|
day: "numeric",
|
|
month: "long",
|
|
year: "numeric",
|
|
}).format(dateObj);
|
|
});
|
|
|
|
eleventyConfig.addFilter("listTags", (tagsList) => {
|
|
let listHTML = "";
|
|
for (let i in tagsList) {
|
|
listHTML += `<span class='tag'>${tagsList[i]}</span>`;
|
|
}
|
|
return listHTML;
|
|
});
|
|
|
|
eleventyConfig.addFilter("capitalize", function (value) {
|
|
return value.toUpperCase();
|
|
});
|
|
|
|
// generate a nice preview image for articles that don't have one
|
|
eleventyConfig.addShortcode("generateThumbnail", function (hash) {
|
|
return generateThumbnail(hash);
|
|
});
|
|
|
|
// Collections
|
|
eleventyConfig.addCollection("posts", (collectionApi) => {
|
|
return collectionApi.getFilteredByTag("Posts");
|
|
});
|
|
|
|
eleventyConfig.addPassthroughCopy({ "public/": "/" });
|
|
}
|