From 412b3ad7dda47c8fd8bdd55053ca4649ae47a592 Mon Sep 17 00:00:00 2001 From: KishiTheMechanic Date: Mon, 28 Oct 2024 01:39:28 +0100 Subject: [PATCH] fixing --- deno.json | 2 +- mod.ts | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/deno.json b/deno.json index c35b8c7..d3bd403 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@elsoul/fresh-sitemap", - "version": "0.7.5", + "version": "0.7.6", "description": "Lightweight global state management library for Fresh framework using Preact signals.", "runtimes": ["deno", "browser"], "exports": "./mod.ts", diff --git a/mod.ts b/mod.ts index f97d626..71d36c6 100644 --- a/mod.ts +++ b/mod.ts @@ -90,7 +90,7 @@ export async function saveSitemapAndRobots( /** * Generates sitemap entries for static routes, excluding dynamic and grouping directories. - * Ensures `_` and `()` directories and `index.tsx` files are excluded. + * Ensures `_` and `()` directories and `index.tsx` files are correctly processed. * @param basename - The base URL * @param distDirectory - Directory containing routes * @param options - Options for sitemap generation @@ -143,12 +143,14 @@ async function generateSitemap( } } - // Remove `index` as the last segment + // Remove `index` as a segment, but keep the path for (const path in pathMap) { - if (pathMap[path] === 1 && path.endsWith('/index')) { + if (pathMap[path] === 1) { const cleanedPath = path.replace(/\/index$/, '') - pathMap[cleanedPath] = 1 - delete pathMap[path] + if (cleanedPath !== path) { + pathMap[cleanedPath] = 1 + delete pathMap[path] + } } }