@onruntime/next-sitemap 0.4.0 → 0.4.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 +9 -3
- package/dist/app/index.js +9 -3
- package/dist/index.cjs +10 -3
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +10 -4
- package/dist/pages/index.cjs +9 -3
- package/dist/pages/index.js +9 -3
- package/package.json +4 -2
package/dist/app/index.cjs
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
function calculateDepthPriority(pathname) {
|
|
5
5
|
if (pathname === "/") return 1;
|
|
6
6
|
const depth = pathname.split("/").filter(Boolean).length;
|
|
7
|
-
|
|
7
|
+
const priority = Math.max(0.1, 1 - depth * 0.2);
|
|
8
|
+
return Math.round(priority * 100) / 100;
|
|
8
9
|
}
|
|
9
10
|
function shouldExclude(pathname, exclude) {
|
|
10
11
|
if (!exclude) return false;
|
|
@@ -35,11 +36,16 @@ function getChangeFreq(pathname, changeFreq) {
|
|
|
35
36
|
}
|
|
36
37
|
return changeFreq;
|
|
37
38
|
}
|
|
39
|
+
function normalizePath(pathname) {
|
|
40
|
+
if (pathname === "/") return pathname;
|
|
41
|
+
return pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
|
|
42
|
+
}
|
|
38
43
|
function buildUrl(baseUrl, pathname, locale, defaultLocale) {
|
|
44
|
+
const normalizedPath = normalizePath(pathname);
|
|
39
45
|
if (!locale || locale === defaultLocale) {
|
|
40
|
-
return `${baseUrl}${
|
|
46
|
+
return `${baseUrl}${normalizedPath}`;
|
|
41
47
|
}
|
|
42
|
-
return `${baseUrl}/${locale}${
|
|
48
|
+
return `${baseUrl}/${locale}${normalizedPath}`;
|
|
43
49
|
}
|
|
44
50
|
function generateSitemapXml(entries) {
|
|
45
51
|
const hasAlternates = entries.some((e) => e.alternates?.languages);
|
package/dist/app/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
function calculateDepthPriority(pathname) {
|
|
3
3
|
if (pathname === "/") return 1;
|
|
4
4
|
const depth = pathname.split("/").filter(Boolean).length;
|
|
5
|
-
|
|
5
|
+
const priority = Math.max(0.1, 1 - depth * 0.2);
|
|
6
|
+
return Math.round(priority * 100) / 100;
|
|
6
7
|
}
|
|
7
8
|
function shouldExclude(pathname, exclude) {
|
|
8
9
|
if (!exclude) return false;
|
|
@@ -33,11 +34,16 @@ function getChangeFreq(pathname, changeFreq) {
|
|
|
33
34
|
}
|
|
34
35
|
return changeFreq;
|
|
35
36
|
}
|
|
37
|
+
function normalizePath(pathname) {
|
|
38
|
+
if (pathname === "/") return pathname;
|
|
39
|
+
return pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
|
|
40
|
+
}
|
|
36
41
|
function buildUrl(baseUrl, pathname, locale, defaultLocale) {
|
|
42
|
+
const normalizedPath = normalizePath(pathname);
|
|
37
43
|
if (!locale || locale === defaultLocale) {
|
|
38
|
-
return `${baseUrl}${
|
|
44
|
+
return `${baseUrl}${normalizedPath}`;
|
|
39
45
|
}
|
|
40
|
-
return `${baseUrl}/${locale}${
|
|
46
|
+
return `${baseUrl}/${locale}${normalizedPath}`;
|
|
41
47
|
}
|
|
42
48
|
function generateSitemapXml(entries) {
|
|
43
49
|
const hasAlternates = entries.some((e) => e.alternates?.languages);
|
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
function calculateDepthPriority(pathname) {
|
|
5
5
|
if (pathname === "/") return 1;
|
|
6
6
|
const depth = pathname.split("/").filter(Boolean).length;
|
|
7
|
-
|
|
7
|
+
const priority = Math.max(0.1, 1 - depth * 0.2);
|
|
8
|
+
return Math.round(priority * 100) / 100;
|
|
8
9
|
}
|
|
9
10
|
function shouldExclude(pathname, exclude) {
|
|
10
11
|
if (!exclude) return false;
|
|
@@ -35,11 +36,16 @@ function getChangeFreq(pathname, changeFreq) {
|
|
|
35
36
|
}
|
|
36
37
|
return changeFreq;
|
|
37
38
|
}
|
|
39
|
+
function normalizePath(pathname) {
|
|
40
|
+
if (pathname === "/") return pathname;
|
|
41
|
+
return pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
|
|
42
|
+
}
|
|
38
43
|
function buildUrl(baseUrl, pathname, locale, defaultLocale) {
|
|
44
|
+
const normalizedPath = normalizePath(pathname);
|
|
39
45
|
if (!locale || locale === defaultLocale) {
|
|
40
|
-
return `${baseUrl}${
|
|
46
|
+
return `${baseUrl}${normalizedPath}`;
|
|
41
47
|
}
|
|
42
|
-
return `${baseUrl}/${locale}${
|
|
48
|
+
return `${baseUrl}/${locale}${normalizedPath}`;
|
|
43
49
|
}
|
|
44
50
|
function generateSitemapXml(entries) {
|
|
45
51
|
const hasAlternates = entries.some((e) => e.alternates?.languages);
|
|
@@ -100,4 +106,5 @@ exports.generateSitemapIndexXml = generateSitemapIndexXml;
|
|
|
100
106
|
exports.generateSitemapXml = generateSitemapXml;
|
|
101
107
|
exports.getChangeFreq = getChangeFreq;
|
|
102
108
|
exports.getPriority = getPriority;
|
|
109
|
+
exports.normalizePath = normalizePath;
|
|
103
110
|
exports.shouldExclude = shouldExclude;
|
package/dist/index.d.cts
CHANGED
|
@@ -92,6 +92,10 @@ interface RouteInfo {
|
|
|
92
92
|
type PageModule = {
|
|
93
93
|
generateStaticParams?: () => Promise<Record<string, string>[]>;
|
|
94
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* Normalize pathname by removing trailing slash (except for root)
|
|
97
|
+
*/
|
|
98
|
+
declare function normalizePath(pathname: string): string;
|
|
95
99
|
/**
|
|
96
100
|
* Generate the full URL for a pathname
|
|
97
101
|
*/
|
|
@@ -108,4 +112,4 @@ declare function generateSitemapIndexXml(baseUrl: string, sitemapCount: number,
|
|
|
108
112
|
additionalSitemaps?: string[];
|
|
109
113
|
}): string;
|
|
110
114
|
|
|
111
|
-
export { type ChangeFrequency, type PageModule, type RouteInfo, type SitemapConfig, type SitemapEntry, buildUrl, calculateDepthPriority, generateSitemapIndexXml, generateSitemapXml, getChangeFreq, getPriority, shouldExclude };
|
|
115
|
+
export { type ChangeFrequency, type PageModule, type RouteInfo, type SitemapConfig, type SitemapEntry, buildUrl, calculateDepthPriority, generateSitemapIndexXml, generateSitemapXml, getChangeFreq, getPriority, normalizePath, shouldExclude };
|
package/dist/index.d.ts
CHANGED
|
@@ -92,6 +92,10 @@ interface RouteInfo {
|
|
|
92
92
|
type PageModule = {
|
|
93
93
|
generateStaticParams?: () => Promise<Record<string, string>[]>;
|
|
94
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* Normalize pathname by removing trailing slash (except for root)
|
|
97
|
+
*/
|
|
98
|
+
declare function normalizePath(pathname: string): string;
|
|
95
99
|
/**
|
|
96
100
|
* Generate the full URL for a pathname
|
|
97
101
|
*/
|
|
@@ -108,4 +112,4 @@ declare function generateSitemapIndexXml(baseUrl: string, sitemapCount: number,
|
|
|
108
112
|
additionalSitemaps?: string[];
|
|
109
113
|
}): string;
|
|
110
114
|
|
|
111
|
-
export { type ChangeFrequency, type PageModule, type RouteInfo, type SitemapConfig, type SitemapEntry, buildUrl, calculateDepthPriority, generateSitemapIndexXml, generateSitemapXml, getChangeFreq, getPriority, shouldExclude };
|
|
115
|
+
export { type ChangeFrequency, type PageModule, type RouteInfo, type SitemapConfig, type SitemapEntry, buildUrl, calculateDepthPriority, generateSitemapIndexXml, generateSitemapXml, getChangeFreq, getPriority, normalizePath, shouldExclude };
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
function calculateDepthPriority(pathname) {
|
|
3
3
|
if (pathname === "/") return 1;
|
|
4
4
|
const depth = pathname.split("/").filter(Boolean).length;
|
|
5
|
-
|
|
5
|
+
const priority = Math.max(0.1, 1 - depth * 0.2);
|
|
6
|
+
return Math.round(priority * 100) / 100;
|
|
6
7
|
}
|
|
7
8
|
function shouldExclude(pathname, exclude) {
|
|
8
9
|
if (!exclude) return false;
|
|
@@ -33,11 +34,16 @@ function getChangeFreq(pathname, changeFreq) {
|
|
|
33
34
|
}
|
|
34
35
|
return changeFreq;
|
|
35
36
|
}
|
|
37
|
+
function normalizePath(pathname) {
|
|
38
|
+
if (pathname === "/") return pathname;
|
|
39
|
+
return pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
|
|
40
|
+
}
|
|
36
41
|
function buildUrl(baseUrl, pathname, locale, defaultLocale) {
|
|
42
|
+
const normalizedPath = normalizePath(pathname);
|
|
37
43
|
if (!locale || locale === defaultLocale) {
|
|
38
|
-
return `${baseUrl}${
|
|
44
|
+
return `${baseUrl}${normalizedPath}`;
|
|
39
45
|
}
|
|
40
|
-
return `${baseUrl}/${locale}${
|
|
46
|
+
return `${baseUrl}/${locale}${normalizedPath}`;
|
|
41
47
|
}
|
|
42
48
|
function generateSitemapXml(entries) {
|
|
43
49
|
const hasAlternates = entries.some((e) => e.alternates?.languages);
|
|
@@ -92,4 +98,4 @@ ${allEntries}
|
|
|
92
98
|
</sitemapindex>`;
|
|
93
99
|
}
|
|
94
100
|
|
|
95
|
-
export { buildUrl, calculateDepthPriority, generateSitemapIndexXml, generateSitemapXml, getChangeFreq, getPriority, shouldExclude };
|
|
101
|
+
export { buildUrl, calculateDepthPriority, generateSitemapIndexXml, generateSitemapXml, getChangeFreq, getPriority, normalizePath, shouldExclude };
|
package/dist/pages/index.cjs
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
function calculateDepthPriority(pathname) {
|
|
5
5
|
if (pathname === "/") return 1;
|
|
6
6
|
const depth = pathname.split("/").filter(Boolean).length;
|
|
7
|
-
|
|
7
|
+
const priority = Math.max(0.1, 1 - depth * 0.2);
|
|
8
|
+
return Math.round(priority * 100) / 100;
|
|
8
9
|
}
|
|
9
10
|
function shouldExclude(pathname, exclude) {
|
|
10
11
|
if (!exclude) return false;
|
|
@@ -35,11 +36,16 @@ function getChangeFreq(pathname, changeFreq) {
|
|
|
35
36
|
}
|
|
36
37
|
return changeFreq;
|
|
37
38
|
}
|
|
39
|
+
function normalizePath(pathname) {
|
|
40
|
+
if (pathname === "/") return pathname;
|
|
41
|
+
return pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
|
|
42
|
+
}
|
|
38
43
|
function buildUrl(baseUrl, pathname, locale, defaultLocale) {
|
|
44
|
+
const normalizedPath = normalizePath(pathname);
|
|
39
45
|
if (!locale || locale === defaultLocale) {
|
|
40
|
-
return `${baseUrl}${
|
|
46
|
+
return `${baseUrl}${normalizedPath}`;
|
|
41
47
|
}
|
|
42
|
-
return `${baseUrl}/${locale}${
|
|
48
|
+
return `${baseUrl}/${locale}${normalizedPath}`;
|
|
43
49
|
}
|
|
44
50
|
function generateSitemapXml(entries) {
|
|
45
51
|
const hasAlternates = entries.some((e) => e.alternates?.languages);
|
package/dist/pages/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
function calculateDepthPriority(pathname) {
|
|
3
3
|
if (pathname === "/") return 1;
|
|
4
4
|
const depth = pathname.split("/").filter(Boolean).length;
|
|
5
|
-
|
|
5
|
+
const priority = Math.max(0.1, 1 - depth * 0.2);
|
|
6
|
+
return Math.round(priority * 100) / 100;
|
|
6
7
|
}
|
|
7
8
|
function shouldExclude(pathname, exclude) {
|
|
8
9
|
if (!exclude) return false;
|
|
@@ -33,11 +34,16 @@ function getChangeFreq(pathname, changeFreq) {
|
|
|
33
34
|
}
|
|
34
35
|
return changeFreq;
|
|
35
36
|
}
|
|
37
|
+
function normalizePath(pathname) {
|
|
38
|
+
if (pathname === "/") return pathname;
|
|
39
|
+
return pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
|
|
40
|
+
}
|
|
36
41
|
function buildUrl(baseUrl, pathname, locale, defaultLocale) {
|
|
42
|
+
const normalizedPath = normalizePath(pathname);
|
|
37
43
|
if (!locale || locale === defaultLocale) {
|
|
38
|
-
return `${baseUrl}${
|
|
44
|
+
return `${baseUrl}${normalizedPath}`;
|
|
39
45
|
}
|
|
40
|
-
return `${baseUrl}/${locale}${
|
|
46
|
+
return `${baseUrl}/${locale}${normalizedPath}`;
|
|
41
47
|
}
|
|
42
48
|
function generateSitemapXml(entries) {
|
|
43
49
|
const hasAlternates = entries.some((e) => e.alternates?.languages);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onruntime/next-sitemap",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.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": {
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"@types/node": "^22.0.0",
|
|
46
46
|
"next": "^16.1.1",
|
|
47
47
|
"tsup": "^8",
|
|
48
|
+
"tsx": "^4",
|
|
48
49
|
"typescript": "^5"
|
|
49
50
|
},
|
|
50
51
|
"keywords": [
|
|
@@ -60,6 +61,7 @@
|
|
|
60
61
|
"scripts": {
|
|
61
62
|
"build": "tsup",
|
|
62
63
|
"dev": "tsup --watch",
|
|
63
|
-
"type-check": "tsc --noEmit"
|
|
64
|
+
"type-check": "tsc --noEmit",
|
|
65
|
+
"test": "tsx --test tests/index.ts"
|
|
64
66
|
}
|
|
65
67
|
}
|