Skip to content

Commit

Permalink
fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
KishiTheMechanic committed Oct 28, 2024
1 parent 412b3ad commit c8a71aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
23 changes: 8 additions & 15 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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$/, '')
Expand Down

0 comments on commit c8a71aa

Please sign in to comment.