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
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:
1 parent
24460083ff
commit
1c3503fed0
18 files changed
+1765
-116
No files matched your search
@@ -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')}`)
|
||||
Reference in new issue
Block a user