From bb57b3b63f378400cde5d0c585e4d9cd16875ec2 Mon Sep 17 00:00:00 2001 From: prototypa Date: Fri, 6 Jan 2023 13:18:21 -0500 Subject: [PATCH] Set default titleTemplate --- src/components/common/MetaTags.astro | 9 +++++++-- src/pages/404.astro | 3 +-- src/pages/[...blog]/[...page].astro | 2 +- src/pages/[...blog]/[slug].astro | 2 +- src/pages/[...categories]/[category]/[...page].astro | 2 +- src/pages/[...tags]/[tag]/[...page].astro | 2 +- src/pages/index.astro | 1 + 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/components/common/MetaTags.astro b/src/components/common/MetaTags.astro index b1b5ae0..3c3dd24 100644 --- a/src/components/common/MetaTags.astro +++ b/src/components/common/MetaTags.astro @@ -11,6 +11,10 @@ import SplitbeeAnalytics from './SplitbeeAnalytics.astro'; import { MetaSEO } from '~/types'; +export interface Props extends MetaSEO { + dontUseTitleTemplate?: boolean; +} + const defaultImage = SITE.defaultImage ? ( await getImage({ @@ -22,8 +26,6 @@ const defaultImage = SITE.defaultImage ).src : ''; -export interface Props extends MetaSEO {} - const { title = SITE.name, description = '', @@ -35,6 +37,8 @@ const { ogTitle = title, ogType = 'website', + + dontUseTitleTemplate = false, } = Astro.props; const image = @@ -51,6 +55,7 @@ const image = diff --git a/src/pages/[...blog]/[...page].astro b/src/pages/[...blog]/[...page].astro index 69cf92a..27fbd4d 100644 --- a/src/pages/[...blog]/[...page].astro +++ b/src/pages/[...blog]/[...page].astro @@ -22,7 +22,7 @@ const { page } = Astro.props; const currentPage = page.currentPage ?? 1; const meta = { - title: `Blog ${currentPage > 1 ? `— Page ${currentPage} ` : ''}— ${SITE.name}`, + title: `Blog${currentPage > 1 ? ` — Page ${currentPage}` : ''}`, description: SITE.description, canonical: getCanonical(getPermalink(BLOG?.blog?.pathname)), ogType: 'blog', diff --git a/src/pages/[...blog]/[slug].astro b/src/pages/[...blog]/[slug].astro index ee972d4..0cb92de 100644 --- a/src/pages/[...blog]/[slug].astro +++ b/src/pages/[...blog]/[slug].astro @@ -25,7 +25,7 @@ const { post } = Astro.props; const url = getCanonical(getPermalink(post.slug, 'post')); const meta = { - title: `${post.title} — ${SITE.name}`, + title: post.title, description: post.description, canonical: post.canonical || url, image: await findImage(post.image), diff --git a/src/pages/[...categories]/[category]/[...page].astro b/src/pages/[...categories]/[category]/[...page].astro index 1b70f32..3c25840 100644 --- a/src/pages/[...categories]/[category]/[...page].astro +++ b/src/pages/[...categories]/[category]/[...page].astro @@ -34,7 +34,7 @@ const { page, category } = Astro.props; const currentPage = page.currentPage ?? 1; const meta = { - title: `Category '${category}' ${currentPage > 1 ? `— Page ${currentPage} ` : ''}— ${SITE.name}`, + title: `Category'${category}' ${currentPage > 1 ? ` — Page ${currentPage}` : ''}`, description: SITE.description, canonical: getCanonical(getPermalink(category, 'category')), noindex: true, diff --git a/src/pages/[...tags]/[tag]/[...page].astro b/src/pages/[...tags]/[tag]/[...page].astro index f6c5b2c..5becf41 100644 --- a/src/pages/[...tags]/[tag]/[...page].astro +++ b/src/pages/[...tags]/[tag]/[...page].astro @@ -34,7 +34,7 @@ const { page, tag } = Astro.props; const currentPage = page.currentPage ?? 1; const meta = { - title: `Posts by tag '${tag}' ${currentPage > 1 ? `— Page ${currentPage} ` : ''}— ${SITE.name}`, + title: `Posts by tag '${tag}'${currentPage > 1 ? ` — Page ${currentPage} ` : ''}`, description: SITE.description, canonical: getCanonical(getPermalink(tag, 'tag')), noindex: true, diff --git a/src/pages/index.astro b/src/pages/index.astro index e2ff48d..febe535 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -18,6 +18,7 @@ const meta = { title: SITE.title, description: SITE.description, canonical: getCanonical(getHomePermalink()), + dontUseTitleTemplate: true, }; ---