Add misc section with full per-page strings translation support, 88x31 page and bookmarks page.

This commit is contained in:
天クマ 2026-04-21 14:33:42 -03:00
commit 74285e314d
89 changed files with 291 additions and 9 deletions

View file

@ -1,7 +1,29 @@
const fs = require("fs");
const path = require("path");
module.exports = function(eleventyConfig) {
eleventyConfig.addCollection("post", function(collectionApi) {
return collectionApi.getFilteredByGlob("./posts/*").sort((a, b) => b.date - a.date);
});
eleventyConfig.addCollection("misc", (api) =>
api.getFilteredByTag("misc")
);
eleventyConfig.addFilter("getTranslation", (page, lang) => {
const dir = path.dirname(page.inputPath);
const file = path.join(dir, `${lang}.json`);
if (fs.existsSync(file)) {
return JSON.parse(fs.readFileSync(file, "utf-8"));
}
return {};
});
eleventyConfig.addCollection("88x31", () => {
return fs.readdirSync("static/images/88x31")
.map(file => ({
url: `/static/images/88x31/${file}`
}));
});
eleventyConfig.addPassthroughCopy("static");
@ -16,10 +38,10 @@ eleventyConfig.addNunjucksFilter("alternateLanguages", function(collection, post
}))
});
eleventyConfig.addFilter("absoluteUrl", function(path) {
const base = "https://adrianvic.github.io";
return base + path;
});
eleventyConfig.addFilter("absoluteUrl", function(path) {
const base = "https://adrianvic.github.io";
return base + path;
});
eleventyConfig.addNunjucksFilter("smartTitle", function(str) {
if (!str) return "";
@ -30,7 +52,7 @@ eleventyConfig.addNunjucksFilter("smartTitle", function(str) {
return smallWords.includes(word) ? word : word.charAt(0).toUpperCase() + word.slice(1);
}).join(" ");
});
return {
return {
dir: {
output: "docs"
}