fix: rename news dynamic route parameter from id to slug
This commit is contained in:
Vendored
+23
-3
@@ -1,24 +1,30 @@
|
||||
// This file is generated automatically by Next.js
|
||||
// Do not edit this file manually
|
||||
|
||||
type AppRoutes = "/" | "/about" | "/cases/[id]" | "/contact" | "/news" | "/news/[slug]" | "/preview/effects" | "/products" | "/services"
|
||||
type AppRoutes = "/" | "/about" | "/cases/[id]" | "/contact" | "/news" | "/news/[slug]" | "/preview/effects" | "/privacy" | "/products" | "/products/[id]" | "/services" | "/services/[id]" | "/terms"
|
||||
type AppRouteHandlerRoutes = "/api/contact"
|
||||
type PageRoutes = never
|
||||
type LayoutRoutes = "/"
|
||||
type RedirectRoutes = never
|
||||
type RewriteRoutes = never
|
||||
type Routes = AppRoutes | PageRoutes | LayoutRoutes | RedirectRoutes | RewriteRoutes
|
||||
type Routes = AppRoutes | PageRoutes | LayoutRoutes | RedirectRoutes | RewriteRoutes | AppRouteHandlerRoutes
|
||||
|
||||
|
||||
interface ParamMap {
|
||||
"/": {}
|
||||
"/about": {}
|
||||
"/api/contact": {}
|
||||
"/cases/[id]": { "id": string; }
|
||||
"/contact": {}
|
||||
"/news": {}
|
||||
"/news/[slug]": { "slug": string; }
|
||||
"/preview/effects": {}
|
||||
"/privacy": {}
|
||||
"/products": {}
|
||||
"/products/[id]": { "id": string; }
|
||||
"/services": {}
|
||||
"/services/[id]": { "id": string; }
|
||||
"/terms": {}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +35,7 @@ interface LayoutSlotMap {
|
||||
}
|
||||
|
||||
|
||||
export type { AppRoutes, PageRoutes, LayoutRoutes, RedirectRoutes, RewriteRoutes, ParamMap }
|
||||
export type { AppRoutes, PageRoutes, LayoutRoutes, RedirectRoutes, RewriteRoutes, ParamMap, AppRouteHandlerRoutes }
|
||||
|
||||
declare global {
|
||||
/**
|
||||
@@ -62,4 +68,18 @@ declare global {
|
||||
} & {
|
||||
[K in LayoutSlotMap[LayoutRoute]]: React.ReactNode
|
||||
}
|
||||
|
||||
/**
|
||||
* Context for Next.js App Router route handlers
|
||||
* @example
|
||||
* ```tsx
|
||||
* export async function GET(request: NextRequest, context: RouteContext<'/api/users/[id]'>) {
|
||||
* const { id } = await context.params
|
||||
* return Response.json({ id })
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface RouteContext<AppRouteHandlerRoute extends AppRouteHandlerRoutes> {
|
||||
params: Promise<ParamMap[AppRouteHandlerRoute]>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
// Do not edit this file manually
|
||||
// This file validates that all pages and layouts export the correct types
|
||||
|
||||
import type { AppRoutes, LayoutRoutes, ParamMap } from "./routes.js"
|
||||
import type { AppRoutes, LayoutRoutes, ParamMap, AppRouteHandlerRoutes } from "./routes.js"
|
||||
import type { ResolvingMetadata, ResolvingViewport } from "next/types.js"
|
||||
import type { NextRequest } from 'next/server.js'
|
||||
|
||||
type AppPageConfig<Route extends AppRoutes = AppRoutes> = {
|
||||
default: React.ComponentType<{ params: Promise<ParamMap[Route]> } & any> | ((props: { params: Promise<ParamMap[Route]> } & any) => React.ReactNode | Promise<React.ReactNode> | never | void | Promise<void>)
|
||||
@@ -35,6 +36,16 @@ type LayoutConfig<Route extends LayoutRoutes = LayoutRoutes> = {
|
||||
viewport?: any
|
||||
}
|
||||
|
||||
type RouteHandlerConfig<Route extends AppRouteHandlerRoutes = AppRouteHandlerRoutes> = {
|
||||
GET?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void
|
||||
POST?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void
|
||||
PUT?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void
|
||||
PATCH?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void
|
||||
DELETE?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void
|
||||
HEAD?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void
|
||||
OPTIONS?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void
|
||||
}
|
||||
|
||||
|
||||
// Validate ../../src/app/(marketing)/about/page.tsx
|
||||
{
|
||||
@@ -90,6 +101,24 @@ type LayoutConfig<Route extends LayoutRoutes = LayoutRoutes> = {
|
||||
type __Unused = __Check
|
||||
}
|
||||
|
||||
// Validate ../../src/app/(marketing)/privacy/page.tsx
|
||||
{
|
||||
type __IsExpected<Specific extends AppPageConfig<"/privacy">> = Specific
|
||||
const handler = {} as typeof import("../../src/app/(marketing)/privacy/page.js")
|
||||
type __Check = __IsExpected<typeof handler>
|
||||
// @ts-ignore
|
||||
type __Unused = __Check
|
||||
}
|
||||
|
||||
// Validate ../../src/app/(marketing)/products/[id]/page.tsx
|
||||
{
|
||||
type __IsExpected<Specific extends AppPageConfig<"/products/[id]">> = Specific
|
||||
const handler = {} as typeof import("../../src/app/(marketing)/products/[id]/page.js")
|
||||
type __Check = __IsExpected<typeof handler>
|
||||
// @ts-ignore
|
||||
type __Unused = __Check
|
||||
}
|
||||
|
||||
// Validate ../../src/app/(marketing)/products/page.tsx
|
||||
{
|
||||
type __IsExpected<Specific extends AppPageConfig<"/products">> = Specific
|
||||
@@ -99,6 +128,15 @@ type LayoutConfig<Route extends LayoutRoutes = LayoutRoutes> = {
|
||||
type __Unused = __Check
|
||||
}
|
||||
|
||||
// Validate ../../src/app/(marketing)/services/[id]/page.tsx
|
||||
{
|
||||
type __IsExpected<Specific extends AppPageConfig<"/services/[id]">> = Specific
|
||||
const handler = {} as typeof import("../../src/app/(marketing)/services/[id]/page.js")
|
||||
type __Check = __IsExpected<typeof handler>
|
||||
// @ts-ignore
|
||||
type __Unused = __Check
|
||||
}
|
||||
|
||||
// Validate ../../src/app/(marketing)/services/page.tsx
|
||||
{
|
||||
type __IsExpected<Specific extends AppPageConfig<"/services">> = Specific
|
||||
@@ -108,6 +146,15 @@ type LayoutConfig<Route extends LayoutRoutes = LayoutRoutes> = {
|
||||
type __Unused = __Check
|
||||
}
|
||||
|
||||
// Validate ../../src/app/(marketing)/terms/page.tsx
|
||||
{
|
||||
type __IsExpected<Specific extends AppPageConfig<"/terms">> = Specific
|
||||
const handler = {} as typeof import("../../src/app/(marketing)/terms/page.js")
|
||||
type __Check = __IsExpected<typeof handler>
|
||||
// @ts-ignore
|
||||
type __Unused = __Check
|
||||
}
|
||||
|
||||
// Validate ../../src/app/preview/effects/page.tsx
|
||||
{
|
||||
type __IsExpected<Specific extends AppPageConfig<"/preview/effects">> = Specific
|
||||
@@ -117,7 +164,14 @@ type LayoutConfig<Route extends LayoutRoutes = LayoutRoutes> = {
|
||||
type __Unused = __Check
|
||||
}
|
||||
|
||||
|
||||
// Validate ../../src/app/api/contact/route.ts
|
||||
{
|
||||
type __IsExpected<Specific extends RouteHandlerConfig<"/api/contact">> = Specific
|
||||
const handler = {} as typeof import("../../src/app/api/contact/route.js")
|
||||
type __Check = __IsExpected<typeof handler>
|
||||
// @ts-ignore
|
||||
type __Unused = __Check
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user