Add route information for getStaticPaths warning (#7126)

This commit is contained in:
Bjorn Lu 2023-05-19 18:13:46 +08:00 committed by GitHub
parent 31cbf4357e
commit 530fb9ebee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Add route information when warning of `getStaticPaths()` ignored

View file

@ -1,3 +1,4 @@
import { bold } from 'kleur/colors';
import type { ComponentInstance, GetStaticPathsResult, RouteData } from '../../@types/astro';
import { AstroError, AstroErrorData } from '../errors/index.js';
import type { LogOptions } from '../logger/core';
@ -32,7 +33,11 @@ export function validateDynamicRouteModule(
}
) {
if (ssr && mod.getStaticPaths && !mod.prerender) {
warn(logging, 'getStaticPaths', 'getStaticPaths() is ignored when "output: server" is set.');
warn(
logging,
'getStaticPaths',
`getStaticPaths() in ${bold(route.component)} is ignored when "output: server" is set.`
);
}
if ((!ssr || mod.prerender) && !mod.getStaticPaths) {
throw new AstroError({