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:
@@ -25,7 +25,7 @@ export type SearchHit = {
|
||||
function pageHref(p: { slug?: string; _slug?: string }): string {
|
||||
const raw = (p.slug ?? p._slug ?? '').replace(/^\//, '').trim();
|
||||
if (!raw || raw === 'home') return '/';
|
||||
return '/' + raw.split('/').filter(Boolean).map(encodeURIComponent).join('/');
|
||||
return '/' + raw.split('/').filter(Boolean).map(encodeURIComponent).join('/') + '/';
|
||||
}
|
||||
|
||||
export const GET: RequestHandler = async () => {
|
||||
|
||||
Reference in New Issue
Block a user