create-sitecore-jss 22.5.0-canary.3 → 22.5.0-canary.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
-
import { NativeDataFetcher, GraphQLSitemapXmlService } from '@sitecore-jss/sitecore-jss-nextjs'
|
|
2
|
+
import { NativeDataFetcher, GraphQLSitemapXmlService } from '@sitecore-jss/sitecore-jss-nextjs';
|
|
3
3
|
import { siteResolver } from 'lib/site-resolver';
|
|
4
4
|
import config from 'temp/config';
|
|
5
5
|
import clientFactory from 'lib/graphql-client-factory';
|
|
@@ -24,10 +24,11 @@ const sitemapApi = async (
|
|
|
24
24
|
siteName: site.name,
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
// if url has sitemap-{n}.xml type.
|
|
27
|
+
// The id is present if url has sitemap-{n}.xml type.
|
|
28
|
+
// The id can be null if it's index sitemap.xml request
|
|
28
29
|
const sitemapPath = await sitemapXmlService.getSitemap(id as string);
|
|
29
30
|
|
|
30
|
-
//
|
|
31
|
+
// regular sitemap
|
|
31
32
|
if (sitemapPath) {
|
|
32
33
|
const isAbsoluteUrl = sitemapPath.match(ABSOLUTE_URL_REGEXP);
|
|
33
34
|
const sitemapUrl = isAbsoluteUrl ? sitemapPath : `${config.sitecoreApiHost}${sitemapPath}`;
|
|
@@ -35,27 +36,15 @@ const sitemapApi = async (
|
|
|
35
36
|
|
|
36
37
|
try {
|
|
37
38
|
const fetcher = new NativeDataFetcher();
|
|
38
|
-
const
|
|
39
|
+
const xmlResponse = await fetcher.fetch<string>(sitemapUrl);
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
if (reader) {
|
|
42
|
-
while (true) {
|
|
43
|
-
const { done, value } = await reader.read();
|
|
44
|
-
if (done) break;
|
|
45
|
-
if (value) res.write(value);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
res.end();
|
|
41
|
+
return res.send(xmlResponse.data);
|
|
49
42
|
} catch (error) {
|
|
50
43
|
return res.redirect('/404');
|
|
51
44
|
}
|
|
52
|
-
return;
|
|
53
45
|
}
|
|
54
46
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
// this approache if user go to /sitemap.xml - under it generate xml page with list of sitemaps
|
|
47
|
+
// index /sitemap.xml that includes links to all sitemaps
|
|
59
48
|
const sitemaps = await sitemapXmlService.fetchSitemaps();
|
|
60
49
|
|
|
61
50
|
if (!sitemaps.length) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-sitecore-jss",
|
|
3
|
-
"version": "22.5.0-canary.
|
|
3
|
+
"version": "22.5.0-canary.5",
|
|
4
4
|
"description": "Sitecore JSS initializer",
|
|
5
5
|
"bin": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"ts-node": "^10.9.1",
|
|
66
66
|
"typescript": "~5.6.3"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "0ab4e803264dbf26782b7d67b14c63c38e31a09d"
|
|
69
69
|
}
|