From ab071b0f7831f218ef8ca5aa0646cfd132903549 Mon Sep 17 00:00:00 2001 From: Adrian Victor Date: Sat, 4 Jul 2026 14:34:59 -0300 Subject: [PATCH] Convert .eleventy.js to EJS, add friends to index's aside, create playground page to test site elements, add syntax highlighting with custom theme, convert header subtitle from link to paragraph, add support for custom alt text in 88x31 macro, new template for generic text pages, add changelog to about page with recent commits. --- .eleventy.js | 144 +- _data/{i18n.js => i18n.cjs} | 6 +- _data/{languages.js => languages.cjs} | 0 _includes/base.njk | 1 + _includes/header.njk | 8 +- _includes/macros.njk | 10 +- _includes/text.njk | 6 + index.njk | 9 + misc/88x31/index.njk | 1 + misc/about/index.njk | 15 +- misc/{misc.11tydata.js => misc.11tydata.cjs} | 0 package-lock.json | 3012 +++-------------- package.json | 10 +- playground.njk | 89 + .../{posts.11tydata.js => posts.11tydata.cjs} | 0 static/images/88x31/mrnandokk.gif | Bin 0 -> 47863 bytes static/main.css | 18 + static/prism.css | 139 + 18 files changed, 946 insertions(+), 2522 deletions(-) rename _data/{i18n.js => i18n.cjs} (99%) rename _data/{languages.js => languages.cjs} (100%) create mode 100644 _includes/text.njk rename misc/{misc.11tydata.js => misc.11tydata.cjs} (100%) create mode 100644 playground.njk rename posts/{posts.11tydata.js => posts.11tydata.cjs} (100%) create mode 100644 static/images/88x31/mrnandokk.gif create mode 100644 static/prism.css diff --git a/.eleventy.js b/.eleventy.js index ed81672..030c747 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -1,46 +1,73 @@ -const fs = require("fs"); -const path = require("path"); -const i18n = require('./_data/i18n.js'); +import fs from "fs"; +import path from "path"; -module.exports = function(eleventyConfig) { - eleventyConfig.addCollection("post", function(collectionApi) { - return collectionApi.getFilteredByGlob("./posts/*").sort((a, b) => b.date - a.date); +import syntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight"; +import safeLinks from "@sardine/eleventy-plugin-external-links"; +import pluginGitCommitDate from "eleventy-plugin-git-commit-date"; +import recentChanges from "eleventy-plugin-recent-changes"; +import Webmentions from "eleventy-plugin-webmentions"; // configure later +import pluginInlineLinkFavicon from "eleventy-plugin-inline-link-favicon"; + +// import i18n from "./_data/i18n.js"; + +export default function (eleventyConfig) { + eleventyConfig.setQuietMode(true); + eleventyConfig.addPlugin(syntaxHighlight); + eleventyConfig.addPlugin(safeLinks); + eleventyConfig.addPlugin(pluginGitCommitDate); + eleventyConfig.addPlugin(recentChanges, { + commits: 10, }); - eleventyConfig.addCollection("misc", (api) => - api.getFilteredByTag("misc") - ); + eleventyConfig.addPlugin(pluginInlineLinkFavicon); + + 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}`, - fileSlug: file - })); + return fs + .readdirSync("static/images/88x31") + .map((file) => ({ + url: `/static/images/88x31/${file}`, + fileSlug: file, + })); }); eleventyConfig.addPassthroughCopy("static"); - eleventyConfig.addNunjucksFilter("alternateLanguages", function(collection, postId, currentLanguageKey) { - return collection.filter(post => - post.data.postId === postId && post.data.langKey !== currentLanguageKey - ) - .map(post => ({ - lang: post.data.langKey, - url: post.url, - title: post.data.title - })) - }); + eleventyConfig.addNunjucksFilter( + "alternateLanguages", + function (collection, postId, currentLanguageKey) { + return collection + .filter( + (post) => + post.data.postId === postId && + post.data.langKey !== currentLanguageKey + ) + .map((post) => ({ + lang: post.data.langKey, + url: post.url, + title: post.data.title, + })); + } + ); - eleventyConfig.addFilter("absoluteUrl", function(url) { + eleventyConfig.addFilter("absoluteUrl", function (url) { const base = "https://adrianvic.github.io"; const prefix = process.env.GITHUB_ACTIONS ? "" : "/tenkuma/web"; return base + prefix + url; @@ -52,24 +79,65 @@ module.exports = function(eleventyConfig) { year: "numeric", month: "numeric", day: "numeric", - timeZone: "America/Sao_Paulo" + timeZone: "America/Sao_Paulo", }); }); - eleventyConfig.addNunjucksFilter("smartTitle", function(str) { + eleventyConfig.addNunjucksFilter("smartTitle", function (str) { if (!str) return ""; - const smallWords = ["a","an","and","at","but","by","for","in","nor","of","on","or","so","the","to","up","yet", - "e","de","do","da","dos","das","a","o","um","uma","em","por","para","com","no","na","nos"]; - return str.toLowerCase().split(" ").map((word, i) => { - if (i === 0) return word.charAt(0).toUpperCase() + word.slice(1); - return smallWords.includes(word) ? word : word.charAt(0).toUpperCase() + word.slice(1); - }).join(" "); + const smallWords = [ + "a", + "an", + "and", + "at", + "but", + "by", + "for", + "in", + "nor", + "of", + "on", + "or", + "so", + "the", + "to", + "up", + "yet", + "e", + "de", + "do", + "da", + "dos", + "das", + "a", + "o", + "um", + "uma", + "em", + "por", + "para", + "com", + "no", + "na", + "nos", + ]; + + return str + .toLowerCase() + .split(" ") + .map((word, i) => { + if (i === 0) return word.charAt(0).toUpperCase() + word.slice(1); + return smallWords.includes(word) + ? word + : word.charAt(0).toUpperCase() + word.slice(1); + }) + .join(" "); }); return { pathPrefix: process.env.GITHUB_ACTIONS ? "" : "/tenkuma/web", dir: { - output: "docs" - } + output: "docs", + }, }; -}; +} diff --git a/_data/i18n.js b/_data/i18n.cjs similarity index 99% rename from _data/i18n.js rename to _data/i18n.cjs index af27cab..39d68e5 100644 --- a/_data/i18n.js +++ b/_data/i18n.cjs @@ -92,7 +92,8 @@ module.exports = { previous: "previous", next: "next", about: "about", - thisWebsiteDoesNotTrackYou: "This website does not track you." + thisWebsiteDoesNotTrackYou: "This website does not track you.", + mrnandoChannel: "Mr. Nando's channel" }, pt: { language: "português", @@ -160,6 +161,7 @@ module.exports = { previous: "anterior", next: "próximo", about: "sobre", - thisWebsiteDoesNotTrackYou: "Esse website não rastreia você." + thisWebsiteDoesNotTrackYou: "Esse website não rastreia você.", + mrnandoChannel: "Canal do Mr. Nando" } }; \ No newline at end of file diff --git a/_data/languages.js b/_data/languages.cjs similarity index 100% rename from _data/languages.js rename to _data/languages.cjs diff --git a/_includes/base.njk b/_includes/base.njk index 66a5297..22a8d31 100644 --- a/_includes/base.njk +++ b/_includes/base.njk @@ -14,6 +14,7 @@ Adrian Victor{% if pageTitle or postTitle %} - {{ pageTitle or postTitle }}{% endif %} + diff --git a/_includes/header.njk b/_includes/header.njk index 230ae1d..89c7880 100644 --- a/_includes/header.njk +++ b/_includes/header.njk @@ -1,7 +1,7 @@

{{ title or "Adrian Victor" }}

- {{ subtitle or "Fanasy is not a crime, find your castle in the sky." }} +

{{ subtitle or "Fanasy is not a crime, find your castle in the sky." }}