Skip to content

feat: add metadata#35

Open
cytronicoder wants to merge 13 commits into
ScottyLabs:mainfrom
cytronicoder:add-metadata
Open

feat: add metadata#35
cytronicoder wants to merge 13 commits into
ScottyLabs:mainfrom
cytronicoder:add-metadata

Conversation

@cytronicoder
Copy link
Copy Markdown
Contributor

@cytronicoder cytronicoder commented Apr 7, 2026

Closes #28

@cytronicoder cytronicoder marked this pull request as ready for review April 7, 2026 15:18
@cytronicoder cytronicoder requested a review from TenType as a code owner April 7, 2026 15:18
Copilot AI review requested due to automatic review settings April 7, 2026 15:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds SEO/social-sharing metadata to the site layout so links render rich previews (Open Graph + Twitter cards), addressing issue #28.

Changes:

  • Introduces resolved title/description defaults for pages missing frontmatter values.
  • Adds canonical URL, Open Graph tags, and Twitter card tags (including image URL resolution).
  • Updates the document <title> to use the resolved title.

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

Comment thread src/layouts/Layout.astro Outdated
currentPath = currentPath.slice(0, -1);
}

const pageUrl = Astro.url.toString();
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

currentPath is normalized to remove a trailing slash, but pageUrl (used for canonical/og:url/twitter:url) is taken directly from Astro.url.toString() and can still include the trailing slash (and any search/hash). This can lead to canonical/OG URLs that don’t match the normalized route and can produce inconsistent embeds/SEO. Consider constructing pageUrl from Astro.url after you normalize currentPath (and clearing search/hash) so the canonical and og:url reflect the same normalized URL.

Suggested change
const pageUrl = Astro.url.toString();
const normalizedPageUrl = new URL(Astro.url);
normalizedPageUrl.pathname = currentPath;
normalizedPageUrl.search = "";
normalizedPageUrl.hash = "";
const pageUrl = normalizedPageUrl.toString();

Copilot uses AI. Check for mistakes.
@TenType TenType marked this pull request as draft April 7, 2026 22:44
now built from cloned Astro.url after currentPath normalization with search and hash cleared
@cytronicoder
Copy link
Copy Markdown
Contributor Author

How the image should look like:

image

Going to test the embed in Discord after I deploy my fork onto Vercel

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


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

Comment thread src/pages/og/[slug].png.ts
Comment thread src/pages/og/[slug].png.ts Outdated
return new Response(png, {
headers: {
"Content-Type": "image/png",
"Cache-Control": "public, max-age=31536000, immutable",
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

Cache-Control: public, max-age=31536000, immutable will cause clients/CDNs to cache these OG images for a year even though the URL is not content-addressed (it won’t change when title/description/category change). Consider removing immutable and/or using a shorter max-age (or s-maxage with revalidation) so metadata image updates propagate after redeploys.

Suggested change
"Cache-Control": "public, max-age=31536000, immutable",
"Cache-Control": "public, max-age=3600",

Copilot uses AI. Check for mistakes.
Comment thread src/layouts/Layout.astro Outdated
Comment on lines +14 to +20
const title = frontmatter.title as string;
const description = frontmatter.description as string;
const defaultTitle = "cmu.guide";
const defaultDescription =
"Your go-to guide for navigating the Tartan life, academics, and beyond!";
const resolvedTitle = title?.trim() || defaultTitle;
const resolvedDescription = description?.trim() || defaultDescription;
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

frontmatter.title as string / frontmatter.description as string are cast to string, but the code now treats them as optional (via ?.trim() and title && ...). It would be safer to type them as string | undefined (or avoid the cast) so TypeScript can correctly model when title/description are absent.

Copilot uses AI. Check for mistakes.
@cytronicoder
Copy link
Copy Markdown
Contributor Author

We should be good to go!

image

@cytronicoder cytronicoder marked this pull request as ready for review April 30, 2026 15:38
@cytronicoder
Copy link
Copy Markdown
Contributor Author

  • Fix font issue if possible

@cytronicoder cytronicoder self-assigned this May 4, 2026
@cytronicoder
Copy link
Copy Markdown
Contributor Author

should be good to go!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Twitter and Open Graph metadata cards

2 participants