Fix trailingSlash with new Astro versions
This commit is contained in:
@ -27,7 +27,16 @@ export const CATEGORY_BASE = cleanSlug(BLOG?.category?.pathname || 'category');
|
||||
export const TAG_BASE = cleanSlug(BLOG?.tag?.pathname) || 'tag';
|
||||
|
||||
/** */
|
||||
export const getCanonical = (path = ''): string | URL => new URL(path, SITE.origin);
|
||||
export const getCanonical = (path = ''): string | URL => {
|
||||
const url = String(new URL(path, SITE.origin));
|
||||
if (SITE.trailingSlash == false && path && url.endsWith('/')) {
|
||||
return url.slice(0,-1)
|
||||
}
|
||||
else if (SITE.trailingSlash == true && path && !url.endsWith('/') ) {
|
||||
return url + '/';
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/** */
|
||||
export const getPermalink = (slug = '', type = 'page'): string => {
|
||||
|
Reference in New Issue
Block a user