olum-compiler 2.0.2 → 2.0.3

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.
Files changed (2) hide show
  1. package/bin/ssg.js +11 -2
  2. package/package.json +1 -1
package/bin/ssg.js CHANGED
@@ -197,14 +197,17 @@ const xmlEscape = (str) =>
197
197
  .replace(/'/g, "'");
198
198
 
199
199
  function writeSitemapXml(finalRoutes) {
200
+ const has404 = finalRoutes.find((item) => item == "/404");
200
201
  const base = siteUrl();
201
202
  if (!base)
202
203
  fail(
203
204
  'no package.json "olum.SITE_URL" — sitemap.xml falls back to relative paths, which crawlers ignore',
204
205
  );
205
206
 
206
- const urls = finalRoutes.filter((route) =>
207
- fs.existsSync(path.join(distDir, route, "index.html")),
207
+ const urls = finalRoutes.filter(
208
+ (route) =>
209
+ route !== "/404" &&
210
+ fs.existsSync(path.join(distDir, route, "index.html")),
208
211
  );
209
212
  const lastmod = new Date().toISOString().slice(0, 10);
210
213
  const body = urls
@@ -218,6 +221,12 @@ function writeSitemapXml(finalRoutes) {
218
221
  path.join(distDir, "sitemap.xml"),
219
222
  `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${body}\n</urlset>\n`,
220
223
  );
224
+
225
+ if (has404 && fs.existsSync(path.join(distDir, "404", "index.html")))
226
+ fs.copyFileSync(
227
+ path.join(distDir, "404", "index.html"),
228
+ path.join(distDir, "404.html"),
229
+ );
221
230
  return urls.length;
222
231
  }
223
232
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "olum-compiler",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "A module for compiling/bundling olumjs projects",
5
5
  "main": "bin/index.js",
6
6
  "bin": {