Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,21 @@ impl ReactServerComponentValidator {
r"[\\/](page|layout|route|icon\d?|apple-icon\d?|opengraph-image\d?|twitter-image\d?|sitemap|robots|manifest)\.{ext_pattern}$",
))
.unwrap();
let is_app_entry = re.is_match(&self.filepath);
let is_in_app_dir = self
.app_dir
.as_ref()
.and_then(|app_dir| app_dir.to_str())
.map_or(false, |app_dir| self.filepath.starts_with(app_dir));

let is_app_entry = if is_in_app_dir {
re.is_match(&self.filepath)
} else if self.app_dir.is_none() {
let app_core_re =
Regex::new(&format!(r"[\\/](page|layout|route)\.{ext_pattern}$")).unwrap();
app_core_re.is_match(&self.filepath)
} else {
false
};

if is_app_entry {
let mut possibly_invalid_exports: FxIndexMap<Atom, (InvalidExportKind, Span)> =
Expand Down
14 changes: 14 additions & 0 deletions test/e2e/pages-sitemap-getstaticprops/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { nextTestSetup } from 'e2e-utils'

describe('pages sitemap with getStaticProps', () => {
const { next } = nextTestSetup({
files: __dirname,
})

it('should render sitemap page with getStaticProps successfully', async () => {
const browser = await next.browser('/sitemap')
expect(await browser.elementById('message').text()).toBe(
'Hello from sitemap getStaticProps'
)
})
})
11 changes: 11 additions & 0 deletions test/e2e/pages-sitemap-getstaticprops/pages/sitemap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export async function getStaticProps() {
return {
props: {
message: 'Hello from sitemap getStaticProps',
},
}
}

export default function Sitemap({ message }) {
return <h1 id="message">{message}</h1>
}