@onruntime/next-sitemap 0.2.0 → 0.2.1

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.
@@ -100,8 +100,20 @@ function extractRoutes(pagesContext, localeSegment) {
100
100
  for (const key of pagesContext.keys()) {
101
101
  if (key.includes("[...")) continue;
102
102
  const pageModule = pagesContext(key);
103
- let pathname = key.replace("./", "/").replace("/page.tsx", "").replace(new RegExp(`^/${localeSegment.replace(/[[\]]/g, "\\$&")}`), "").replace(/\/\([^)]+\)/g, "") || "/";
104
- if (pathname === "") pathname = "/";
103
+ let pathname = key.replace("./", "/").replace("/page.tsx", "");
104
+ if (localeSegment) {
105
+ pathname = pathname.replace(
106
+ new RegExp(`^/${localeSegment.replace(/[[\]]/g, "\\$&")}`),
107
+ ""
108
+ );
109
+ }
110
+ pathname = pathname.replace(/\/\([^)]+\)/g, "");
111
+ if (/(?:^|\/)(src|app)(?:\/|$)/.test(pathname)) continue;
112
+ if (!pathname || pathname === "") {
113
+ pathname = "/";
114
+ } else if (!pathname.startsWith("/")) {
115
+ pathname = "/" + pathname;
116
+ }
105
117
  const dynamicSegments = pathname.match(/\[([^\]]+)\]/g)?.map((s) => s.slice(1, -1)) || [];
106
118
  routes.push({
107
119
  pathname,
package/dist/app/index.js CHANGED
@@ -98,8 +98,20 @@ function extractRoutes(pagesContext, localeSegment) {
98
98
  for (const key of pagesContext.keys()) {
99
99
  if (key.includes("[...")) continue;
100
100
  const pageModule = pagesContext(key);
101
- let pathname = key.replace("./", "/").replace("/page.tsx", "").replace(new RegExp(`^/${localeSegment.replace(/[[\]]/g, "\\$&")}`), "").replace(/\/\([^)]+\)/g, "") || "/";
102
- if (pathname === "") pathname = "/";
101
+ let pathname = key.replace("./", "/").replace("/page.tsx", "");
102
+ if (localeSegment) {
103
+ pathname = pathname.replace(
104
+ new RegExp(`^/${localeSegment.replace(/[[\]]/g, "\\$&")}`),
105
+ ""
106
+ );
107
+ }
108
+ pathname = pathname.replace(/\/\([^)]+\)/g, "");
109
+ if (/(?:^|\/)(src|app)(?:\/|$)/.test(pathname)) continue;
110
+ if (!pathname || pathname === "") {
111
+ pathname = "/";
112
+ } else if (!pathname.startsWith("/")) {
113
+ pathname = "/" + pathname;
114
+ }
103
115
  const dynamicSegments = pathname.match(/\[([^\]]+)\]/g)?.map((s) => s.slice(1, -1)) || [];
104
116
  routes.push({
105
117
  pathname,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onruntime/next-sitemap",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Dynamic sitemap generation for Next.js with automatic route discovery",
5
5
  "author": "onRuntime Studio <contact@onruntime.com>",
6
6
  "repository": {