0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

feat(next): underscore redirects (#11989)

This commit is contained in:
Florian Lefebvre 2024-09-13 16:41:40 +02:00 committed by GitHub
parent d84e444fd3
commit 3e70853b76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/underscore-redirects': minor
---
Updates the type from `RouteData` to `IntegrationRouteData`

View file

@ -1,10 +1,10 @@
import { posix } from 'node:path';
import type { AstroConfig, RouteData, ValidRedirectStatus } from 'astro';
import type { AstroConfig, IntegrationRouteData, ValidRedirectStatus } from 'astro';
import { Redirects } from './redirects.js';
const pathJoin = posix.join;
function getRedirectStatus(route: RouteData): ValidRedirectStatus {
function getRedirectStatus(route: IntegrationRouteData): ValidRedirectStatus {
if (typeof route.redirect === 'object') {
return route.redirect.status;
}
@ -16,7 +16,7 @@ interface CreateRedirectsFromAstroRoutesParams {
/**
* Maps a `RouteData` to a dynamic target
*/
routeToDynamicTargetMap: Map<RouteData, string>;
routeToDynamicTargetMap: Map<IntegrationRouteData, string>;
dir: URL;
}
@ -125,7 +125,7 @@ export function createRedirectsFromAstroRoutes({
* /team/articles/*
* With stars replacing spread and :id syntax replacing [id]
*/
function generateDynamicPattern(route: RouteData) {
function generateDynamicPattern(route: IntegrationRouteData) {
const pattern =
'/' +
route.segments