-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: nested
dynamicUrlsApiEndpoint
calls
- Loading branch information
Showing
4 changed files
with
85 additions
and
3 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,10 @@ | ||
import { defineEventHandler } from 'h3' | ||
|
||
export default defineEventHandler(e => { | ||
const posts = Array.from({ length: 5 }, (_, i) => i + 1) | ||
return [ | ||
...posts.map(post => ({ | ||
loc: `/bar/${post}` | ||
})) | ||
] | ||
}) |
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,10 @@ | ||
import { defineEventHandler } from 'h3' | ||
|
||
export default defineEventHandler(e => { | ||
const posts = Array.from({ length: 5 }, (_, i) => i + 1) | ||
return [ | ||
...posts.map(post => ({ | ||
loc: `/foo/${post}` | ||
})) | ||
] | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { describe, expect, it } from 'vitest' | ||
import { createResolver } from '@nuxt/kit' | ||
import { $fetch, setup } from '@nuxt/test-utils' | ||
|
||
const { resolve } = createResolver(import.meta.url) | ||
|
||
await setup({ | ||
rootDir: resolve('../.playground'), | ||
build: true, | ||
server: true, | ||
nuxtConfig: { | ||
sitemap: { | ||
credits: false, | ||
sitemaps: { | ||
foo: { | ||
include: ['/foo/*'], | ||
dynamicUrlsApiEndpoint: '/api/multi-sitemap-sources/foo', | ||
}, | ||
bar: { | ||
include: ['/bar/*'], | ||
dynamicUrlsApiEndpoint: '/api/multi-sitemap-sources/bar', | ||
}, | ||
}, | ||
sitemapName: 'test.xml', | ||
siteUrl: 'https://nuxtseo.com', | ||
}, | ||
}, | ||
}) | ||
describe('multiEndpoints', () => { | ||
it('basic', async () => { | ||
let sitemap = await $fetch('/foo-sitemap.xml') | ||
// remove lastmods before tresting | ||
sitemap = sitemap.replace(/lastmod>(.*?)</g, 'lastmod><') | ||
// basic test to make sure we get a valid response | ||
expect(sitemap).toMatchInlineSnapshot(` | ||
"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?><?xml-stylesheet type=\\"text/xsl\\" href=\\"/__sitemap__/style.xsl\\"?> | ||
<urlset xmlns:xsi=\\"http://www.w3.org/2001/XMLSchema-instance\\" xmlns:video=\\"http://www.google.com/schemas/sitemap-video/1.1\\" xmlns:xhtml=\\"http://www.w3.org/1999/xhtml\\" xmlns:image=\\"http://www.google.com/schemas/sitemap-image/1.1\\" xsi:schemaLocation=\\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd\\" xmlns=\\"http://www.sitemaps.org/schemas/sitemap/0.9\\"> | ||
<url> | ||
<lastmod></lastmod> | ||
<loc>https://nuxtseo.com/foo/1</loc> | ||
</url> | ||
<url> | ||
<lastmod></lastmod> | ||
<loc>https://nuxtseo.com/foo/2</loc> | ||
</url> | ||
<url> | ||
<lastmod></lastmod> | ||
<loc>https://nuxtseo.com/foo/3</loc> | ||
</url> | ||
<url> | ||
<lastmod></lastmod> | ||
<loc>https://nuxtseo.com/foo/4</loc> | ||
</url> | ||
<url> | ||
<lastmod></lastmod> | ||
<loc>https://nuxtseo.com/foo/5</loc> | ||
</url> | ||
</urlset>" | ||
`) | ||
}, 60000) | ||
}) |