-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix generation for routes defined using getStaticPaths (#7029)
* Fix static site dynamic routes for sitemap integration * Add changeset * Update pnpm-lock * Remove console.log
- Loading branch information
1 parent
e54dcd5
commit 1b90a7a
Showing
8 changed files
with
356 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/sitemap': patch | ||
--- | ||
|
||
Fix generation for static dynamic routes |
277 changes: 277 additions & 0 deletions
277
packages/integrations/cloudflare/test/fixtures/basics/functions/[[path]].js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/integrations/sitemap/test/fixtures/static/astro.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import sitemap from '@astrojs/sitemap'; | ||
|
||
export default defineConfig({ | ||
integrations: [sitemap()], | ||
site: 'http://example.com', | ||
}) |
9 changes: 9 additions & 0 deletions
9
packages/integrations/sitemap/test/fixtures/static/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@test/sitemap-static", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*", | ||
"@astrojs/sitemap": "workspace:*" | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/integrations/sitemap/test/fixtures/static/src/pages/[slug].astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
export function getStaticPaths() { | ||
return [ | ||
{ params: { slug: 'one' }, props: { title: 'One' } }, | ||
{ params: { slug: 'two' }, props: { title: 'Two' } }, | ||
] | ||
} | ||
--- | ||
|
||
<html> | ||
<head> | ||
<title>{Astro.props.title}</title> | ||
</head> | ||
<body> | ||
<h1>{Astro.props.title}</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { loadFixture, readXML } from './test-utils.js'; | ||
import { expect } from 'chai'; | ||
|
||
describe('getStaticPaths support', () => { | ||
/** @type {import('./test-utils.js').Fixture} */ | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/static/', | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('getStaticPath pages require zero config', async () => { | ||
const data = await readXML(fixture.readFile('/sitemap-0.xml')); | ||
const urls = data.urlset.url; | ||
|
||
expect(urls[0].loc[0]).to.equal('http://example.com/one/'); | ||
expect(urls[1].loc[0]).to.equal('http://example.com/two/'); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.