feat: pixel favicon and complete SEO metadata
PR Check / Security scan (Snyk) (pull_request) Skipped
PR Check / Lint + typecheck (pull_request) Successful in 1m6s
PR Check / Secret scan (gitleaks) (pull_request) Successful in 7s
PR Check / Dependency audit (pull_request) Successful in 9s
PR Check / Dockerfile lint (droast) (pull_request) Successful in 5s
PR Check / AI code review (opencode) (pull_request) Successful in 1m11s

- generate favicon.ico and favicon.svg from the header avatar; the sprite
  moves to app/utils/avatar.js so component and generators share one source
- register @nuxtjs/seo with site and Person schema.org data from
  site.config.mjs; canonical, robots, sitemap and llms.txt follow the routes
- title "Noel Sabia — <role>", summary_large_image, and no duplicate
  "| Noel Sabia" suffix from SEO Utils
- add a committed 1200x630 OG card generated by pnpm og-image; the dynamic
  OG renderer and skew protection stay off for the static deployment
- pin the Node version @nuxtjs/seo 6 requires and document the setup in the
  OKF bundle
This commit is contained in:
Noel Sabia committed 2026-10-23 20:37:32 +02:00
1 parent 24460083ff
commit 1c3503fed0
18 files changed
+1765 -116

No files matched your search

