Skip to content

Feat: Enhance metadata handling in BaseHead and layout components - #16

Open
julienG-48 wants to merge 1 commit into
WhitePaper233:mainfrom
julienG-48:dynamic-metadata-og
Open

Feat: Enhance metadata handling in BaseHead and layout components#16
julienG-48 wants to merge 1 commit into
WhitePaper233:mainfrom
julienG-48:dynamic-metadata-og

Conversation

@julienG-48

Copy link
Copy Markdown

Problem

Currently, BaseHead.astro uses static values from YukinaConfig for all pages:

  • The page title is always the site title, never the article/page title
  • og:image and twitter:image tags were commented out and never rendered

Solution

  • Add optional title, description, and image props to BaseHead and BaseLayout
  • Build page title dynamically: Page Title | Site Title (falls back to site title)
  • Enable OG and Twitter image tags when an image is provided
  • Pass title, subTitle, and bannerImage from MainLayout through the chain

This allows individual pages and posts to have proper social sharing previews.

@vercel

vercel Bot commented Apr 9, 2026

Copy link
Copy Markdown

@Lozweb is attempting to deploy a commit to the WhitePaper233's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Apr 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
yukina Ready Ready Preview, Comment Apr 18, 2026 3:34pm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances per-page metadata support by allowing layouts/components to pass dynamic title/description/image values down to BaseHead, enabling better SEO and social sharing previews across pages and posts.

Changes:

  • Add optional title, description, and image props to BaseHead and BaseLayout.
  • Build a dynamic page title (Page Title | Site Title) and fall back to site defaults for description.
  • Render og:image and twitter:image tags when an image is provided, and thread metadata from MainLayout.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/layouts/MainLayout.astro Passes title/subTitle/bannerImage into the base layout as head metadata inputs.
src/layouts/BaseLayout.astro Accepts metadata props and forwards them to BaseHead.
src/components/BaseHead.astro Computes dynamic title/description and conditionally outputs OG/Twitter image tags.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 49 to 69
<link
rel="alternate"
type="application/rss+xml"
title={YukinaConfig.title}
href={new URL("rss.xml", Astro.site)}
rel="alternate"
type="application/rss+xml"
title={YukinaConfig.title}
href={new URL("rss.xml", Astro.site)}
/>

<!-- SiteMap -->
<link rel="sitemap" href="/sitemap-index.xml" />

<!-- CSS -->
<link
rel="stylesheet"
href="https://fastly.jsdelivr.net/npm/katex/dist/katex.min.css"
rel="stylesheet"
href="https://fastly.jsdelivr.net/npm/katex/dist/katex.min.css"
/>
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.bunny.net" />
<link
href="https://fonts.bunny.net/css?family=noto-sans-sc:100,200,300,400,500,600,700,800,900|raleway:500,700"
rel="stylesheet"
href="https://fonts.bunny.net/css?family=noto-sans-sc:100,200,300,400,500,600,700,800,900|raleway:500,700"
rel="stylesheet"
/>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Comment on lines +24 to +31
YukinaConfig.bannerStyle == "LOOP" && (
<Banner
title={props.title}
subTitle={props.subTitle}
bannerImage={props.bannerImage}
slug={props.slug}
/>
)
Comment on lines +15 to +17
<BaseHead title={title} description={description} image={image} />
<body class="overflow-y-hidden">
<slot />
Comment on lines 42 to +46
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:url" content={Astro.url} />
<meta property="twitter:title" content={YukinaConfig.title} />
<meta property="twitter:description" content={YukinaConfig.description} />
<!-- <meta property="twitter:image" content={new URL(image, Astro.url)} /> -->
<meta property="twitter:title" content={pageTitle} />
<meta property="twitter:description" content={pageDescription} />
{ogImage && <meta property="twitter:image" content={ogImage} />}
@julienG-48

Copy link
Copy Markdown
Author

Hi, I'm currently on vacation. I'll review all the comments and address them when I'm back in approximately two weeks.

@WhitePaper233

WhitePaper233 commented Apr 20, 2026

Copy link
Copy Markdown
Owner

Hi, I'm currently on vacation. I'll review all the comments and address them when I'm back in approximately two weeks.

Thank you for the contribution. The comment above was actually generated by GitHub Copilot. I’ll take care of addressing the remaining points and handle the final merge when I have some time. There’s no need for you to make any further changes or follow-ups on this PR.

Wishing you a wonderful vacation!

@WhitePaper233 WhitePaper233 self-assigned this Apr 20, 2026
@WhitePaper233 WhitePaper233 added the bug Something isn't working label Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants