From 5266fe563d137febca1937c7a17673ac9749b6a6 Mon Sep 17 00:00:00 2001 From: Jewgeni Lewash Date: Fri, 8 Mar 2024 07:36:18 +0100 Subject: [PATCH] feat: add meta description --- src/layouts/BaseLayout.astro | 10 ++++++++-- src/pages/blog.astro | 4 +++- src/pages/blog/[...slug].astro | 7 +++++-- src/pages/index.astro | 4 +++- src/pages/recipes.astro | 4 +++- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index befed0a..4e8a5fd 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -2,11 +2,18 @@ import '@/styles/globals.css'; import Header from '@/components/layout/Header.astro'; import Footer from '@/components/layout/Footer.astro'; -const { title } = Astro.props; + +interface Props { + title: string; + description: string; +} +const { title, description } = Astro.props as Props; --- + {title} + @@ -14,7 +21,6 @@ const { title } = Astro.props; - {title}
diff --git a/src/pages/blog.astro b/src/pages/blog.astro index 8316503..09e45fa 100644 --- a/src/pages/blog.astro +++ b/src/pages/blog.astro @@ -5,7 +5,9 @@ import Heading from '@/components/ui/Heading.astro'; const allBlogposts = await getCollection('blog'); --- - +
Blog diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index fd9d5cf..1134c28 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -19,10 +19,13 @@ interface Props { const { entry } = Astro.props as Props; const { Content } = await entry.render(); const components = { table: Table }; -const { title } = entry.data; +const { title, description } = entry.data; + +const descriptionMeta = + description.length > 160 ? description.substring(0, 150) + '...' : description; --- - +

{title}

diff --git a/src/pages/index.astro b/src/pages/index.astro index 1bf87ff..ac88d69 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -8,7 +8,9 @@ import index1 from '@/assets/images/index-1.png'; import index2 from '@/assets/images/index-2.png'; --- - +
Deploy Your diff --git a/src/pages/recipes.astro b/src/pages/recipes.astro index 1603ed3..f6d9bc7 100644 --- a/src/pages/recipes.astro +++ b/src/pages/recipes.astro @@ -17,7 +17,9 @@ const recipes = await directus.request( ); --- - +
Recipes