From 8be3434d32d7ed9046000377f7f9e59ef2a971b3 Mon Sep 17 00:00:00 2001 From: Pauline Date: Wed, 10 Jan 2024 19:58:58 -0500 Subject: super unfinished stuff but i was getting yelled at by wybest --- apps/website/src/components/base/Footer.astro | 2 +- apps/website/src/components/shared/BaseHead.astro | 15 ++++ apps/website/src/components/shared/SEO.astro | 89 +++++++++++++++++++++++ 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 apps/website/src/components/shared/BaseHead.astro create mode 100644 apps/website/src/components/shared/SEO.astro (limited to 'apps/website/src/components') diff --git a/apps/website/src/components/base/Footer.astro b/apps/website/src/components/base/Footer.astro index 9463edc..7a9071a 100644 --- a/apps/website/src/components/base/Footer.astro +++ b/apps/website/src/components/base/Footer.astro @@ -41,7 +41,7 @@ const props = Astro.props;

© {new Date().getFullYear()} Polyfrost. All rights reserved.

-

Not affiliated with Mojang Studios.

+

Not an official Minecraft product. Not approved by or affiliated with Mojang Studios.

diff --git a/apps/website/src/components/shared/BaseHead.astro b/apps/website/src/components/shared/BaseHead.astro new file mode 100644 index 0000000..ddb94e3 --- /dev/null +++ b/apps/website/src/components/shared/BaseHead.astro @@ -0,0 +1,15 @@ +--- +import smartypants from 'smartypants'; +import SEO from './SEO.astro'; + +export type Props = { + siteName: string + title?: string + description: string + image: { src: string, alt: string } + canonicalURL?: URL | null + pageType?: 'website' | 'article' +}; + +const twitterHandle = 'polyfrost'; +--- diff --git a/apps/website/src/components/shared/SEO.astro b/apps/website/src/components/shared/SEO.astro new file mode 100644 index 0000000..6169185 --- /dev/null +++ b/apps/website/src/components/shared/SEO.astro @@ -0,0 +1,89 @@ +--- +import smartypants from 'smartypants'; + +type SEOMetadata = { + name?: string + title: string + description: string + image?: { src: string, alt: string } + canonicalURL?: URL | null + locale?: string +}; + +type OpenGraph = Partial & { + type?: string +}; + +type Twitter = Partial & { + handle?: string + card?: 'summary' | 'summary_large_image' +}; + +export type Props = SEOMetadata & { + og?: OpenGraph + twitter?: Twitter +}; + +const { + name, + description, + image, + locale = 'en', + canonicalURL = new URL(Astro.url.pathname, Astro.site), + og: _og = {}, + twitter: _twitter = {}, +} = Astro.props; + +const title = [Astro.props.title, name].filter(Boolean).join(' | '); +const og: OpenGraph = { name, title, description, canonicalURL, image, locale, type: 'website', ..._og }; +const twitter: Twitter = { name, title, description, canonicalURL, image, locale, card: 'summary_large_image', ..._twitter }; +const ensureSlash = (url: string | URL) => `${url.toString().replace(/\/$/, '')}/`; +--- + + + + + + + + + + + + + +<!-- Page Metadata --> +<meta name="generator" content={Astro.generator} /> +{canonicalURL && <link rel="canonical" href={ensureSlash(canonicalURL)} />} +<title>{title} + + + + + +{og.canonicalURL && } + + + +{ + og.image && ( + <> + + + + ) +} + + +{twitter.card && } +{twitter.handle && } + + +{ + twitter.image && ( + <> + + + + ) +} -- cgit