@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.
- package/dist/app/index.cjs +14 -2
- package/dist/app/index.js +14 -2
- package/package.json +1 -1
package/dist/app/index.cjs
CHANGED
|
@@ -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", "")
|
|
104
|
-
if (
|
|
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", "")
|
|
102
|
-
if (
|
|
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