1
0
mirror of https://github.com/kremalicious/astro-redirect-from.git synced 2024-10-22 11:22:44 +02:00

prepend all slugs with a slash if not present

This commit is contained in:
Matthias Kretschmann 2023-09-23 22:06:22 +01:00
parent 115beb5eea
commit 10d192909c
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -20,11 +20,14 @@ export async function getRedirects(
)
continue
let postSlug = frontmatter.slug
if (!postSlug) postSlug = getSlug(file)
let postSlug = frontmatter.slug || getSlug(file)
if (!postSlug) continue
for (const slug of redirectFrom) {
// Prepend all slugs with a slash if not present
if (!postSlug.startsWith('/')) postSlug = `/${postSlug}`
for (let slug of redirectFrom) {
if (!slug.startsWith('/')) slug = `/${slug}`
redirects[slug] = postSlug
}
}