mirror of
https://github.com/kremalicious/astro-redirect-from.git
synced 2024-11-22 09:57:03 +01:00
prepend all slugs with a slash if not present
This commit is contained in:
parent
115beb5eea
commit
10d192909c
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user