Skip to content

BaseHead

rhiskey edited this page Jun 5, 2023 · 1 revision
---
// Import the global.css file here so that it is included on
// all pages through the use of the <BaseHead /> component.
import '../../styles/global.css';

export interface Props {
    title: string;
    description: string;
    imageUrl: string;
    slug: string;
    tags: [];
}

const canonicalURL = new URL(Astro.url.pathname, Astro.site);
const {title, description, pubDate, tags, imageUrl, slug} = Astro.props;
const ogImageFromSlug = slug !== undefined ? new URL(`/custom-open-graph/articles/${slug}.png`, Astro.site) : new URL(`/social-image.png`, Astro.site)
---
<!-- Global Metadata -->
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<link rel="icon" sizes="any" type="image/svg+xml" href="/favicon.svg"/>

<!-- Canonical URL -->
<link rel="canonical" href={canonicalURL}/>

<!-- Primary Meta Tags -->
<title>{title}</title>
<meta name="title" content={title}/>
<meta name="description" content={description}/>

<!-- Open Graph / Facebook -->
<meta property="og:type" content="article"/>
<meta property="og:url" content={Astro.url}/>
<meta property="og:title" content={title}/>
<meta property="og:description" content={description}/>
<meta property="og:image" content={ogImageFromSlug}/>
<meta property="og:image:secure_url" content={ogImageFromSlug}/>

<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image"/>
<meta property="twitter:image" content={ogImageFromSlug}/>

<meta aria-description=""/>

Clone this wiki locally