Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KishiTheMechanic committed Oct 27, 2024
1 parent 968f12a commit 8604d6c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 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.0",
"version": "0.7.1",
"description": "Lightweight global state management library for Fresh framework using Preact signals.",
"runtimes": ["deno", "browser"],
"exports": "./mod.ts",
Expand Down
7 changes: 4 additions & 3 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,21 @@ async function generateSitemap(
if (filteredSegments.length === 0) continue // Skip if no valid segments remain

const pathname = `/${filteredSegments.join('/')}`
.replace(/\/+/g, '/') // Replace multiple slashes with a single slash
const isExcluded = exclude && exclude.test(pathname.substring(1))
const isIncluded = !include || include.test(pathname.substring(1))
if (isExcluded || !isIncluded) continue

const { mtime } = await Deno.stat(path)
sitemap.push({
loc: basename + pathname,
loc: basename.replace(/\/+$/, '') + pathname,
lastmod: (mtime ?? new Date()).toISOString(),
})

options.languages?.forEach((lang) => {
if (lang !== options.defaultLanguage) {
sitemap.push({
loc: `${basename}/${lang}${pathname}`,
loc: `${basename}/${lang}${pathname}`.replace(/\/+/g, '/'),
lastmod: (mtime ?? new Date()).toISOString(),
})
}
Expand Down Expand Up @@ -191,7 +192,7 @@ async function generateArticlesSitemap(
for (const urlPath of urlPaths) {
const { mtime } = await Deno.stat(path)
sitemap.push({
loc: basename + urlPath,
loc: basename.replace(/\/+$/, '') + urlPath,
lastmod: (mtime ?? new Date()).toISOString(),
})
}
Expand Down

0 comments on commit 8604d6c

Please sign in to comment.