rankrunners-cms 0.0.14 → 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
|
+
};
|
|
@@ -102,7 +102,7 @@ export function parseScripts(html: string): ScriptProps[] {
|
|
|
102
102
|
while ((attrMatch = attrRegex.exec(attributesString)) !== null) {
|
|
103
103
|
const attrName = attrMatch[1]?.toLowerCase();
|
|
104
104
|
if (!attrName) continue;
|
|
105
|
-
const attrValue = attrMatch[2] ?? attrMatch[3] ?? attrMatch[4] ?? true;
|
|
105
|
+
const attrValue = attrMatch[2] ?? attrMatch[3] ?? attrMatch[4] ?? "true";
|
|
106
106
|
|
|
107
107
|
// Map HTML attributes to React props
|
|
108
108
|
switch (attrName) {
|
|
@@ -114,21 +114,18 @@ export function parseScripts(html: string): ScriptProps[] {
|
|
|
114
114
|
break;
|
|
115
115
|
case "async":
|
|
116
116
|
props.async =
|
|
117
|
-
attrValue === true ||
|
|
118
117
|
attrValue === "true" ||
|
|
119
118
|
attrValue === "async" ||
|
|
120
119
|
attrValue === "";
|
|
121
120
|
break;
|
|
122
121
|
case "defer":
|
|
123
122
|
props.defer =
|
|
124
|
-
attrValue === true ||
|
|
125
123
|
attrValue === "true" ||
|
|
126
124
|
attrValue === "defer" ||
|
|
127
125
|
attrValue === "";
|
|
128
126
|
break;
|
|
129
127
|
case "nomodule":
|
|
130
128
|
props.noModule =
|
|
131
|
-
attrValue === true ||
|
|
132
129
|
attrValue === "true" ||
|
|
133
130
|
attrValue === "nomodule" ||
|
|
134
131
|
attrValue === "";
|
|
@@ -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
|
+
};
|