czon 0.7.4 → 0.7.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.
- package/dist/build/robots.js +1 -1
- package/dist/build/sitemap.js +15 -3
- package/package.json +1 -1
package/dist/build/robots.js
CHANGED
|
@@ -105,7 +105,7 @@ Disallow:
|
|
|
105
105
|
User-agent: KHTML, like Gecko
|
|
106
106
|
Disallow:
|
|
107
107
|
|
|
108
|
-
${metadata_1.MetaData.options.site?.baseUrl ? `Sitemap: ${
|
|
108
|
+
${metadata_1.MetaData.options.site?.baseUrl ? `Sitemap: ${new URL('sitemap.xml', metadata_1.MetaData.options.site.baseUrl).href}` : ''}
|
|
109
109
|
`;
|
|
110
110
|
const robotsPath = path.join(paths_1.CZON_DIST_DIR, 'robots.txt');
|
|
111
111
|
await (0, writeFile_1.writeFile)(robotsPath, robotsTxtContent);
|
package/dist/build/sitemap.js
CHANGED
|
@@ -37,6 +37,17 @@ exports.clearSitemapCollection = exports.generateSitemap = exports.collectCatego
|
|
|
37
37
|
const path = __importStar(require("path"));
|
|
38
38
|
const paths_1 = require("../paths");
|
|
39
39
|
const writeFile_1 = require("../utils/writeFile");
|
|
40
|
+
/**
|
|
41
|
+
* Escape special XML characters to prevent parsing errors
|
|
42
|
+
*/
|
|
43
|
+
const escapeXml = (str) => {
|
|
44
|
+
return str
|
|
45
|
+
.replace(/&/g, '&')
|
|
46
|
+
.replace(/</g, '<')
|
|
47
|
+
.replace(/>/g, '>')
|
|
48
|
+
.replace(/"/g, '"')
|
|
49
|
+
.replace(/'/g, ''');
|
|
50
|
+
};
|
|
40
51
|
const sitemapUrls = new Map();
|
|
41
52
|
const collectUrl = (lang, slug) => {
|
|
42
53
|
if (!slug)
|
|
@@ -89,11 +100,12 @@ const generateSitemap = async (baseUrl) => {
|
|
|
89
100
|
sitemap += ` <url>\n`;
|
|
90
101
|
for (const langEntry of entry.langs) {
|
|
91
102
|
const fullUrl = `${baseUrlClean}${langEntry.path}`;
|
|
92
|
-
|
|
103
|
+
// encodeURI handles URL encoding, escapeXml handles XML special characters
|
|
104
|
+
const fullUrlEscaped = escapeXml(encodeURI(fullUrl));
|
|
93
105
|
if (langEntry.lang === entry.langs[0].lang) {
|
|
94
|
-
sitemap += ` <loc>${
|
|
106
|
+
sitemap += ` <loc>${fullUrlEscaped}</loc>\n`;
|
|
95
107
|
}
|
|
96
|
-
sitemap += ` <xhtml:link rel="alternate" hreflang="${langEntry.lang}" href="${
|
|
108
|
+
sitemap += ` <xhtml:link rel="alternate" hreflang="${langEntry.lang}" href="${fullUrlEscaped}"/>\n`;
|
|
97
109
|
}
|
|
98
110
|
sitemap += ` </url>\n`;
|
|
99
111
|
}
|