rankrunners-cms 0.0.15 → 0.0.16
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.
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { CMS_BASE_URL, SITE_ID } from "../constants";
|
|
|
3
3
|
|
|
4
4
|
export const downloadSitemap = async (sitemap: string): Promise<string> => {
|
|
5
5
|
const response = await fetchWithCache(
|
|
6
|
-
`${CMS_BASE_URL}/sites/${SITE_ID}/sitemaps/${sitemap}
|
|
6
|
+
`${CMS_BASE_URL}/sites/${SITE_ID}/sitemaps/${sitemap}`,
|
|
7
7
|
);
|
|
8
8
|
|
|
9
9
|
if (!response.ok) {
|
|
@@ -13,3 +13,20 @@ export const downloadSitemap = async (sitemap: string): Promise<string> => {
|
|
|
13
13
|
const content = await response.text();
|
|
14
14
|
return content;
|
|
15
15
|
};
|
|
16
|
+
|
|
17
|
+
export const downloadSitemapAsResponse = async (
|
|
18
|
+
sitemap: string,
|
|
19
|
+
): Promise<Response> => {
|
|
20
|
+
const sitemapData = await downloadSitemap(sitemap);
|
|
21
|
+
|
|
22
|
+
const contentType = sitemap.endsWith(".xml")
|
|
23
|
+
? "application/xml"
|
|
24
|
+
: "text/plain";
|
|
25
|
+
|
|
26
|
+
return new Response(sitemapData, {
|
|
27
|
+
status: 200,
|
|
28
|
+
headers: {
|
|
29
|
+
"Content-Type": contentType,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { downloadSitemap } from "../../api/client/sitemap";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handler for sitemap routes in TanStack Router
|
|
5
|
+
* Use this in your route file with a loader
|
|
6
|
+
*/
|
|
7
|
+
export const createSitemapRoute = async (sitemap: string) => {
|
|
8
|
+
const sitemapData = await downloadSitemap(`${sitemap}.xml`);
|
|
9
|
+
|
|
10
|
+
return new Response(sitemapData, {
|
|
11
|
+
status: 200,
|
|
12
|
+
headers: {
|
|
13
|
+
"Content-Type": "application/xml",
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Handler for robots.txt route in TanStack Router
|
|
20
|
+
* Use this in your route file with a loader
|
|
21
|
+
*/
|
|
22
|
+
export const createRobotsTxtRoute = async () => {
|
|
23
|
+
const robotsTxt = await downloadSitemap("robots.txt");
|
|
24
|
+
|
|
25
|
+
return new Response(robotsTxt, {
|
|
26
|
+
status: 200,
|
|
27
|
+
headers: {
|
|
28
|
+
"Content-Type": "text/plain",
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
};
|