-
-
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.
Sitemap should only include
page
routes (#7656)
* fix(#7080): sitemap should only add trailing slash to pages * fix(sitemap): only include pages in sitemap * chore: add test * chore: remove unused import * docs: update readme
- Loading branch information
1 parent
6ad4672
commit dd931a7
Showing
7 changed files
with
54 additions
and
2 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': major | ||
--- | ||
|
||
Sitemap only includes `page` routes (generated by `.astro` files) rather than all routes (pages, endpoints, or redirects). This behavior matches our existing documentation, but is a breaking change nonetheless. |
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 | ||
--- | ||
|
||
Ensure trailing slash is only added to page routes |
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
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
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
8 changes: 8 additions & 0 deletions
8
packages/integrations/sitemap/test/fixtures/static/src/pages/endpoint.json.ts
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,8 @@ | ||
export async function get({}) { | ||
return { | ||
body: JSON.stringify({ | ||
name: 'Astro', | ||
url: 'https://astro.build/', | ||
}), | ||
}; | ||
} |
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,26 @@ | ||
import { loadFixture, readXML } from './test-utils.js'; | ||
import { expect } from 'chai'; | ||
|
||
describe('routes', () => { | ||
/** @type {import('./test-utils.js').Fixture} */ | ||
let fixture; | ||
/** @type {string[]} */ | ||
let urls; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/static/', | ||
}); | ||
await fixture.build(); | ||
const data = await readXML(fixture.readFile('/sitemap-0.xml')); | ||
urls = data.urlset.url.map(url => url.loc[0]); | ||
}); | ||
|
||
it('does not include endpoints', async () => { | ||
expect(urls).to.not.include('http://example.com/endpoint.json'); | ||
}); | ||
|
||
it('does not include redirects', async () => { | ||
expect(urls).to.not.include('http://example.com/redirect'); | ||
}); | ||
}); |