Skip to content

Commit

Permalink
feat: add custom head tags for each page
Browse files Browse the repository at this point in the history
  • Loading branch information
MaevaWolff committed Aug 15, 2023
1 parent 331ad79 commit 430062f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
14 changes: 2 additions & 12 deletions src/components/seo/SEOTags.astro
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
9 changes: 4 additions & 5 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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;
---

<!DOCTYPE html>
<html lang="en">
<SEOTags title={title} />
<SEOTags {...headTags} />

<body
class="mx-auto flex min-h-screen max-w-[872px] flex-col gap-9 bg-neutral-950 px-10 py-8 text-sm text-neutral-400 md:gap-20 md:py-16"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/posts/[slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const { post } = Astro.props;
const { Content } = await post.render();
---

<Layout title={post.data.title}>
<Layout title={post.data.title} description={post.data.description}>
<main class="post mx-auto flex w-full max-w-prose flex-col gap-4">
<header role="presentation">
<h1 class="text-md">
Expand Down
12 changes: 12 additions & 0 deletions src/utils/types/HeadTags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export type HeadTags = {
title?: string;
description?: string;
noindex?: boolean;
og?: {
title: string;
type: string;
description: string;
image: string;
alt: string;
};
};

1 comment on commit 430062f

@vercel
Copy link

@vercel vercel bot commented on 430062f Aug 15, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.