Skip to content

Commit

Permalink
Add route information for getStaticPaths warning (#7126)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed May 19, 2023
1 parent 31cbf43 commit 530fb9e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/swift-lamps-doubt.md
@@ -0,0 +1,5 @@
---
'astro': patch
---

Add route information when warning of `getStaticPaths()` ignored
7 changes: 6 additions & 1 deletion packages/astro/src/core/routing/validation.ts
@@ -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';
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 530fb9e

Please sign in to comment.