fix(pinner.xyz): fix transparent navbar on subpages and per-post OG images#1103
Conversation
…mages Two bugs fixed: 1. Transparent navbar on subpages: 18 pages (solutions, alternatives, contact, how-it-works, partners, pricing, 404) used <Layout> without navTheme='dark', causing dark nav text on dark body background (invisible menu). Added navTheme='dark' to all affected pages. 2. Blog post OG images: blog post singles fell back to the generic blog-default.png OG card. Added per-post OG image generation endpoint that uses the post title as headline and description as subtitle (capped at 160 chars). Updated [...slug].astro to use per-post OG image path when no custom ogImage is set in frontmatter.
This comment has been minimized.
This comment has been minimized.
| export const getStaticPaths: GetStaticPaths = async () => { | ||
| const posts = await getCollection("blog", ({ data }) => { | ||
| return import.meta.env.PROD ? data.draft !== true : true; | ||
| }); | ||
|
|
||
| return posts.map((post) => ({ | ||
| params: { slug: post.id }, | ||
| })); |
There was a problem hiding this comment.
Routing mismatch in apps/pinner.xyz/src/pages/images/og/blog/[slug].png.ts causes og:image URLs for nested blog posts with post.id values containing / to 404, because /images/og/blog/2024/my-post.png does not match the single-segment [slug].png.ts route. Renaming the endpoint to [...slug].png.ts keeps params.slug unchanged and aligns the image route with [...slug].astro.
// file: apps/pinner.xyz/src/pages/images/og/blog/[...slug].png.ts
export const getStaticPaths: GetStaticPaths = async () => {
...
return posts.map((post) => ({
params: { slug: post.id },
}));
};
export const GET: APIRoute = async ({ params }) => {
...
const post = posts.find((p) => p.id === params.slug);Prompt for LLM
File apps/pinner.xyz/src/pages/images/og/blog/[slug].png.ts:
Line 5 to 12:
Routing mismatch in apps/pinner.xyz/src/pages/images/og/blog/[slug].png.ts causes og:image URLs for nested blog posts with `post.id` values containing `/` to 404, because `/images/og/blog/2024/my-post.png` does not match the single-segment `[slug].png.ts` route. Renaming the endpoint to `[...slug].png.ts` keeps `params.slug` unchanged and aligns the image route with `[...slug].astro`.
Suggested Code:
// file: apps/pinner.xyz/src/pages/images/og/blog/[...slug].png.ts
export const getStaticPaths: GetStaticPaths = async () => {
...
return posts.map((post) => ({
params: { slug: post.id },
}));
};
export const GET: APIRoute = async ({ params }) => {
...
const post = posts.find((p) => p.id === params.slug);
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
Kody review: [slug].png.ts would 404 for nested blog post IDs containing /. Rename to [...slug].png.ts to match [...slug].astro. See: #1103
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Bug Description
Two bugs introduced after the last site update:
blog-default.pngOG social card instead of reflecting the post content.Root Cause
Navbar
18 subpages used
<Layout>without passingnavTheme="dark". The Layout defaults tovariant="content"which gives the navbar light-theme text (rgb(13, 29, 28)— dark teal), but the body background is alsorgb(13, 29, 28). Dark text on dark background = invisible menu.Blog OG
Blog post singles passed
ogImage={post.data.ogImage}which isundefined(not set in frontmatter), so BlogLayout fell back to/images/og/blog-default.pngfor every post.Fix
Navbar
Added
navTheme="dark"to all 18 affected<Layout>tags, switching navbar text to white (rgb(248, 248, 248)) — readable on dark hero backgrounds.Pages fixed: 404, contact, how-it-works, partners, pricing, all solutions/* (5), all alternatives/* (7).
Blog OG
src/pages/images/og/blog/[slug].png.ts— generates a per-post OG image using the post title as headline and description as subtitle (capped at 160 chars for readability)src/pages/blog/[...slug].astroto usepost.data.ogImage ?? /images/og/blog/${post.id}.pngHow to Verify
/solutions/ipfs-pinning/— navbar links should be white and readable against the dark hero/alternatives/pinata/— same check/blog/content-addressed-storage/— checkog:imagemeta tag resolves to/images/og/blog/content-addressed-storage.png(notblog-default.png)pnpm build --filter=@lumeweb/pinner.xyz— build passes, OG image generated at build timeTest Plan
pnpm build --filter=@lumeweb/pinner.xyz)rgb(248, 248, 248)on solutions and alternatives pagesog:imagepoints to per-post imageRisk Assessment
Low — Changes are prop additions to existing Layout components (no logic changes) and a new build-time OG image endpoint. No runtime behavior changes, no API changes, no breaking changes.
This PR fixes two issues on the pinner.xyz site:
Transparent navbar on subpages: Adds
navTheme="dark"to the Layout component across all subpages (404, alternatives, contact, how-it-works, partners, pricing, solutions, etc.) to ensure the navbar has a proper dark theme rather than appearing transparent.Per-post OG images for blog: Adds a dynamic OG image generator (
/images/og/blog/[slug].png.ts) that automatically creates Open Graph images for blog posts using the post title and description. The blog post template now falls back to these generated images when a customogImageis not specified in the post's frontmatter.