diff --git a/deno.json b/deno.json index d3bd403..41a24e0 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@elsoul/fresh-sitemap", - "version": "0.7.6", + "version": "0.7.7", "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 71d36c6..47847a2 100644 --- a/mod.ts +++ b/mod.ts @@ -116,13 +116,15 @@ async function generateSitemap( ) const normalizedPath = `/${segments.join('/')}` + // Ignore paths with `_` or `()` segments + if ( + segments.some((segment) => + segment.startsWith('_') || segment.match(/\(.*\)/) + ) + ) return + // Initialize path in pathMap pathMap[normalizedPath] = 1 - - // If any segment contains `_`, mark path as 0 to exclude - if (segments.some((segment) => segment.startsWith('_'))) { - pathMap[normalizedPath] = 0 - } } // Retrieve all paths recursively @@ -134,16 +136,7 @@ async function generateSitemap( await addDirectory(distDirectory) - // Remove segments with `()` characters - for (const path in pathMap) { - if (pathMap[path] === 1) { - const cleanedPath = path.replace(/\(.*?\)/g, '') - pathMap[cleanedPath] = 1 - delete pathMap[path] - } - } - - // Remove `index` as a segment, but keep the path + // Remove `index` as the last segment only, but keep the path structure for (const path in pathMap) { if (pathMap[path] === 1) { const cleanedPath = path.replace(/\/index$/, '')