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.
@@ -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: ${path.join(metadata_1.MetaData.options.site.baseUrl, 'sitemap.xml')}` : ''}
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);
@@ -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, '&lt;')
47
+ .replace(/>/g, '&gt;')
48
+ .replace(/"/g, '&quot;')
49
+ .replace(/'/g, '&apos;');
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
- const fullUrlEncoded = encodeURI(fullUrl);
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>${fullUrlEncoded}</loc>\n`;
106
+ sitemap += ` <loc>${fullUrlEscaped}</loc>\n`;
95
107
  }
96
- sitemap += ` <xhtml:link rel="alternate" hreflang="${langEntry.lang}" href="${fullUrlEncoded}"/>\n`;
108
+ sitemap += ` <xhtml:link rel="alternate" hreflang="${langEntry.lang}" href="${fullUrlEscaped}"/>\n`;
97
109
  }
98
110
  sitemap += ` </url>\n`;
99
111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "czon",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
4
4
  "description": "CZON - AI enhanced Markdown content engine",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",