Set default titleTemplate
This commit is contained in:
@ -11,6 +11,10 @@ import SplitbeeAnalytics from './SplitbeeAnalytics.astro';
|
|||||||
|
|
||||||
import { MetaSEO } from '~/types';
|
import { MetaSEO } from '~/types';
|
||||||
|
|
||||||
|
export interface Props extends MetaSEO {
|
||||||
|
dontUseTitleTemplate?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
const defaultImage = SITE.defaultImage
|
const defaultImage = SITE.defaultImage
|
||||||
? (
|
? (
|
||||||
await getImage({
|
await getImage({
|
||||||
@ -22,8 +26,6 @@ const defaultImage = SITE.defaultImage
|
|||||||
).src
|
).src
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
export interface Props extends MetaSEO {}
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
title = SITE.name,
|
title = SITE.name,
|
||||||
description = '',
|
description = '',
|
||||||
@ -35,6 +37,8 @@ const {
|
|||||||
|
|
||||||
ogTitle = title,
|
ogTitle = title,
|
||||||
ogType = 'website',
|
ogType = 'website',
|
||||||
|
|
||||||
|
dontUseTitleTemplate = false,
|
||||||
} = Astro.props;
|
} = Astro.props;
|
||||||
|
|
||||||
const image =
|
const image =
|
||||||
@ -51,6 +55,7 @@ const image =
|
|||||||
|
|
||||||
<AstroSeo
|
<AstroSeo
|
||||||
title={title}
|
title={title}
|
||||||
|
titleTemplate={dontUseTitleTemplate ? '%s' : `%s — ${SITE.name}`}
|
||||||
description={description}
|
description={description}
|
||||||
canonical={String(canonical)}
|
canonical={String(canonical)}
|
||||||
noindex={noindex}
|
noindex={noindex}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
---
|
---
|
||||||
import Layout from '~/layouts/BaseLayout.astro';
|
import Layout from '~/layouts/BaseLayout.astro';
|
||||||
import { SITE } from '~/config.mjs';
|
|
||||||
import Error404 from '~/components/widgets/Error404.astro';
|
import Error404 from '~/components/widgets/Error404.astro';
|
||||||
|
|
||||||
const title = `Error 404 — ${SITE.name}`;
|
const title = `Error 404`;
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout meta={{ title }}>
|
<Layout meta={{ title }}>
|
||||||
|
@ -22,7 +22,7 @@ const { page } = Astro.props;
|
|||||||
const currentPage = page.currentPage ?? 1;
|
const currentPage = page.currentPage ?? 1;
|
||||||
|
|
||||||
const meta = {
|
const meta = {
|
||||||
title: `Blog ${currentPage > 1 ? `— Page ${currentPage} ` : ''}— ${SITE.name}`,
|
title: `Blog${currentPage > 1 ? ` — Page ${currentPage}` : ''}`,
|
||||||
description: SITE.description,
|
description: SITE.description,
|
||||||
canonical: getCanonical(getPermalink(BLOG?.blog?.pathname)),
|
canonical: getCanonical(getPermalink(BLOG?.blog?.pathname)),
|
||||||
ogType: 'blog',
|
ogType: 'blog',
|
||||||
|
@ -25,7 +25,7 @@ const { post } = Astro.props;
|
|||||||
const url = getCanonical(getPermalink(post.slug, 'post'));
|
const url = getCanonical(getPermalink(post.slug, 'post'));
|
||||||
|
|
||||||
const meta = {
|
const meta = {
|
||||||
title: `${post.title} — ${SITE.name}`,
|
title: post.title,
|
||||||
description: post.description,
|
description: post.description,
|
||||||
canonical: post.canonical || url,
|
canonical: post.canonical || url,
|
||||||
image: await findImage(post.image),
|
image: await findImage(post.image),
|
||||||
|
@ -34,7 +34,7 @@ const { page, category } = Astro.props;
|
|||||||
|
|
||||||
const currentPage = page.currentPage ?? 1;
|
const currentPage = page.currentPage ?? 1;
|
||||||
const meta = {
|
const meta = {
|
||||||
title: `Category '${category}' ${currentPage > 1 ? `— Page ${currentPage} ` : ''}— ${SITE.name}`,
|
title: `Category'${category}' ${currentPage > 1 ? ` — Page ${currentPage}` : ''}`,
|
||||||
description: SITE.description,
|
description: SITE.description,
|
||||||
canonical: getCanonical(getPermalink(category, 'category')),
|
canonical: getCanonical(getPermalink(category, 'category')),
|
||||||
noindex: true,
|
noindex: true,
|
||||||
|
@ -34,7 +34,7 @@ const { page, tag } = Astro.props;
|
|||||||
|
|
||||||
const currentPage = page.currentPage ?? 1;
|
const currentPage = page.currentPage ?? 1;
|
||||||
const meta = {
|
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,
|
description: SITE.description,
|
||||||
canonical: getCanonical(getPermalink(tag, 'tag')),
|
canonical: getCanonical(getPermalink(tag, 'tag')),
|
||||||
noindex: true,
|
noindex: true,
|
||||||
|
@ -18,6 +18,7 @@ const meta = {
|
|||||||
title: SITE.title,
|
title: SITE.title,
|
||||||
description: SITE.description,
|
description: SITE.description,
|
||||||
canonical: getCanonical(getHomePermalink()),
|
canonical: getCanonical(getHomePermalink()),
|
||||||
|
dontUseTitleTemplate: true,
|
||||||
};
|
};
|
||||||
---
|
---
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user