From c89ed0f7f9dcf14d1d96ad0d13ad59f5b542396e Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 11 Sep 2024 22:03:55 +0000 Subject: Update default title and description --- src/components/Comments.astro | 4 +--- src/components/Head.astro | 15 +++++++++------ src/env.d.ts | 8 ++++++++ src/layouts/BaseLayout.astro | 4 +++- src/layouts/PageLayout.astro | 4 +++- src/pages/blog/[...slug].astro | 2 +- src/pages/feed.xml.js | 4 ++-- 7 files changed, 27 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/components/Comments.astro b/src/components/Comments.astro index 5fcd65d..f9ae4e5 100644 --- a/src/components/Comments.astro +++ b/src/components/Comments.astro @@ -14,7 +14,6 @@ const theme = "transparent_dark"; --- +> diff --git a/src/components/Head.astro b/src/components/Head.astro index bc5609f..42ae32b 100644 --- a/src/components/Head.astro +++ b/src/components/Head.astro @@ -1,17 +1,20 @@ --- const canonicalURL = new URL(Astro.url.pathname, Astro.site); + +const { title, description } = Astro.props; --- - - - - - + + + + + + - Title + {title ?? import.meta.env.DEFAULT_TITLE} diff --git a/src/env.d.ts b/src/env.d.ts index e16c13c..d714331 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -1 +1,9 @@ /// +interface ImportMetaEnv { + readonly DEFAULT_TITLE: string; + readonly DEFAULT_DESCRIPTION: string; +} + +interface ImportMeta { + readonly env: ImportMetaEnv; +} diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index 5a73ac6..5cbaf5c 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -1,10 +1,12 @@ --- import Head from "../components/Head.astro"; import Header from "../components/Header.astro"; + +const { title, description } = Astro.props; --- - +
diff --git a/src/layouts/PageLayout.astro b/src/layouts/PageLayout.astro index 3730334..eff37fb 100644 --- a/src/layouts/PageLayout.astro +++ b/src/layouts/PageLayout.astro @@ -1,7 +1,9 @@ --- import BaseLayout from "./BaseLayout.astro"; + +const { title, description } = Astro.props; --- - + diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index 2593921..f99ef21 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -22,7 +22,7 @@ const { Content, remarkPluginFrontmatter } = await post.render(); } - +

{post.data.title}

diff --git a/src/pages/feed.xml.js b/src/pages/feed.xml.js index a509386..c837202 100644 --- a/src/pages/feed.xml.js +++ b/src/pages/feed.xml.js @@ -6,7 +6,7 @@ export async function GET(context) { return rss({ customData: `ru-ru`, - description: "Tech insights and coding best practices from an OpenSource enthusiast and ethical hacker.", + description: import.meta.env.DEFAULT_DESCRIPTION, items: posts.map((post) => ({ customData: post.data.customData, description: post.data.description, @@ -15,6 +15,6 @@ export async function GET(context) { title: post.data.title, })), site: context.site, - title: "Valentin Popov’s Technology Blog", + title: import.meta.env.DEFAULT_TITLE, }); } -- cgit v1.2.3