seo: enforce trailing slash on all URLs
- Set trailingSlash='always' globally via root layout. - Update postHref, pageHref, Pagination, tag/breadcrumb hrefs, blog→posts redirects to emit trailing slash. - Match old Astro canonical so indexed URLs hit 200 directly instead of 308-redirect.
This commit is contained in:
@@ -108,8 +108,8 @@
|
||||
}
|
||||
|
||||
function tagHref(tagSlug: string | null): string {
|
||||
if (!tagSlug) return basePath;
|
||||
return `${basePath}/tag/${encodeURIComponent(tagSlug)}`;
|
||||
if (!tagSlug) return `${basePath}/`;
|
||||
return `${basePath}/tag/${encodeURIComponent(tagSlug)}/`;
|
||||
}
|
||||
|
||||
const totalCount = $derived(totalPosts);
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
} = $props();
|
||||
|
||||
function tagHref(tagSlug: string | null): string {
|
||||
if (!tagSlug) return basePath;
|
||||
return `${basePath}/tag/${encodeURIComponent(tagSlug)}`;
|
||||
if (!tagSlug) return `${basePath}/`;
|
||||
return `${basePath}/tag/${encodeURIComponent(tagSlug)}/`;
|
||||
}
|
||||
|
||||
function pageHref(page: number): string {
|
||||
@@ -28,7 +28,7 @@
|
||||
const tagPart = activeTag
|
||||
? `/tag/${encodeURIComponent(activeTag)}`
|
||||
: "";
|
||||
return `${basePath}${tagPart}/page/${page}`;
|
||||
return `${basePath}${tagPart}/page/${page}/`;
|
||||
}
|
||||
|
||||
const showPagination = $derived(totalPages > 1);
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<Tag
|
||||
label={name}
|
||||
variant={variant}
|
||||
href={tagBase ? `${tagBase}/${slug(t)}` : null}
|
||||
href={tagBase ? `${tagBase}/${slug(t)}/` : null}
|
||||
icon={tagIcon(t)}
|
||||
customColor={tagColor(t)}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user