Skip to content

Commit

Permalink
prepend all slugs with a slash if not present
Browse files Browse the repository at this point in the history
  • Loading branch information
kremalicious committed Sep 23, 2023
1 parent 115beb5 commit 10d1929
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/getRedirects.ts
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 10d1929

Please sign in to comment.