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

18 lines
372 B
TypeScript

import type { Redirects } from './index.js'
import { prependForwardSlash } from './utils.js'
export function createRedirect(
redirects: Redirects,
redirectFrom: string[],
postSlug: string
) {
postSlug = prependForwardSlash(postSlug)
for (let slug of redirectFrom) {
slug = prependForwardSlash(slug)
redirects[slug] = postSlug
}
return redirects
}