Fix title and description tags

This commit is contained in:
Mikkel Svartveit 2023-10-30 23:01:19 -07:00
parent e7e6276334
commit bf578e4d80
4 changed files with 12 additions and 8 deletions

View file

@ -4,13 +4,14 @@ import RootLayout from "./RootLayout.astro";
interface Props { interface Props {
title?: string; title?: string;
description?: string;
noStickyNavbar?: boolean; noStickyNavbar?: boolean;
} }
const { title, noStickyNavbar } = Astro.props; const { title, description, noStickyNavbar } = Astro.props;
--- ---
<RootLayout {title}> <RootLayout {title} {description}>
<Navbar <Navbar
client:load client:load
sticky={!noStickyNavbar} sticky={!noStickyNavbar}

View file

@ -3,11 +3,12 @@ import { ViewTransitions } from "astro:transitions";
interface Props { interface Props {
title?: string; title?: string;
description?: string;
hideScrollbar?: boolean; hideScrollbar?: boolean;
themeColor?: string; themeColor?: string;
} }
const { title, hideScrollbar, themeColor } = Astro.props; const { title, description, hideScrollbar, themeColor } = Astro.props;
const fullTitle = `${title ? title + " " : ""}Mikkel Svartveit`; const fullTitle = `${title ? title + " " : ""}Mikkel Svartveit`;
--- ---
@ -21,7 +22,8 @@ const fullTitle = `${title ? title + " " : ""}Mikkel Svartveit`;
<title>{fullTitle}</title> <title>{fullTitle}</title>
<meta <meta
name="description" name="description"
content="Hi, I'm Mikkel! I am a Computer Science student from Norway and this is my playground. Here you will find some programming projects, and a small collection of photos I'm proud of." content={description ??
"Hi, I'm Mikkel! I am a Computer Science student from Norway and this is my playground. Here you will find some programming projects, and a small collection of photos I'm proud of."}
/> />
<meta name="theme-color" content={themeColor ?? "#facc15"} /> <meta name="theme-color" content={themeColor ?? "#facc15"} />
<ViewTransitions fallback="swap" /> <ViewTransitions fallback="swap" />

View file

@ -17,11 +17,12 @@ export const getStaticPaths = (async () => {
}) satisfies GetStaticPaths; }) satisfies GetStaticPaths;
const project = Astro.props.entry; const project = Astro.props.entry;
const { Content } = await project.render(); const { Content, headings } = await project.render();
const { title, date } = project.data; const { date, intro } = project.data;
const title = headings[0].text;
--- ---
<BaseLayout {title}> <BaseLayout {title} description={intro}>
<ContainerLayout> <ContainerLayout>
<TextContentLayout> <TextContentLayout>
<p class="mx-auto mb-4 text-gray-500"> <p class="mx-auto mb-4 text-gray-500">

View file

@ -9,7 +9,7 @@ import { getCollection } from "astro:content";
const articles = await getCollection("blog"); const articles = await getCollection("blog");
--- ---
<BaseLayout title="Programming"> <BaseLayout title="Articles">
<ContainerLayout> <ContainerLayout>
<TextContentLayout> <TextContentLayout>
<h1 <h1