Connor McCutcheon
/ Music
HeadSEO.astro
astro
---
import { SITE, OPEN_GRAPH, type Frontmatter } from '../config';
export interface Props {
  frontmatter: Frontmatter;
  canonicalUrl: URL;
}
const { frontmatter, canonicalUrl } = Astro.props as Props;
const formattedContentTitle = `${frontmatter.title} 🚀 ${SITE.title}`;
const imageSrc = frontmatter.image?.src ?? OPEN_GRAPH.image.src;
const canonicalImageSrc = new URL(imageSrc, Astro.site);
const imageAlt = frontmatter.image?.alt ?? OPEN_GRAPH.image.alt;
---
<!-- Page Metadata -->
<link rel="canonical" href={canonicalUrl} />
<!-- OpenGraph Tags -->
<meta property="og:title" content={formattedContentTitle} />
<meta property="og:type" content="article" />
<meta property="og:url" content={canonicalUrl} />
<meta property="og:locale" content={frontmatter.ogLocale ?? SITE.defaultLanguage} />
<meta property="og:image" content={canonicalImageSrc} />
<meta property="og:image:alt" content={imageAlt} />
<meta name="description" property="og:description" content={frontmatter.description ?? SITE.description} />
<meta property="og:site_name" content={SITE.title} />
No comments yet.