Simplify canonical url
This commit is contained in:
@ -2,9 +2,11 @@
|
|||||||
import { AstroSeo } from '@astrolib/seo';
|
import { AstroSeo } from '@astrolib/seo';
|
||||||
import { GoogleAnalytics } from '@astrolib/analytics';
|
import { GoogleAnalytics } from '@astrolib/analytics';
|
||||||
import { getImage } from '@astrojs/image';
|
import { getImage } from '@astrojs/image';
|
||||||
import { getRelativeUrlByFilePath } from '~/utils/directories';
|
|
||||||
|
|
||||||
import { SITE } from '~/config.mjs';
|
import { SITE } from '~/config.mjs';
|
||||||
|
import { getCanonical } from '~/utils/permalinks';
|
||||||
|
import { getRelativeUrlByFilePath } from '~/utils/directories';
|
||||||
|
|
||||||
import Fonts from '~/components/common/Fonts.astro';
|
import Fonts from '~/components/common/Fonts.astro';
|
||||||
import ExtraMetaTags from '~/components/common/ExtraMetaTags.astro';
|
import ExtraMetaTags from '~/components/common/ExtraMetaTags.astro';
|
||||||
import SplitbeeAnalytics from './SplitbeeAnalytics.astro';
|
import SplitbeeAnalytics from './SplitbeeAnalytics.astro';
|
||||||
@ -31,7 +33,7 @@ const {
|
|||||||
description = '',
|
description = '',
|
||||||
image: _image = defaultImage,
|
image: _image = defaultImage,
|
||||||
|
|
||||||
canonical,
|
canonical = getCanonical(String(Astro.url.pathname)),
|
||||||
noindex = false,
|
noindex = false,
|
||||||
nofollow = false,
|
nofollow = false,
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ const currentPage = page.currentPage ?? 1;
|
|||||||
const meta = {
|
const meta = {
|
||||||
title: `Blog${currentPage > 1 ? ` — Page ${currentPage}` : ''}`,
|
title: `Blog${currentPage > 1 ? ` — Page ${currentPage}` : ''}`,
|
||||||
description: SITE.description,
|
description: SITE.description,
|
||||||
canonical: getCanonical(getPermalink(BLOG?.blog?.pathname)),
|
|
||||||
ogType: 'blog',
|
ogType: 'blog',
|
||||||
noindex: currentPage > 1,
|
noindex: currentPage > 1,
|
||||||
};
|
};
|
||||||
|
@ -6,7 +6,7 @@ import BlogList from '~/components/blog/List.astro';
|
|||||||
import Pagination from '~/components/common/Pagination.astro';
|
import Pagination from '~/components/common/Pagination.astro';
|
||||||
|
|
||||||
import { fetchPosts } from '~/utils/posts';
|
import { fetchPosts } from '~/utils/posts';
|
||||||
import { getCanonical, getPermalink, cleanSlug, CATEGORY_BASE } from '~/utils/permalinks';
|
import { cleanSlug, CATEGORY_BASE } from '~/utils/permalinks';
|
||||||
import Title from '~/components/blog/Title.astro';
|
import Title from '~/components/blog/Title.astro';
|
||||||
|
|
||||||
export async function getStaticPaths({ paginate }) {
|
export async function getStaticPaths({ paginate }) {
|
||||||
@ -36,7 +36,6 @@ const currentPage = page.currentPage ?? 1;
|
|||||||
const meta = {
|
const meta = {
|
||||||
title: `Category'${category}' ${currentPage > 1 ? ` — Page ${currentPage}` : ''}`,
|
title: `Category'${category}' ${currentPage > 1 ? ` — Page ${currentPage}` : ''}`,
|
||||||
description: SITE.description,
|
description: SITE.description,
|
||||||
canonical: getCanonical(getPermalink(category, 'category')),
|
|
||||||
noindex: true,
|
noindex: true,
|
||||||
};
|
};
|
||||||
---
|
---
|
||||||
|
@ -27,7 +27,7 @@ const url = getCanonical(getPermalink(post.slug, 'post'));
|
|||||||
const meta = {
|
const meta = {
|
||||||
title: post.title,
|
title: post.title,
|
||||||
description: post.description,
|
description: post.description,
|
||||||
canonical: post.canonical || url,
|
canonical: post.canonical || undefined,
|
||||||
image: await findImage(post.image),
|
image: await findImage(post.image),
|
||||||
ogTitle: post.title,
|
ogTitle: post.title,
|
||||||
ogType: 'article',
|
ogType: 'article',
|
||||||
|
@ -36,7 +36,6 @@ const currentPage = page.currentPage ?? 1;
|
|||||||
const meta = {
|
const meta = {
|
||||||
title: `Posts by tag '${tag}'${currentPage > 1 ? ` — Page ${currentPage} ` : ''}`,
|
title: `Posts by tag '${tag}'${currentPage > 1 ? ` — Page ${currentPage} ` : ''}`,
|
||||||
description: SITE.description,
|
description: SITE.description,
|
||||||
canonical: getCanonical(getPermalink(tag, 'tag')),
|
|
||||||
noindex: true,
|
noindex: true,
|
||||||
};
|
};
|
||||||
---
|
---
|
||||||
|
@ -17,7 +17,6 @@ import CallToAction from '~/components/widgets/CallToAction.astro';
|
|||||||
const meta = {
|
const meta = {
|
||||||
title: SITE.title,
|
title: SITE.title,
|
||||||
description: SITE.description,
|
description: SITE.description,
|
||||||
canonical: getCanonical(getHomePermalink()),
|
|
||||||
dontUseTitleTemplate: true,
|
dontUseTitleTemplate: true,
|
||||||
};
|
};
|
||||||
---
|
---
|
||||||
|
Reference in New Issue
Block a user