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:
@@ -302,7 +302,7 @@ const POST_BASE = "/post";
|
||||
export function postHref(post: PostEntry): string {
|
||||
const slug = post.slug ?? post._slug ?? "";
|
||||
const norm = (slug ?? "").replace(/^\//, "").trim();
|
||||
return norm ? `${POST_BASE}/${encodeURIComponent(norm)}` : POST_BASE;
|
||||
return norm ? `${POST_BASE}/${encodeURIComponent(norm)}/` : `${POST_BASE}/`;
|
||||
}
|
||||
|
||||
export function formatPostDate(value: string | undefined): string {
|
||||
|
||||
Reference in New Issue
Block a user