opencode/packages/nav-menus/script/brand.ts
David Hill e45af15e84
feat(site): add the shared product and logo menus to every nav (#62654)
Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com>
2026-11-07 22:06:29 +00:00

17 lines
932 B
TypeScript

// Writes src/brand.ts from the site's logo files (services/site/src/asset/brand), so the menu carries
// them inline and works on any host: run `bun script/brand.ts` after the brand files change.
const source = new URL("../../../services/site/src/asset/brand/", import.meta.url)
const files = await Promise.all(
(["transparent", "solid"] as const).flatMap((style) =>
(["logo", "wordmark"] as const).flatMap((kind) =>
(["light", "dark"] as const).map(async (tone) => {
const svg = await Bun.file(new URL(`opencode-${kind}-${style}-${tone}.svg`, source)).text()
return ` "${kind}-${style}-${tone}": ${JSON.stringify(svg.replace(/\n/g, "").trim())},`
}),
),
),
)
await Bun.write(
new URL("../src/brand.ts", import.meta.url),
`// Generated by script/brand.ts from services/site/src/asset/brand. Do not edit.\nexport const brandSvgs: Record<string, string> = {\n${files.join("\n")}\n}\n`,
)