+108
View File
@@ -0,0 +1,108 @@
// Generates public/favicon.svg and public/favicon.ico from the pixel avatar in
// app/utils/avatar.js, so the sprite exists once. Run with `pnpm favicon`.
//
// No image library: the sprite is 32x32 cells, so the ICO is written as an
// uncompressed 32bpp BMP inside a one-image ICO container (4.2 kB), and the SVG
// merges each run of same-coloured cells per row into one rect.
import { mkdirSync, writeFileSync } from 'node:fs'
import { join } from 'node:path'
import { AVATAR_PALETTE, AVATAR_SPRITE } from '../app/utils/avatar.js'
const SIZE = 32
// Same chip colour the logo sits on in the header, so the portrait stays
// readable on a dark browser tab bar. Set to null for a transparent icon.
const BACKGROUND = '#1b2b3f'
const OUT_DIR = join(import.meta.dirname, '..', 'public')
const hex = (value) => {
const n = Number.parseInt(value.slice(1), 16)
return [n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff]
}
const colorAt = (x, y) => {
const cell = AVATAR_SPRITE[y]?.[x] ?? '.'
return AVATAR_PALETTE[cell] ?? BACKGROUND
}
// --- SVG -------------------------------------------------------------------
const svg = () => {
const rects = []
for (let y = 0; y < SIZE; y++) {
let x = 0
while (x < SIZE) {
const color = colorAt(x, y)
let run = 1
while (x + run < SIZE && colorAt(x + run, y) === color) run++
if (color && color !== BACKGROUND) rects.push(`<rect x="${x}" y="${y}" width="${run}" height="1" fill="${color}"/>`)
x += run
}
}
const background = BACKGROUND
? `<rect width="${SIZE}" height="${SIZE}" fill="${BACKGROUND}"/>`
: ''
return [
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${SIZE} ${SIZE}" width="${SIZE}" height="${SIZE}" shape-rendering="crispEdges">`,
...(background ? [background] : []),
...rects,
'</svg>',
// Keep the trailing newline: the end-of-file-fixer pre-commit hook wants it.
'',
].join('\n')
}
// --- ICO -------------------------------------------------------------------
const ico = () => {
const xorSize = SIZE * SIZE * 4
const maskRow = Math.ceil(SIZE / 32) * 4
const maskSize = maskRow * SIZE
const bitmap = Buffer.alloc(40 + xorSize + maskSize)
bitmap.writeUInt32LE(40, 0) // BITMAPINFOHEADER size
bitmap.writeInt32LE(SIZE, 4) // width
bitmap.writeInt32LE(SIZE * 2, 8) // height: XOR image + AND mask
bitmap.writeUInt16LE(1, 12) // planes
bitmap.writeUInt16LE(32, 14) // bits per pixel
bitmap.writeUInt32LE(xorSize + maskSize, 20) // image size
// XOR bitmap: bottom-up rows of BGRA.
let offset = 40
for (let y = SIZE - 1; y >= 0; y--) {
for (let x = 0; x < SIZE; x++) {
const [r, g, b] = hex(colorAt(x, y) ?? '#000000')
bitmap[offset++] = b
bitmap[offset++] = g
bitmap[offset++] = r
bitmap[offset++] = 0xff
}
}
// AND mask stays zeroed: every pixel is opaque.
const header = Buffer.alloc(6)
header.writeUInt16LE(0, 0) // reserved
header.writeUInt16LE(1, 2) // type: icon
header.writeUInt16LE(1, 4) // image count
const entry = Buffer.alloc(16)
entry[0] = SIZE // width
entry[1] = SIZE // height
entry[2] = 0 // palette colours
entry[3] = 0 // reserved
entry.writeUInt16LE(1, 4) // planes
entry.writeUInt16LE(32, 6) // bits per pixel
entry.writeUInt32LE(bitmap.length, 8)
entry.writeUInt32LE(header.length + entry.length, 12)
return Buffer.concat([header, entry, bitmap])
}
// --- write -----------------------------------------------------------------
mkdirSync(OUT_DIR, { recursive: true })
const svgFile = join(OUT_DIR, 'favicon.svg')
const icoFile = join(OUT_DIR, 'favicon.ico')
writeFileSync(svgFile, svg())
writeFileSync(icoFile, ico())
console.log(`wrote ${svgFile} and ${icoFile}`)
+117
View File
@@ -0,0 +1,117 @@
// Generates public/og-image.png (1200x630) and its alt text from the site
// metadata and the pixel avatar. Run with `pnpm og-image`.
//
// Needs two system tools that the rest of the project does not:
// woff2_decompress (font/woff2) - turns the self-hosted woff2 files into
// TTF, because librsvg cannot read woff2
// rsvg-convert (librsvg) - rasterizes the SVG card
// The generated PNG is committed, so neither tool is needed to build or deploy.
import { execFileSync } from 'node:child_process'
import { copyFileSync, mkdirSync, writeFileSync } from 'node:fs'
import { join } from 'node:path'
import { SITE } from '../site.config.mjs'
import { AVATAR_PALETTE, AVATAR_SPRITE } from '../app/utils/avatar.js'
const WIDTH = 1200
const HEIGHT = 630
const ROOT = join(import.meta.dirname, '..')
const OUT_DIR = join(ROOT, 'public')
const FONT_DIR = join(ROOT, 'node_modules', '.cache', 'og-image-fonts')
// Brand fonts, normalised name -> file in public/fonts.
const FONTS = [
['Inter', 'inter-var.woff2'],
['JetBrains Mono', 'jetbrains-mono-var.woff2'],
// The variable Newsreader file carries its optical-size name.
['Newsreader 16pt', 'newsreader-var.woff2'],
]
// --- fonts -----------------------------------------------------------------
const prepareFonts = () => {
mkdirSync(FONT_DIR, { recursive: true })
for (const [, file] of FONTS) {
copyFileSync(join(ROOT, 'public', 'fonts', file), join(FONT_DIR, file))
execFileSync('woff2_decompress', [join(FONT_DIR, file)], { stdio: 'ignore' })
}
const conf = join(FONT_DIR, 'fonts.conf')
writeFileSync(conf, `<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir>${FONT_DIR}</dir>
<cachedir>${join(FONT_DIR, 'cache')}</cachedir>
</fontconfig>
`)
return conf
}
// --- card ------------------------------------------------------------------
const avatar = () => {
const scale = 8
const x = 88
const y = (HEIGHT - 32 * scale) / 2
const cells = []
for (let row = 0; row < 32; row++) {
for (let col = 0; col < 32; col++) {
const color = AVATAR_PALETTE[AVATAR_SPRITE[row][col]]
if (!color) continue
cells.push(
`<rect x="${col}" y="${row}" width="1" height="1" fill="${color}"/>`,
)
}
}
return [
// Chip, the same surface the avatar sits on in the header.
`<rect x="${x}" y="${y}" width="${32 * scale}" height="${32 * scale}" fill="#1b2b3f"/>`,
`<rect x="${x}" y="${y}" width="${32 * scale}" height="${32 * scale}" fill="none" stroke="#2a3a4f" stroke-width="1"/>`,
`<g transform="translate(${x} ${y}) scale(${scale})" shape-rendering="crispEdges">`,
...cells,
'</g>',
].join('\n')
}
const card = () => {
const textX = 400
const textRight = WIDTH - 88
const mono = `font-family="'JetBrains Mono', monospace"`
const sans = `font-family="'Inter', sans-serif"`
const serif = `font-family="'Newsreader 16pt', serif"`
return `<svg xmlns="http://www.w3.org/2000/svg" width="${WIDTH}" height="${HEIGHT}" viewBox="0 0 ${WIDTH} ${HEIGHT}">
<rect width="${WIDTH}" height="${HEIGHT}" fill="#031428"/>
<rect x="24" y="24" width="${WIDTH - 48}" height="${HEIGHT - 48}" fill="none" stroke="#1b2b3f" stroke-width="1"/>
${avatar()}
<circle cx="${textX + 5}" cy="194" r="5" fill="#4ae176"/>
<text x="${textX + 22}" y="200" ${mono} font-size="16" letter-spacing="3" fill="#a9c9f7">SYS_ORCHESTRATOR // RESILIENCE LABS</text>
<text x="${textX}" y="312" ${serif} font-size="88" fill="#d3e4ff">${SITE.name}</text>
<text x="${textX}" y="362" ${sans} font-size="27" fill="#c3c6cf">${SITE.role}</text>
<line x1="${textX}" y1="400" x2="${textRight}" y2="400" stroke="#1b2b3f" stroke-width="1"/>
<text x="${textX}" y="446" ${sans} font-size="21" fill="#8d9199">Every chapter runs as a real Kubernetes workload —</text>
<text x="${textX}" y="478" ${sans} font-size="21" fill="#8d9199">knock it down and watch it recover.</text>
<circle cx="${textX + 5}" cy="552" r="5" fill="#4ae176"/>
<text x="${textX + 22}" y="558" ${mono} font-size="18" fill="#c3c6cf">noelsabia.dev</text>
<text x="${textRight}" y="558" ${mono} font-size="14" letter-spacing="2" fill="#8d9199" text-anchor="end">CV // ${new Date().getUTCFullYear()}</text>
</svg>
`
}
// --- write -----------------------------------------------------------------
const fontsConf = prepareFonts()
const svgFile = join(FONT_DIR, 'og-image.svg')
const pngFile = join(OUT_DIR, 'og-image.png')
writeFileSync(svgFile, card())
execFileSync(
'rsvg-convert',
['-w', String(WIDTH), '-h', String(HEIGHT), svgFile, '-o', pngFile],
{ env: { ...process.env, FONTCONFIG_FILE: fontsConf }, stdio: 'inherit' },
)
writeFileSync(
join(OUT_DIR, 'og-image.alt.txt'),
`${SITE.name} — ${SITE.role}. Pixel portrait next to the CV title, with the line "Every chapter runs as a real Kubernetes workload — knock it down and watch it recover."\n`,
)
console.log(`wrote ${pngFile} and ${join(OUT_DIR, 'og-image.alt.txt')}`)