fix(aliases): prevent alias emitter from infinite redirect

This commit is contained in:
vanadium23 2024-12-01 22:45:02 +03:00
parent 5ccc2dcbba
commit 311f92011f

View File

@ -49,6 +49,12 @@ export const AliasRedirects: QuartzEmitterPlugin = () => ({
} }
for (let slug of slugs) { for (let slug of slugs) {
// prevent infinite redirect if permalink is same as fullSlug
if (`/${ogSlug}/` == `${slug}`) {
console.warn(`AliasRedirects: ${slug} is the same as the original slug`)
continue
}
// fix any slugs that have trailing slash // fix any slugs that have trailing slash
if (slug.endsWith("/")) { if (slug.endsWith("/")) {
slug = joinSegments(slug, "index") as FullSlug slug = joinSegments(slug, "index") as FullSlug