From 430062f260f4e895022ab57a1281cb0fc0f7920f Mon Sep 17 00:00:00 2001 From: MaevaWolff Date: Tue, 15 Aug 2023 09:35:09 +0200 Subject: [PATCH] feat: add custom head tags for each page --- src/components/seo/SEOTags.astro | 14 ++------------ src/layouts/Layout.astro | 9 ++++----- src/pages/posts/[slug].astro | 2 +- src/utils/types/HeadTags.ts | 12 ++++++++++++ 4 files changed, 19 insertions(+), 18 deletions(-) create mode 100644 src/utils/types/HeadTags.ts diff --git a/src/components/seo/SEOTags.astro b/src/components/seo/SEOTags.astro index c86eda4..3288aae 100644 --- a/src/components/seo/SEOTags.astro +++ b/src/components/seo/SEOTags.astro @@ -1,19 +1,9 @@ --- import { SEO } from "astro-seo"; import { SITE_URL } from "@/data/config"; +import type { HeadTags } from "@/utils/types/HeadTags"; -type Props = { - title?: string; - description?: string; - noindex?: boolean; - og?: { - title: string; - type: string; - description: string; - image: string; - alt: string; - }; -}; +type Props = HeadTags; const { title, description, noindex, og } = Astro.props; diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 4a7b7e5..494b16f 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -3,21 +3,20 @@ import Header from "../components/Header.astro"; import BlurCircle from "@/components/shared/BlurCircle.astro"; import theme from "@/data/theme"; import SEOTags from "@/components/seo/SEOTags.astro"; +import type { HeadTags } from "@/utils/types/HeadTags"; import "@fontsource/open-sans"; import "@/styles/tailwind.css"; import "@/styles/post.css"; -export interface Props { - title?: string; -} +export type Props = HeadTags; -const { title } = Astro.props; +const headTags = Astro.props; --- - + +

diff --git a/src/utils/types/HeadTags.ts b/src/utils/types/HeadTags.ts new file mode 100644 index 0000000..abbf3d4 --- /dev/null +++ b/src/utils/types/HeadTags.ts @@ -0,0 +1,12 @@ +export type HeadTags = { + title?: string; + description?: string; + noindex?: boolean; + og?: { + title: string; + type: string; + description: string; + image: string; + alt: string; + }; +};