next-advanced-sitemap 1.1.1 → 1.1.3
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/LICENSE +23 -23
- package/README.md +333 -218
- package/dist/index.cjs +28 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +28 -4
- package/dist/index.js.map +1 -1
- package/package.json +55 -55
package/LICENSE
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
FomaDev Public License (FPL)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 FomaDev. All rights reserved.
|
|
4
|
-
|
|
5
|
-
This license protects next-advanced-sitemap innovation while encouraging community collaboration.
|
|
6
|
-
|
|
7
|
-
1. Personal and Educational Use
|
|
8
|
-
The use of the next-advanced-sitemap library is entirely free for developers and companies, including within commercial projects, as long as it is used as a dependency. You may integrate and use this tool in your websites or applications without any payment to FomaDev.
|
|
9
|
-
|
|
10
|
-
2. Contributions (Fork & Pull Request)
|
|
11
|
-
Forks are authorized ONLY for contributing to the official FomaDev project. Any improvements, bug fixes, or new features must be submitted via a Pull Request to the original repository. By contributing, you agree that your code will be integrated under this same license.
|
|
12
|
-
|
|
13
|
-
3. Commercial Use and Competition (PAID)
|
|
14
|
-
A paid commercial license is MANDATORY for the following cases:
|
|
15
|
-
- Selling, redistributing, or sub-licensing the source code of this library.
|
|
16
|
-
- Creating a derivative sitemap generation tool or library based on this source code.
|
|
17
|
-
- Integrating this source code directly into another commercial library or framework intended for sale.
|
|
18
|
-
- Building a paid "Sitemap as a Service" platform based on this specific engine.
|
|
19
|
-
|
|
20
|
-
4. Prohibition of Independent Forks
|
|
21
|
-
Maintaining a separate version (permanent Fork) of this project to bypass FomaDev's authority or to create a competing package on registries (such as npm) is strictly prohibited.
|
|
22
|
-
|
|
23
|
-
5. Licensing Contact
|
|
1
|
+
FomaDev Public License (FPL)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FomaDev. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This license protects next-advanced-sitemap innovation while encouraging community collaboration.
|
|
6
|
+
|
|
7
|
+
1. Personal and Educational Use
|
|
8
|
+
The use of the next-advanced-sitemap library is entirely free for developers and companies, including within commercial projects, as long as it is used as a dependency. You may integrate and use this tool in your websites or applications without any payment to FomaDev.
|
|
9
|
+
|
|
10
|
+
2. Contributions (Fork & Pull Request)
|
|
11
|
+
Forks are authorized ONLY for contributing to the official FomaDev project. Any improvements, bug fixes, or new features must be submitted via a Pull Request to the original repository. By contributing, you agree that your code will be integrated under this same license.
|
|
12
|
+
|
|
13
|
+
3. Commercial Use and Competition (PAID)
|
|
14
|
+
A paid commercial license is MANDATORY for the following cases:
|
|
15
|
+
- Selling, redistributing, or sub-licensing the source code of this library.
|
|
16
|
+
- Creating a derivative sitemap generation tool or library based on this source code.
|
|
17
|
+
- Integrating this source code directly into another commercial library or framework intended for sale.
|
|
18
|
+
- Building a paid "Sitemap as a Service" platform based on this specific engine.
|
|
19
|
+
|
|
20
|
+
4. Prohibition of Independent Forks
|
|
21
|
+
Maintaining a separate version (permanent Fork) of this project to bypass FomaDev's authority or to create a competing package on registries (such as npm) is strictly prohibited.
|
|
22
|
+
|
|
23
|
+
5. Licensing Contact
|
|
24
24
|
To obtain commercial authorization, negotiate an exploitation license, or for any questions regarding professional use, contact Fordi (FomaDev) directly.
|
package/README.md
CHANGED
|
@@ -1,219 +1,334 @@
|
|
|
1
|
-
# next-advanced-sitemap
|
|
2
|
-
|
|
3
|
-
[](LICENSE)
|
|
4
|
-

|
|
5
|
-
|
|
6
|
-
A robust and type-safe sitemap generator for Next.js (App Router). This library extends standard sitemap capabilities by providing native support for Google-specific metadata including Images, Videos, News, and Internationalization (Hreflang).
|
|
7
|
-
|
|
8
|
-
## Overview
|
|
9
|
-
|
|
10
|
-
While Next.js provides a built-in `MetadataRoute.Sitemap` utility, it currently lacks support for advanced SEO attributes required by high-performance web applications. `next-advanced-sitemap` bridges this gap, allowing developers to programmatically generate complex XML sitemaps that comply with Google's extended schemas.
|
|
11
|
-
|
|
12
|
-
## Features
|
|
13
|
-
|
|
14
|
-
- **Google Images Support**:
|
|
15
|
-
- **
|
|
16
|
-
- **Google Video
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
22
|
-
- **
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
25
|
-
- **
|
|
26
|
-
- **
|
|
27
|
-
- **
|
|
28
|
-
- **
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
{ hreflang: '
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
<td><
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
<td
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
<td
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
<td
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
<td
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
<td
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
<td
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
<td
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
<td
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
1
|
+
# next-advanced-sitemap
|
|
2
|
+
|
|
3
|
+
[](LICENSE)
|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
A robust and type-safe sitemap generator for Next.js (App Router). This library extends standard sitemap capabilities by providing native support for Google-specific metadata including Images, Videos, News, and Internationalization (Hreflang).
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
While Next.js provides a built-in `MetadataRoute.Sitemap` utility, it currently lacks support for advanced SEO attributes required by high-performance web applications. `next-advanced-sitemap` bridges this gap, allowing developers to programmatically generate complex XML sitemaps that comply with Google's extended schemas.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- **Google Images Support**: Complete indexation of visual assets with support for titles, captions, local SEO positioning, and copyright protections.
|
|
15
|
+
- **Image Accessibility Protection (v1.1.2)**: Advanced preventive protection against empty text strings or spaces (`.trim()`) in `title` and `caption` fields to completely eliminate malformed empty XML tokens.
|
|
16
|
+
- **Google Video Support**: Boost video search layouts and video-carousel presence on Google Search with complete structured data encapsulation.
|
|
17
|
+
- **Video Engagement Metrics & Validation (v1.1.3)**: Native integration of `<video:duration>` and `<video:view_count>` statistical metrics featuring deterministic float truncation (`Math.floor`) and strict bounding boundaries (0 to 28,800 seconds max).
|
|
18
|
+
- **Google Video Live Streaming (v1.1.1)**: Native injection of the `<video:live>` parameter to flag active real-time broadcasts and instantly trigger red **LIVE** badges on Google SERP matrices.
|
|
19
|
+
- **Google News Support**: Instant discovery for news publications with strict support for required news name, language tag, and publication date attributes.
|
|
20
|
+
- **Internationalization (Hreflang)**: Seamless rendering of `xhtml:link` relation tags to govern multi-regional and multilingual indexing across global markets.
|
|
21
|
+
- **Priority Auto-Sorting (v1.0.8)**: Optional deterministic descending sort (`1.0` down to `0.0`) based on entry weights to present your most strategic revenue-driving pages to crawlers first.
|
|
22
|
+
- **Auto-Trimming Sanitization (v1.0.7)**: Automatic `.trim()` execution on all URL structures to silently correct leading/trailing whitespace errors originating from CMS fields or raw databases.
|
|
23
|
+
- **Native Date Polymorphism (v1.0.6)**: Full support for native JavaScript `Date` objects inside all extensions—handling internal conversion and structural formatting automatically.
|
|
24
|
+
- **Strict SEO Enum Typing (v1.0.5)**: Compile-time validation and IDE autocompletion for `changefreq` and `priority` keys to completely lock out manual layout typos.
|
|
25
|
+
- **Strict Structural Validation (v1.0.4)**: Advanced URL parsing using the platform-native engine to intercept syntax errors and unencoded internal spaces before application deployment.
|
|
26
|
+
- **Auto-lastmod (v1.0.3)**: Optional automatic injection of the current system ISO date for entries missing an explicit `lastmod` tracking value.
|
|
27
|
+
- **Deep XML Metadata Escaping (v1.0.2)**: Enhanced, high-performance regex processor to safely handle complex special characters (`&`, `"`, `'`, `<`, `>`) inside titles, descriptions, and captions.
|
|
28
|
+
- **Custom TTL Cache-Control (v1.0.9)**: Direct control over sitemap caching persistence using a clean `maxAge` configuration option to lower crawl footprints on backend nodes.
|
|
29
|
+
- **Local SEO & Image Licensing (v1.1.0)**: Support for `geo_location` parameters and programmatic `license` badges to trigger Google's image search retail overlay.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install next-advanced-sitemap
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
To implement an advanced sitemap in the Next.js App Router, create a Route Handler at `app/sitemap.xml/route.ts`.
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { getServerSitemapResponse, SitemapEntry } from 'next-advanced-sitemap';
|
|
43
|
+
|
|
44
|
+
export async function GET() {
|
|
45
|
+
const entries: SitemapEntry[] = [
|
|
46
|
+
{
|
|
47
|
+
url: ' https://fomadev.com ', // Auto-trimmed seamlessly in v1.0.7
|
|
48
|
+
lastmod: new Date(),
|
|
49
|
+
changefreq: 'daily', // Strictly typed
|
|
50
|
+
priority: 1.0, // Auto-completed and strictly typed
|
|
51
|
+
alternates: [
|
|
52
|
+
{ hreflang: 'fr', href: 'https://fomadev.com/fr' },
|
|
53
|
+
{ hreflang: 'en', href: 'https://fomadev.com/en' }
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
url: 'https://fomadev.com/live-stream',
|
|
58
|
+
priority: 0.9,
|
|
59
|
+
videos: [
|
|
60
|
+
{
|
|
61
|
+
thumbnail_loc: 'https://fomadev.com/thumbs/live.jpg ',
|
|
62
|
+
title: 'FomaDev Live Tech Session',
|
|
63
|
+
description: 'Building production-grade packages with Next.js.',
|
|
64
|
+
publication_date: new Date(),
|
|
65
|
+
duration: 3600, // v1.1.3: Statistical metric (Duration in seconds)
|
|
66
|
+
view_count: 1420, // v1.1.3: Engagement metric (Views integer)
|
|
67
|
+
live: 'yes' // v1.1.1: Triggers the official Google LIVE badge on SERP
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
url: 'https://fomadev.com/products/tech-item',
|
|
73
|
+
priority: 0.8,
|
|
74
|
+
images: [
|
|
75
|
+
{
|
|
76
|
+
loc: 'https://fomadev.com/images/product.png',
|
|
77
|
+
title: ' Premium Wireless Keyboard ', // v1.1.2: Auto-trimmed preventively
|
|
78
|
+
caption: 'Close-up shot of our custom mechanical keyboard layout with XML characters like & or <', // v1.1.2: Deep XML Escaping
|
|
79
|
+
geo_location: 'Kinshasa, Democratic Republic of the Congo', // v1.1.0 Local SEO
|
|
80
|
+
license: 'https://fomadev.com/terms/licensing' // v1.1.0 Badging
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
// Enable autoLastmod and sortByPriority (v1.0.8) to optimize crawl efficiency
|
|
87
|
+
return getServerSitemapResponse(entries, {
|
|
88
|
+
autoLastmod: true,
|
|
89
|
+
sortByPriority: true
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## API Reference
|
|
95
|
+
|
|
96
|
+
### getServerSitemapResponse(entries: SitemapEntry[], options?: SitemapOptions)
|
|
97
|
+
|
|
98
|
+
Generates a standard Next.js `Response` object with the correct `application/xml` content-type and optimized cache headers.
|
|
99
|
+
|
|
100
|
+
### Options:
|
|
101
|
+
|
|
102
|
+
* `autoLastmod` (boolean): If `true`, injects the current ISO date for any entry missing the `lastmod` property.
|
|
103
|
+
|
|
104
|
+
* `sortByPriority` (boolean): If `true`, sorts the sitemap records in a descending sequence based on their priority level (`1.0` down to `0.0`) before writing the XML stream. Items without an explicit priority fall back safely to `0.5`.
|
|
105
|
+
|
|
106
|
+
* `maxAge` (number): (Optional) Maximum lifespan duration expressed in seconds. Transforms the HTTP communication layer payload to use a rigid `public, max-age=X, must-revalidate` schema.
|
|
107
|
+
|
|
108
|
+
### SitemapEntry Object
|
|
109
|
+
|
|
110
|
+
<table>
|
|
111
|
+
<thead>
|
|
112
|
+
<tr>
|
|
113
|
+
<th>Property</th>
|
|
114
|
+
<th>Type</th>
|
|
115
|
+
<th>Description</th>
|
|
116
|
+
</tr>
|
|
117
|
+
</thead>
|
|
118
|
+
<tbody>
|
|
119
|
+
<tr>
|
|
120
|
+
<td><code>url</code></td>
|
|
121
|
+
<td>string</td>
|
|
122
|
+
<td><strong>Required.</strong> Absolute target link (must begin with http:// or https://).</td>
|
|
123
|
+
</tr>
|
|
124
|
+
<tr>
|
|
125
|
+
<td><code>lastmod</code></td>
|
|
126
|
+
<td>Date | string</td>
|
|
127
|
+
<td>Optional tracking timestamp reflecting last structural update.</td>
|
|
128
|
+
</tr>
|
|
129
|
+
<tr>
|
|
130
|
+
<td><code>changefreq</code></td>
|
|
131
|
+
<td>SitemapChangeFreq</td>
|
|
132
|
+
<td>Optional hint keyword mapped to engine crawling loops</td>
|
|
133
|
+
</tr>
|
|
134
|
+
<tr>
|
|
135
|
+
<td><code>priority</code></td>
|
|
136
|
+
<td>SitemapPriority</td>
|
|
137
|
+
<td>Optional weight coefficient bounding page value from 0.0 to 1.0.</td>
|
|
138
|
+
</tr>
|
|
139
|
+
<tr>
|
|
140
|
+
<td><code>images</code></td>
|
|
141
|
+
<td>SitemapImage[]</td>
|
|
142
|
+
<td>Optional array containing structural metadata assets for Google Images.</td>
|
|
143
|
+
</tr>
|
|
144
|
+
<tr>
|
|
145
|
+
<td><code>videos</code></td>
|
|
146
|
+
<td>SitemapVideo[]</td>
|
|
147
|
+
<td>Optional array conveying detailed schemas for rich video indexation.</td>
|
|
148
|
+
</tr>
|
|
149
|
+
<tr>
|
|
150
|
+
<td><code>news</code></td>
|
|
151
|
+
<td>SitemapNews</td>
|
|
152
|
+
<td>Optional integration configuration complying with Google News indexing rules.</td>
|
|
153
|
+
</tr>
|
|
154
|
+
<tr>
|
|
155
|
+
<td><code>alternates</code></td>
|
|
156
|
+
<td>SitemapAlternate[]</td>
|
|
157
|
+
<td>Optional translation links array serving Hreflang indexing loops.</td>
|
|
158
|
+
</tr>
|
|
159
|
+
<tr>
|
|
160
|
+
<td><code>geo_location</code></td>
|
|
161
|
+
<td>string</td>
|
|
162
|
+
<td>(Optional) Geographic location string of the image (e.g., "Kinshasa, DRC").</td>
|
|
163
|
+
</tr>
|
|
164
|
+
<tr>
|
|
165
|
+
<td><code>license</code></td>
|
|
166
|
+
<td>string</td>
|
|
167
|
+
<td>(Optional) Valid HTTP/HTTPS URL addressing the licensing rights or usage terms of the image asset.</td>
|
|
168
|
+
</tr>
|
|
169
|
+
</tbody>
|
|
170
|
+
</table>
|
|
171
|
+
|
|
172
|
+
### SitemapImage
|
|
173
|
+
|
|
174
|
+
<table>
|
|
175
|
+
<thead>
|
|
176
|
+
<tr>
|
|
177
|
+
<th>Property</th>
|
|
178
|
+
<th>Type</th>
|
|
179
|
+
<th>Description</th>
|
|
180
|
+
</tr>
|
|
181
|
+
</thead>
|
|
182
|
+
<tbody>
|
|
183
|
+
<tr>
|
|
184
|
+
<td><code>loc</code></td>
|
|
185
|
+
<td>string</td>
|
|
186
|
+
<td><strong>Required.</strong> The absolute URL targeting the source image asset.</td>
|
|
187
|
+
</tr>
|
|
188
|
+
<tr>
|
|
189
|
+
<td><code>title</code></td>
|
|
190
|
+
<td>string</td>
|
|
191
|
+
<td>Optional text representation describing the visual asset. Auto-trimmed.</td>
|
|
192
|
+
</tr>
|
|
193
|
+
<tr>
|
|
194
|
+
<td><code>caption</code></td>
|
|
195
|
+
<td>string</td>
|
|
196
|
+
<td>Optional descriptive context surrounding the element. Deep XML Escaped.</td>
|
|
197
|
+
</tr>
|
|
198
|
+
<tr>
|
|
199
|
+
<td><code>geo_location</code></td>
|
|
200
|
+
<td>string</td>
|
|
201
|
+
<td>Optional location reference (e.g., "Kinshasa, Democratic Republic of the Congo").</td>
|
|
202
|
+
</tr>
|
|
203
|
+
<tr>
|
|
204
|
+
<td><code>license</code></td>
|
|
205
|
+
<td>string</td>
|
|
206
|
+
<td>Optional absolute URL containing intellectual copyright terms or usage badges.</td>
|
|
207
|
+
</tr>
|
|
208
|
+
</tbody>
|
|
209
|
+
</table>
|
|
210
|
+
|
|
211
|
+
### SitemapVideo
|
|
212
|
+
|
|
213
|
+
<table>
|
|
214
|
+
<thead>
|
|
215
|
+
<tr>
|
|
216
|
+
<th>Property</th>
|
|
217
|
+
<th>Type</th>
|
|
218
|
+
<th>Description</th>
|
|
219
|
+
</tr>
|
|
220
|
+
</thead>
|
|
221
|
+
<tbody>
|
|
222
|
+
<tr>
|
|
223
|
+
<td><code>thumbnail_loc</code></td>
|
|
224
|
+
<td>string</td>
|
|
225
|
+
<td><strong>Required.</strong> The absolute URL targeting the source image asset.</td>
|
|
226
|
+
</tr>
|
|
227
|
+
<tr>
|
|
228
|
+
<td><code>title</code></td>
|
|
229
|
+
<td>string</td>
|
|
230
|
+
<td><strong>Required.</strong> The descriptive headline of the video asset. Escaped.</td>
|
|
231
|
+
</tr>
|
|
232
|
+
<tr>
|
|
233
|
+
<td><code>description</code></td>
|
|
234
|
+
<td>string</td>
|
|
235
|
+
<td><strong>Required.</strong> Summary text representing the video topic. Max 2048 chars.</td>
|
|
236
|
+
</tr>
|
|
237
|
+
<tr>
|
|
238
|
+
<td><code>publication_date</code></td>
|
|
239
|
+
<td>Date | string</td>
|
|
240
|
+
<td><strong>Required.</strong> Publication date object or raw formatted ISO string.</td>
|
|
241
|
+
</tr>
|
|
242
|
+
<tr>
|
|
243
|
+
<td><code>content_loc</code></td>
|
|
244
|
+
<td>string</td>
|
|
245
|
+
<td>Optional absolute URL targeting the raw video media stream container.</td>
|
|
246
|
+
</tr>
|
|
247
|
+
<tr>
|
|
248
|
+
<td><code>player_loc</code></td>
|
|
249
|
+
<td>string</td>
|
|
250
|
+
<td>Optional absolute URL linking out to an embeddable video player frame.</td>
|
|
251
|
+
</tr>
|
|
252
|
+
<tr>
|
|
253
|
+
<td><code>duration</code></td>
|
|
254
|
+
<td>number</td>
|
|
255
|
+
<td>Optional length in seconds. Must be an integer bounded between 0 and 28800.</td>
|
|
256
|
+
</tr>
|
|
257
|
+
<tr>
|
|
258
|
+
<td><code>view_count</code></td>
|
|
259
|
+
<td>number</td>
|
|
260
|
+
<td>Optional overall hit counter. Negative values strictly prohibited.</td>
|
|
261
|
+
</tr>
|
|
262
|
+
<tr>
|
|
263
|
+
<td><code>live</code></td>
|
|
264
|
+
<td>'yes' | 'no'</td>
|
|
265
|
+
<td>Optional switch triggering immediate Google SERP LIVE badges.</td>
|
|
266
|
+
</tr>
|
|
267
|
+
</tbody>
|
|
268
|
+
</table>
|
|
269
|
+
|
|
270
|
+
## Technical Implementation
|
|
271
|
+
|
|
272
|
+
### Strict Video Statistical Enforcement (v1.1.3)
|
|
273
|
+
Google's ingestion schema specifies rigid rules for video engagement parameters. Providing decimals or numbers outside structural limits can invalidate the entire sitemap file inside the Google Search Console.
|
|
274
|
+
|
|
275
|
+
- **Range Locking**: The generator enforces that any provided `duration` fits within a strict `0` to `28,800` seconds bracket (up to 8 hours). Breaking this threshold or inputting negative values immediately throws an descriptive runtime exception.
|
|
276
|
+
|
|
277
|
+
- **Decimal Truncation**: Both `duration` and `view_count` properties undergo automated conversion into integers using deterministic mathematical grounding (`Math.floor`). This allows systems to relay float-heavy numbers straight from analytics stores safely.
|
|
278
|
+
|
|
279
|
+
### Image Accessibility & E-commerce Protection
|
|
280
|
+
Large e-commerce platform backends or multi-vendor platforms frequently inject messy string data from user-generated fields—such as alternative text filled with raw spaces (`" "`) or unescaped description metadata containing special HTML entities (`&`, `<`, `>`). To achieve strict alignment with Googlebot accessibility schemas without risking layout parsing crashes, the engine implements a two-tier architectural protective filter in **v1.1.2**:
|
|
281
|
+
|
|
282
|
+
1. **White Space Drop**: Every title, caption, and geographical entry is preventively processed using white-space reduction pipelines. Empty strings or lines composed only of white spaces are automatically stripped to avoid rendering dead, invalid `<image:title></image:title>` tokens.
|
|
283
|
+
|
|
284
|
+
2. **Deep Meta-Escaping**: Extends the core encoding matrix down to visual metadata blocks. This ensures massive production payloads safely render special symbols without altering the global XML stream layout tree.
|
|
285
|
+
|
|
286
|
+
### Priority Auto-Sorting
|
|
287
|
+
Search engine crawlers allocate a finite scanning resource quota (crawl budget) when inspecting domain properties. By default, raw database queries or collection iterations generate un-ordered XML lists, causing indexers to process trivial nodes ahead of strategic content. When `sortByPriority` is enabled, the generation engine executes an immutable descending sorting operation. Unlabeled entries smoothly receive an RFC-compliant fallback baseline score of `0.5`, allowing top-tier entries to line up at the absolute top of the index file.
|
|
288
|
+
|
|
289
|
+
### Auto-Trimming & Ingestion Sanitization
|
|
290
|
+
|
|
291
|
+
Distributed content pipelines frequently face issues with accidental leading spaces, trailing newlines, or indentation remnants introduced via headless CMS panels or Markdown document updates. To protect against application deployment errors caused by these invisible characters, the pipeline incorporates an automatic `.trim()` sanitization step. This layer cleans all input strings—including primary entries, alternative nodes, image endpoints, and video references—and passes the cleaned string directly down to the structural validation layer and the output XML stream.
|
|
292
|
+
|
|
293
|
+
### Native Date Polymorphism
|
|
294
|
+
|
|
295
|
+
To simplify integrations with database mappers and modern ORMs (like Prisma, Supabase, or Mongoose) that output raw timestamps, the compiler implements native date polymorphism. Media structures (`SitemapNews` and `SitemapVideo`) accept both standard string layouts and full JavaScript `Date` instances. The internal pipeline evaluates instances using the `instanceof Date` boundary condition and automatically fires the `.toISOString()` handler when a native object is discovered, removing boilerplate conversion overhead.
|
|
296
|
+
|
|
297
|
+
### Compile-Time Parameter Guarding
|
|
298
|
+
|
|
299
|
+
To avoid syntax typos breaking standard crawler schemas (e.g. accidentally writing `"dayly"` instead of `"daily"`), the library replaces generic primitive types with rigid evaluation layers:
|
|
300
|
+
|
|
301
|
+
* **SitemapChangeFreq**: A literal string union restricting data ingestion exclusively to authorized keywords (`'always'` | `'hourly'` | `'daily'` | `'weekly'` | `'monthly'` | `'yearly'` | `'never'`).
|
|
302
|
+
|
|
303
|
+
* **SitemapPriority**: A custom intersection schema offering direct autocomplete properties across decimal steps from `0.0` to `1.0` within modern code editors while retaining flexibility for precise custom float variables.
|
|
304
|
+
|
|
305
|
+
### Validation & Safety
|
|
306
|
+
|
|
307
|
+
The library executes deterministic validation layers on all URL inputs:
|
|
308
|
+
|
|
309
|
+
1. **Protocol Match**: Enforces that all strings begin strictly with an absolute `http://` or `https://` prefix.
|
|
310
|
+
|
|
311
|
+
2. **Whitespace Interception**: Instantly isolates and rejects strings containing unencoded internal spaces.
|
|
312
|
+
|
|
313
|
+
3. **Structural Compliance**: Leverages the native `URL.canParse`() API (with a clean fallback mechanism to the `new URL()` constructor) to validate layout health.
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
### Advanced XML Security
|
|
317
|
+
|
|
318
|
+
The engine includes an enhanced encoding processor. It automatically detects and escapes special characters within titles, descriptions, and captions to prevent XML layout corruption (e.g., `&` becomes `&`, `<` becomes `<`).
|
|
319
|
+
|
|
320
|
+
### Performance
|
|
321
|
+
|
|
322
|
+
This library relies on an optimized string-building pattern to ensure minimal execution memory footprints, even when parsing deep multi-resource structures with thousands of entries.
|
|
323
|
+
|
|
324
|
+
## License
|
|
325
|
+
|
|
326
|
+
This project is licensed under the [FomaDev Public License (FPL)](LICENSE).
|
|
327
|
+
|
|
328
|
+
* **Free Use**: Authorized for personal and commercial projects as a dependency.
|
|
329
|
+
|
|
330
|
+
* **[Contributions](CONTRIBUTING.md)**: Authorized via Pull Requests to the official repository only.
|
|
331
|
+
|
|
332
|
+
* **Restrictions**: Independent forks, redistribution of source code, or building competing products based on this engine require a paid commercial license.
|
|
333
|
+
|
|
219
334
|
See the [LICENSE](LICENSE) file for the full legal text.
|
package/dist/index.cjs
CHANGED
|
@@ -135,12 +135,16 @@ function generateXml(entries, options = {}) {
|
|
|
135
135
|
`;
|
|
136
136
|
xml += ` <image:loc>${escapeXml(cleanImgUrl)}</image:loc>
|
|
137
137
|
`;
|
|
138
|
-
if (img.title
|
|
138
|
+
if (img.title && img.title.trim() !== "") {
|
|
139
|
+
xml += ` <image:title>${escapeXml(img.title.trim())}</image:title>
|
|
139
140
|
`;
|
|
140
|
-
|
|
141
|
+
}
|
|
142
|
+
if (img.caption && img.caption.trim() !== "") {
|
|
143
|
+
xml += ` <image:caption>${escapeXml(img.caption.trim())}</image:caption>
|
|
141
144
|
`;
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
}
|
|
146
|
+
if (img.geo_location && img.geo_location.trim() !== "") {
|
|
147
|
+
xml += ` <image:geo_location>${escapeXml(img.geo_location.trim())}</image:geo_location>
|
|
144
148
|
`;
|
|
145
149
|
}
|
|
146
150
|
if (img.license) {
|
|
@@ -172,6 +176,26 @@ function generateXml(entries, options = {}) {
|
|
|
172
176
|
if (vid.publication_date) {
|
|
173
177
|
const vDate = vid.publication_date instanceof Date ? vid.publication_date.toISOString() : vid.publication_date;
|
|
174
178
|
xml += ` <video:publication_date>${vDate}</video:publication_date>
|
|
179
|
+
`;
|
|
180
|
+
}
|
|
181
|
+
if (vid.duration !== void 0) {
|
|
182
|
+
const finalDuration = Math.floor(vid.duration);
|
|
183
|
+
if (finalDuration < 0 || finalDuration > 28800) {
|
|
184
|
+
throw new Error(
|
|
185
|
+
`[next-advanced-sitemap] Invalid video duration: ${finalDuration}. Duration must be an integer between 0 and 28800 seconds (8 hours).`
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
xml += ` <video:duration>${finalDuration}</video:duration>
|
|
189
|
+
`;
|
|
190
|
+
}
|
|
191
|
+
if (vid.view_count !== void 0) {
|
|
192
|
+
const finalViewCount = Math.floor(vid.view_count);
|
|
193
|
+
if (finalViewCount < 0) {
|
|
194
|
+
throw new Error(
|
|
195
|
+
`[next-advanced-sitemap] Invalid video view_count: ${finalViewCount}. View count cannot be negative.`
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
xml += ` <video:view_count>${finalViewCount}</video:view_count>
|
|
175
199
|
`;
|
|
176
200
|
}
|
|
177
201
|
if (vid.live) {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/utils/xml-escape.ts","../src/core/generator.ts"],"sourcesContent":["/* * Copyright (c) 2026 Fordi / FomaDev. \r\n * Licensed under FomaDev Public License.\r\n * See LICENSE file in the project root for full license information.\r\n */\r\n\r\nimport { SitemapEntry, SitemapOptions } from './types/sitemap.js';\r\nimport { generateXml } from './core/generator.js';\r\n\r\nexport * from './types/sitemap.js';\r\n\r\n/**\r\n * Génère une réponse HTTP compatible Next.js (App Router) avec options de configuration.\r\n * v1.0.9 : Injection dynamique et personnalisable de l'en-tête Cache-Control via l'option maxAge\r\n * * @param entries - Liste des entrées du sitemap\r\n * @param options - Options de génération et de mise en cache (ex: autoLastmod, maxAge)\r\n * @returns Une instance de Response contenant le flux XML configuré\r\n */\r\nexport function getServerSitemapResponse(\r\n entries: SitemapEntry[], \r\n options: SitemapOptions = {}\r\n): Response {\r\n const xml = generateXml(entries, options);\r\n\r\n // Détermination de la stratégie de mise en cache (v1.0.9)\r\n const cacheControlHeader = options.maxAge !== undefined\r\n ? `public, max-age=${options.maxAge}, must-revalidate`\r\n : 'public, s-maxage=86400, stale-while-revalidate';\r\n\r\n return new Response(xml, {\r\n headers: {\r\n 'Content-Type': 'application/xml',\r\n 'Cache-Control': cacheControlHeader,\r\n },\r\n });\r\n}","/* * Copyright (c) 2026 Fordi / FomaDev. \r\n * Licensed under FomaDev Public License.\r\n * See LICENSE file in the project root for full license information.\r\n */\r\n\r\n/**\r\n * Convertit les caractères spéciaux en entités XML pour éviter la corruption du fichier.\r\n * Gère : <, >, &, \", '\r\n */\r\nexport function escapeXml(unsafe: string | undefined | null): string {\r\n if (!unsafe) return '';\r\n \r\n return unsafe.replace(/[<>&\"']/g, (c) => {\r\n switch (c) {\r\n case '<': return '<';\r\n case '>': return '>';\r\n case '&': return '&';\r\n case '\"': return '"';\r\n case \"'\": return ''';\r\n default: return c;\r\n }\r\n });\r\n}","/* * Copyright (c) 2026 Fordi / FomaDev. \r\n * Licensed under FomaDev Public License.\r\n * See LICENSE file in the project root for full license information.\r\n */\r\n\r\nimport { SitemapEntry, SitemapOptions } from '../types/sitemap.js';\r\nimport { escapeXml } from '../utils/xml-escape.js';\r\n\r\n/**\r\n * Nettoie et valide de manière stricte le format et la structure d'une URL.\r\n * v1.0.7 : Intégration de l'Auto-Trimming (nettoyage des espaces de début et de fin)\r\n */\r\nfunction sanitizeAndValidateUrl(rawUrl: string, context: string): string {\r\n const url = rawUrl ? rawUrl.trim() : '';\r\n\r\n if (!url.startsWith('http://') && !url.startsWith('https://')) {\r\n throw new Error(\r\n `[next-advanced-sitemap] Invalid URL in ${context}: \"${url}\". URLs must start with http:// or https://`\r\n );\r\n }\r\n\r\n if (url.includes(' ')) {\r\n throw new Error(\r\n `[next-advanced-sitemap] Malformed URL structure detected in ${context}: \"${url}\". Please verify spaces or special characters.`\r\n );\r\n }\r\n\r\n let isValid = false;\r\n if (typeof URL.canParse === 'function') {\r\n isValid = URL.canParse(url);\r\n } else {\r\n try {\r\n new URL(url);\r\n isValid = true;\r\n } catch {\r\n isValid = false;\r\n }\r\n }\r\n\r\n if (!isValid) {\r\n throw new Error(\r\n `[next-advanced-sitemap] Malformed URL structure detected in ${context}: \"${url}\". Please verify spaces or special characters.`\r\n );\r\n }\r\n\r\n return url;\r\n}\r\n\r\n/**\r\n * Génère le flux XML complet du sitemap incluant les extensions Images, Vidéos, News et Hreflang.\r\n * v1.1.0 : Prise en charge des attributs étendus <image:geo_location> et <image:license>\r\n */\r\nexport function generateXml(entries: SitemapEntry[], options: SitemapOptions = {}): string {\r\n const now = new Date().toISOString();\r\n let finalEntries = [...entries];\r\n\r\n if (options.sortByPriority) {\r\n finalEntries.sort((a, b) => {\r\n const priorityA = a.priority !== undefined ? (a.priority as number) : 0.5;\r\n const priorityB = b.priority !== undefined ? (b.priority as number) : 0.5;\r\n return priorityB - priorityA;\r\n });\r\n }\r\n \r\n let xml = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n`;\r\n xml += `<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\\n`;\r\n xml += ` xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"\\n`;\r\n xml += ` xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\"\\n`;\r\n xml += ` xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\"\\n`;\r\n xml += ` xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\\n`;\r\n\r\n for (const entry of finalEntries) {\r\n const cleanMainUrl = sanitizeAndValidateUrl(entry.url, 'main entry');\r\n\r\n xml += ` <url>\\n`;\r\n xml += ` <loc>${escapeXml(cleanMainUrl)}</loc>\\n`;\r\n\r\n if (entry.alternates?.length) {\r\n for (const alt of entry.alternates) {\r\n const cleanAltUrl = sanitizeAndValidateUrl(alt.href, 'alternate link');\r\n xml += ` <xhtml:link rel=\"alternate\" hreflang=\"${escapeXml(alt.hreflang)}\" href=\"${escapeXml(cleanAltUrl)}\" />\\n`;\r\n }\r\n }\r\n\r\n let lastmodValue = entry.lastmod;\r\n if (options.autoLastmod && !lastmodValue) {\r\n lastmodValue = now;\r\n }\r\n\r\n if (lastmodValue) {\r\n const date = lastmodValue instanceof Date ? lastmodValue.toISOString() : lastmodValue;\r\n xml += ` <lastmod>${date}</lastmod>\\n`;\r\n }\r\n\r\n if (entry.changefreq) {\r\n xml += ` <changefreq>${entry.changefreq}</changefreq>\\n`;\r\n }\r\n\r\n if (entry.priority !== undefined) {\r\n xml += ` <priority>${(entry.priority as number).toFixed(1)}</priority>\\n`;\r\n }\r\n\r\n // Extension Images - enrichie en v1.1.0\r\n if (entry.images?.length) {\r\n for (const img of entry.images) {\r\n const cleanImgUrl = sanitizeAndValidateUrl(img.loc, 'image location');\r\n \r\n xml += ` <image:image>\\n`;\r\n xml += ` <image:loc>${escapeXml(cleanImgUrl)}</image:loc>\\n`;\r\n if (img.title) xml += ` <image:title>${escapeXml(img.title)}</image:title>\\n`;\r\n if (img.caption) xml += ` <image:caption>${escapeXml(img.caption)}</image:caption>\\n`;\r\n \r\n // SEO Local v1.1.0\r\n if (img.geo_location) {\r\n xml += ` <image:geo_location>${escapeXml(img.geo_location)}</image:geo_location>\\n`;\r\n }\r\n \r\n // Gestion des Licences Google Images v1.1.0\r\n if (img.license) {\r\n const cleanLicenseUrl = sanitizeAndValidateUrl(img.license, 'image license URL');\r\n xml += ` <image:license>${escapeXml(cleanLicenseUrl)}</image:license>\\n`;\r\n }\r\n \r\n xml += ` </image:image>\\n`;\r\n }\r\n }\r\n\r\n // Extension Vidéos\r\n if (entry.videos?.length) {\r\n for (const vid of entry.videos) {\r\n const cleanThumbLoc = sanitizeAndValidateUrl(vid.thumbnail_loc, 'video thumbnail');\r\n const cleanContentLoc = vid.content_loc ? sanitizeAndValidateUrl(vid.content_loc, 'video content location') : undefined;\r\n const cleanPlayerLoc = vid.player_loc ? sanitizeAndValidateUrl(vid.player_loc, 'video player location') : undefined;\r\n\r\n xml += ` <video:video>\\n`;\r\n xml += ` <video:thumbnail_loc>${escapeXml(cleanThumbLoc)}</video:thumbnail_loc>\\n`;\r\n xml += ` <video:title>${escapeXml(vid.title)}</video:title>\\n`;\r\n xml += ` <video:description>${escapeXml(vid.description)}</video:description>\\n`;\r\n \r\n if (cleanContentLoc) xml += ` <video:content_loc>${escapeXml(cleanContentLoc)}</video:content_loc>\\n`;\r\n if (cleanPlayerLoc) xml += ` <video:player_loc>${escapeXml(cleanPlayerLoc)}</video:player_loc>\\n`;\r\n \r\n if (vid.publication_date) {\r\n const vDate = vid.publication_date instanceof Date ? vid.publication_date.toISOString() : vid.publication_date;\r\n xml += ` <video:publication_date>${vDate}</video:publication_date>\\n`;\r\n }\r\n\r\n // Support du Live Streaming v1.1.1\r\n if (vid.live) {\r\n xml += ` <video:live>${vid.live}</video:live>\\n`;\r\n }\r\n\r\n xml += ` </video:video>\\n`;\r\n }\r\n }\r\n\r\n // Extension News\r\n if (entry.news) {\r\n const nDate = entry.news.publication_date instanceof Date ? entry.news.publication_date.toISOString() : entry.news.publication_date;\r\n xml += ` <news:news>\\n`;\r\n xml += ` <news:publication>\\n`;\r\n xml += ` <news:name>${escapeXml(entry.news.name)}</news:name>\\n`;\r\n xml += ` <news:language>${escapeXml(entry.news.language)}</news:language>\\n`;\r\n xml += ` </news:publication>\\n`;\r\n xml += ` <news:publication_date>${nDate}</news:publication_date>\\n`;\r\n xml += ` <news:title>${escapeXml(entry.news.title)}</news:title>\\n`;\r\n xml += ` </news:news>\\n`;\r\n }\r\n\r\n xml += ` </url>\\n`;\r\n }\r\n\r\n xml += `</urlset>`;\r\n return xml;\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACSO,SAAS,UAAU,QAA2C;AACnE,MAAI,CAAC,OAA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,aAAO,0BAA0B,UAAU,MAAM,KAAK,QAAQ,CAAC;AAAA;AAC/D,aAAO;AAAA;AACP,aAAO,gCAAgC,KAAK;AAAA;AAC5C,aAAO,qBAAqB,UAAU,MAAM,KAAK,KAAK,CAAC;AAAA;AACvD,aAAO;AAAA;AAAA,IACT;AAEA,WAAO;AAAA;AAAA,EACT;AAEA,SAAO;AACP,SAAO;AACT;;;AF7JO,SAAS,yBACd,SACA,UAA0B,CAAC,GACjB;AACV,QAAM,MAAM,YAAY,SAAS,OAAO;AAGxC,QAAM,qBAAqB,QAAQ,WAAW,SAC1C,mBAAmB,QAAQ,MAAM,sBACjC;AAEJ,SAAO,IAAI,SAAS,KAAK;AAAA,IACvB,SAAS;AAAA,MACP,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,IACnB;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/xml-escape.ts","../src/core/generator.ts"],"sourcesContent":["/* * Copyright (c) 2026 Fordi / FomaDev. \n * Licensed under FomaDev Public License.\n * See LICENSE file in the project root for full license information.\n */\n\nimport { SitemapEntry, SitemapOptions } from './types/sitemap.js';\nimport { generateXml } from './core/generator.js';\n\nexport * from './types/sitemap.js';\n\n/**\n * Génère une réponse HTTP compatible Next.js (App Router) avec options de configuration.\n * v1.0.9 : Injection dynamique et personnalisable de l'en-tête Cache-Control via l'option maxAge\n * * @param entries - Liste des entrées du sitemap\n * @param options - Options de génération et de mise en cache (ex: autoLastmod, maxAge)\n * @returns Une instance de Response contenant le flux XML configuré\n */\nexport function getServerSitemapResponse(\n entries: SitemapEntry[], \n options: SitemapOptions = {}\n): Response {\n const xml = generateXml(entries, options);\n\n // Détermination de la stratégie de mise en cache (v1.0.9)\n const cacheControlHeader = options.maxAge !== undefined\n ? `public, max-age=${options.maxAge}, must-revalidate`\n : 'public, s-maxage=86400, stale-while-revalidate';\n\n return new Response(xml, {\n headers: {\n 'Content-Type': 'application/xml',\n 'Cache-Control': cacheControlHeader,\n },\n });\n}","/* * Copyright (c) 2026 Fordi / FomaDev. \n * Licensed under FomaDev Public License.\n * See LICENSE file in the project root for full license information.\n */\n\n/**\n * Convertit les caractères spéciaux en entités XML pour éviter la corruption du fichier.\n * Gère : <, >, &, \", '\n */\nexport function escapeXml(unsafe: string | undefined | null): string {\n if (!unsafe) return '';\n \n return unsafe.replace(/[<>&\"']/g, (c) => {\n switch (c) {\n case '<': return '<';\n case '>': return '>';\n case '&': return '&';\n case '\"': return '"';\n case \"'\": return ''';\n default: return c;\n }\n });\n}","/* * Copyright (c) 2026 Fordi / FomaDev. \n * Licensed under FomaDev Public License.\n * See LICENSE file in the project root for full license information.\n */\n\nimport { SitemapEntry, SitemapOptions } from '../types/sitemap.js';\nimport { escapeXml } from '../utils/xml-escape.js';\n\n/**\n * Nettoie et valide de manière stricte le format et la structure d'une URL.\n * v1.0.7 : Intégration de l'Auto-Trimming (nettoyage des espaces de début et de fin)\n */\nfunction sanitizeAndValidateUrl(rawUrl: string, context: string): string {\n const url = rawUrl ? rawUrl.trim() : '';\n\n if (!url.startsWith('http://') && !url.startsWith('https://')) {\n throw new Error(\n `[next-advanced-sitemap] Invalid URL in ${context}: \"${url}\". URLs must start with http:// or https://`\n );\n }\n\n if (url.includes(' ')) {\n throw new Error(\n `[next-advanced-sitemap] Malformed URL structure detected in ${context}: \"${url}\". Please verify spaces or special characters.`\n );\n }\n\n let isValid = false;\n if (typeof URL.canParse === 'function') {\n isValid = URL.canParse(url);\n } else {\n try {\n new URL(url);\n isValid = true;\n } catch {\n isValid = false;\n }\n }\n\n if (!isValid) {\n throw new Error(\n `[next-advanced-sitemap] Malformed URL structure detected in ${context}: \"${url}\". Please verify spaces or special characters.`\n );\n }\n\n return url;\n}\n\n/**\n * Génère le flux XML complet du sitemap incluant les extensions Images, Vidéos, News et Hreflang.\n * v1.1.3 : Validation stricte des statistiques vidéo (duration entre 0-28800s & view_count >= 0)\n */\nexport function generateXml(entries: SitemapEntry[], options: SitemapOptions = {}): string {\n const now = new Date().toISOString();\n let finalEntries = [...entries];\n\n if (options.sortByPriority) {\n finalEntries.sort((a, b) => {\n const priorityA = a.priority !== undefined ? (a.priority as number) : 0.5;\n const priorityB = b.priority !== undefined ? (b.priority as number) : 0.5;\n return priorityB - priorityA;\n });\n }\n \n let xml = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n`;\n xml += `<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\\n`;\n xml += ` xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"\\n`;\n xml += ` xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\"\\n`;\n xml += ` xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\"\\n`;\n xml += ` xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\\n`;\n\n for (const entry of finalEntries) {\n const cleanMainUrl = sanitizeAndValidateUrl(entry.url, 'main entry');\n\n xml += ` <url>\\n`;\n xml += ` <loc>${escapeXml(cleanMainUrl)}</loc>\\n`;\n\n if (entry.alternates?.length) {\n for (const alt of entry.alternates) {\n const cleanAltUrl = sanitizeAndValidateUrl(alt.href, 'alternate link');\n xml += ` <xhtml:link rel=\"alternate\" hreflang=\"${escapeXml(alt.hreflang)}\" href=\"${escapeXml(cleanAltUrl)}\" />\\n`;\n }\n }\n\n let lastmodValue = entry.lastmod;\n if (options.autoLastmod && !lastmodValue) {\n lastmodValue = now;\n }\n\n if (lastmodValue) {\n const date = lastmodValue instanceof Date ? lastmodValue.toISOString() : lastmodValue;\n xml += ` <lastmod>${date}</lastmod>\\n`;\n }\n\n if (entry.changefreq) {\n xml += ` <changefreq>${entry.changefreq}</changefreq>\\n`;\n }\n\n if (entry.priority !== undefined) {\n xml += ` <priority>${(entry.priority as number).toFixed(1)}</priority>\\n`;\n }\n\n // Extension Images\n if (entry.images?.length) {\n for (const img of entry.images) {\n const cleanImgUrl = sanitizeAndValidateUrl(img.loc, 'image location');\n \n xml += ` <image:image>\\n`;\n xml += ` <image:loc>${escapeXml(cleanImgUrl)}</image:loc>\\n`;\n \n if (img.title && img.title.trim() !== '') {\n xml += ` <image:title>${escapeXml(img.title.trim())}</image:title>\\n`;\n }\n if (img.caption && img.caption.trim() !== '') {\n xml += ` <image:caption>${escapeXml(img.caption.trim())}</image:caption>\\n`;\n }\n \n if (img.geo_location && img.geo_location.trim() !== '') {\n xml += ` <image:geo_location>${escapeXml(img.geo_location.trim())}</image:geo_location>\\n`;\n }\n \n if (img.license) {\n const cleanLicenseUrl = sanitizeAndValidateUrl(img.license, 'image license URL');\n xml += ` <image:license>${escapeXml(cleanLicenseUrl)}</image:license>\\n`;\n }\n \n xml += ` </image:image>\\n`;\n }\n }\n\n // Extension Vidéos - v1.1.3 sécurisée\n if (entry.videos?.length) {\n for (const vid of entry.videos) {\n const cleanThumbLoc = sanitizeAndValidateUrl(vid.thumbnail_loc, 'video thumbnail');\n const cleanContentLoc = vid.content_loc ? sanitizeAndValidateUrl(vid.content_loc, 'video content location') : undefined;\n const cleanPlayerLoc = vid.player_loc ? sanitizeAndValidateUrl(vid.player_loc, 'video player location') : undefined;\n\n xml += ` <video:video>\\n`;\n xml += ` <video:thumbnail_loc>${escapeXml(cleanThumbLoc)}</video:thumbnail_loc>\\n`;\n xml += ` <video:title>${escapeXml(vid.title)}</video:title>\\n`;\n xml += ` <video:description>${escapeXml(vid.description)}</video:description>\\n`;\n \n if (cleanContentLoc) xml += ` <video:content_loc>${escapeXml(cleanContentLoc)}</video:content_loc>\\n`;\n if (cleanPlayerLoc) xml += ` <video:player_loc>${escapeXml(cleanPlayerLoc)}</video:player_loc>\\n`;\n \n if (vid.publication_date) {\n const vDate = vid.publication_date instanceof Date ? vid.publication_date.toISOString() : vid.publication_date;\n xml += ` <video:publication_date>${vDate}</video:publication_date>\\n`;\n }\n\n // ✨ Validation et Sérialisation de la durée (0 - 28800s)\n if (vid.duration !== undefined) {\n const finalDuration = Math.floor(vid.duration);\n if (finalDuration < 0 || finalDuration > 28800) {\n throw new Error(\n `[next-advanced-sitemap] Invalid video duration: ${finalDuration}. Duration must be an integer between 0 and 28800 seconds (8 hours).`\n );\n }\n xml += ` <video:duration>${finalDuration}</video:duration>\\n`;\n }\n\n // ✨ Validation et Sérialisation du nombre de vues (>= 0)\n if (vid.view_count !== undefined) {\n const finalViewCount = Math.floor(vid.view_count);\n if (finalViewCount < 0) {\n throw new Error(\n `[next-advanced-sitemap] Invalid video view_count: ${finalViewCount}. View count cannot be negative.`\n );\n }\n xml += ` <video:view_count>${finalViewCount}</video:view_count>\\n`;\n }\n\n if (vid.live) {\n xml += ` <video:live>${vid.live}</video:live>\\n`;\n }\n\n xml += ` </video:video>\\n`;\n }\n }\n\n // Extension News\n if (entry.news) {\n const nDate = entry.news.publication_date instanceof Date ? entry.news.publication_date.toISOString() : entry.news.publication_date;\n xml += ` <news:news>\\n`;\n xml += ` <news:publication>\\n`;\n xml += ` <news:name>${escapeXml(entry.news.name)}</news:name>\\n`;\n xml += ` <news:language>${escapeXml(entry.news.language)}</news:language>\\n`;\n xml += ` </news:publication>\\n`;\n xml += ` <news:publication_date>${nDate}</news:publication_date>\\n`;\n xml += ` <news:title>${escapeXml(entry.news.title)}</news:title>\\n`;\n xml += ` </news:news>\\n`;\n }\n\n xml += ` </url>\\n`;\n }\n\n xml += `</urlset>`;\n return xml;\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACSO,SAAS,UAAU,QAA2C;AACnE,MAAI,CAAC,OAAQ,QAAO;AAEpB,SAAO,OAAO,QAAQ,YAAY,CAAC,MAAM;AACvC,YAAQ,GAAG;AAAA,MACT,KAAK;AAAK,eAAO;AAAA,MACjB,KAAK;AAAK,eAAO;AAAA,MACjB,KAAK;AAAK,eAAO;AAAA,MACjB,KAAK;AAAK,eAAO;AAAA,MACjB,KAAK;AAAK,eAAO;AAAA,MACjB;AAAS,eAAO;AAAA,IAClB;AAAA,EACF,CAAC;AACH;;;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;AAAA,QAClD;AAEA,YAAI,IAAI,MAAM;AACZ,iBAAO,qBAAqB,IAAI,IAAI;AAAA;AAAA,QACtC;AAEA,eAAO;AAAA;AAAA,MACT;AAAA,IACF;AAGA,QAAI,MAAM,MAAM;AACd,YAAM,QAAQ,MAAM,KAAK,4BAA4B,OAAO,MAAM,KAAK,iBAAiB,YAAY,IAAI,MAAM,KAAK;AACnH,aAAO;AAAA;AACP,aAAO;AAAA;AACP,aAAO,sBAAsB,UAAU,MAAM,KAAK,IAAI,CAAC;AAAA;AACvD,aAAO,0BAA0B,UAAU,MAAM,KAAK,QAAQ,CAAC;AAAA;AAC/D,aAAO;AAAA;AACP,aAAO,gCAAgC,KAAK;AAAA;AAC5C,aAAO,qBAAqB,UAAU,MAAM,KAAK,KAAK,CAAC;AAAA;AACvD,aAAO;AAAA;AAAA,IACT;AAEA,WAAO;AAAA;AAAA,EACT;AAEA,SAAO;AACP,SAAO;AACT;;;AFrLO,SAAS,yBACd,SACA,UAA0B,CAAC,GACjB;AACV,QAAM,MAAM,YAAY,SAAS,OAAO;AAGxC,QAAM,qBAAqB,QAAQ,WAAW,SAC1C,mBAAmB,QAAQ,MAAM,sBACjC;AAEJ,SAAO,IAAI,SAAS,KAAK;AAAA,IACvB,SAAS;AAAA,MACP,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,IACnB;AAAA,EACF,CAAC;AACH;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -39,12 +39,19 @@ interface SitemapVideo {
|
|
|
39
39
|
description: string;
|
|
40
40
|
content_loc?: string;
|
|
41
41
|
player_loc?: string;
|
|
42
|
-
duration?: number;
|
|
43
|
-
view_count?: number;
|
|
44
42
|
publication_date?: Date | string;
|
|
45
43
|
family_friendly?: 'yes' | 'no';
|
|
46
44
|
/** (Optional) v1.1.1: Indique si la vidéo est une diffusion en direct ('yes' ou 'no'). */
|
|
47
45
|
live?: 'yes' | 'no';
|
|
46
|
+
/**
|
|
47
|
+
* (Optional) La durée de la vidéo en secondes.
|
|
48
|
+
* Doit être un entier compris entre 0 et 28800 (8 heures).
|
|
49
|
+
*/
|
|
50
|
+
duration?: number;
|
|
51
|
+
/**
|
|
52
|
+
* (Optional) Le nombre de vues de la vidéo.
|
|
53
|
+
*/
|
|
54
|
+
view_count?: number;
|
|
48
55
|
}
|
|
49
56
|
/**
|
|
50
57
|
* Interface pour Google News
|
package/dist/index.d.ts
CHANGED
|
@@ -39,12 +39,19 @@ interface SitemapVideo {
|
|
|
39
39
|
description: string;
|
|
40
40
|
content_loc?: string;
|
|
41
41
|
player_loc?: string;
|
|
42
|
-
duration?: number;
|
|
43
|
-
view_count?: number;
|
|
44
42
|
publication_date?: Date | string;
|
|
45
43
|
family_friendly?: 'yes' | 'no';
|
|
46
44
|
/** (Optional) v1.1.1: Indique si la vidéo est une diffusion en direct ('yes' ou 'no'). */
|
|
47
45
|
live?: 'yes' | 'no';
|
|
46
|
+
/**
|
|
47
|
+
* (Optional) La durée de la vidéo en secondes.
|
|
48
|
+
* Doit être un entier compris entre 0 et 28800 (8 heures).
|
|
49
|
+
*/
|
|
50
|
+
duration?: number;
|
|
51
|
+
/**
|
|
52
|
+
* (Optional) Le nombre de vues de la vidéo.
|
|
53
|
+
*/
|
|
54
|
+
view_count?: number;
|
|
48
55
|
}
|
|
49
56
|
/**
|
|
50
57
|
* Interface pour Google News
|
package/dist/index.js
CHANGED
|
@@ -109,12 +109,16 @@ function generateXml(entries, options = {}) {
|
|
|
109
109
|
`;
|
|
110
110
|
xml += ` <image:loc>${escapeXml(cleanImgUrl)}</image:loc>
|
|
111
111
|
`;
|
|
112
|
-
if (img.title
|
|
112
|
+
if (img.title && img.title.trim() !== "") {
|
|
113
|
+
xml += ` <image:title>${escapeXml(img.title.trim())}</image:title>
|
|
113
114
|
`;
|
|
114
|
-
|
|
115
|
+
}
|
|
116
|
+
if (img.caption && img.caption.trim() !== "") {
|
|
117
|
+
xml += ` <image:caption>${escapeXml(img.caption.trim())}</image:caption>
|
|
115
118
|
`;
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
}
|
|
120
|
+
if (img.geo_location && img.geo_location.trim() !== "") {
|
|
121
|
+
xml += ` <image:geo_location>${escapeXml(img.geo_location.trim())}</image:geo_location>
|
|
118
122
|
`;
|
|
119
123
|
}
|
|
120
124
|
if (img.license) {
|
|
@@ -146,6 +150,26 @@ function generateXml(entries, options = {}) {
|
|
|
146
150
|
if (vid.publication_date) {
|
|
147
151
|
const vDate = vid.publication_date instanceof Date ? vid.publication_date.toISOString() : vid.publication_date;
|
|
148
152
|
xml += ` <video:publication_date>${vDate}</video:publication_date>
|
|
153
|
+
`;
|
|
154
|
+
}
|
|
155
|
+
if (vid.duration !== void 0) {
|
|
156
|
+
const finalDuration = Math.floor(vid.duration);
|
|
157
|
+
if (finalDuration < 0 || finalDuration > 28800) {
|
|
158
|
+
throw new Error(
|
|
159
|
+
`[next-advanced-sitemap] Invalid video duration: ${finalDuration}. Duration must be an integer between 0 and 28800 seconds (8 hours).`
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
xml += ` <video:duration>${finalDuration}</video:duration>
|
|
163
|
+
`;
|
|
164
|
+
}
|
|
165
|
+
if (vid.view_count !== void 0) {
|
|
166
|
+
const finalViewCount = Math.floor(vid.view_count);
|
|
167
|
+
if (finalViewCount < 0) {
|
|
168
|
+
throw new Error(
|
|
169
|
+
`[next-advanced-sitemap] Invalid video view_count: ${finalViewCount}. View count cannot be negative.`
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
xml += ` <video:view_count>${finalViewCount}</video:view_count>
|
|
149
173
|
`;
|
|
150
174
|
}
|
|
151
175
|
if (vid.live) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/xml-escape.ts","../src/core/generator.ts","../src/index.ts"],"sourcesContent":["/* * Copyright (c) 2026 Fordi / FomaDev. \r\n * Licensed under FomaDev Public License.\r\n * See LICENSE file in the project root for full license information.\r\n */\r\n\r\n/**\r\n * Convertit les caractères spéciaux en entités XML pour éviter la corruption du fichier.\r\n * Gère : <, >, &, \", '\r\n */\r\nexport function escapeXml(unsafe: string | undefined | null): string {\r\n if (!unsafe) return '';\r\n \r\n return unsafe.replace(/[<>&\"']/g, (c) => {\r\n switch (c) {\r\n case '<': return '<';\r\n case '>': return '>';\r\n case '&': return '&';\r\n case '\"': return '"';\r\n case \"'\": return ''';\r\n default: return c;\r\n }\r\n });\r\n}","/* * Copyright (c) 2026 Fordi / FomaDev. \r\n * Licensed under FomaDev Public License.\r\n * See LICENSE file in the project root for full license information.\r\n */\r\n\r\nimport { SitemapEntry, SitemapOptions } from '../types/sitemap.js';\r\nimport { escapeXml } from '../utils/xml-escape.js';\r\n\r\n/**\r\n * Nettoie et valide de manière stricte le format et la structure d'une URL.\r\n * v1.0.7 : Intégration de l'Auto-Trimming (nettoyage des espaces de début et de fin)\r\n */\r\nfunction sanitizeAndValidateUrl(rawUrl: string, context: string): string {\r\n const url = rawUrl ? rawUrl.trim() : '';\r\n\r\n if (!url.startsWith('http://') && !url.startsWith('https://')) {\r\n throw new Error(\r\n `[next-advanced-sitemap] Invalid URL in ${context}: \"${url}\". URLs must start with http:// or https://`\r\n );\r\n }\r\n\r\n if (url.includes(' ')) {\r\n throw new Error(\r\n `[next-advanced-sitemap] Malformed URL structure detected in ${context}: \"${url}\". Please verify spaces or special characters.`\r\n );\r\n }\r\n\r\n let isValid = false;\r\n if (typeof URL.canParse === 'function') {\r\n isValid = URL.canParse(url);\r\n } else {\r\n try {\r\n new URL(url);\r\n isValid = true;\r\n } catch {\r\n isValid = false;\r\n }\r\n }\r\n\r\n if (!isValid) {\r\n throw new Error(\r\n `[next-advanced-sitemap] Malformed URL structure detected in ${context}: \"${url}\". Please verify spaces or special characters.`\r\n );\r\n }\r\n\r\n return url;\r\n}\r\n\r\n/**\r\n * Génère le flux XML complet du sitemap incluant les extensions Images, Vidéos, News et Hreflang.\r\n * v1.1.0 : Prise en charge des attributs étendus <image:geo_location> et <image:license>\r\n */\r\nexport function generateXml(entries: SitemapEntry[], options: SitemapOptions = {}): string {\r\n const now = new Date().toISOString();\r\n let finalEntries = [...entries];\r\n\r\n if (options.sortByPriority) {\r\n finalEntries.sort((a, b) => {\r\n const priorityA = a.priority !== undefined ? (a.priority as number) : 0.5;\r\n const priorityB = b.priority !== undefined ? (b.priority as number) : 0.5;\r\n return priorityB - priorityA;\r\n });\r\n }\r\n \r\n let xml = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n`;\r\n xml += `<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\\n`;\r\n xml += ` xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"\\n`;\r\n xml += ` xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\"\\n`;\r\n xml += ` xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\"\\n`;\r\n xml += ` xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\\n`;\r\n\r\n for (const entry of finalEntries) {\r\n const cleanMainUrl = sanitizeAndValidateUrl(entry.url, 'main entry');\r\n\r\n xml += ` <url>\\n`;\r\n xml += ` <loc>${escapeXml(cleanMainUrl)}</loc>\\n`;\r\n\r\n if (entry.alternates?.length) {\r\n for (const alt of entry.alternates) {\r\n const cleanAltUrl = sanitizeAndValidateUrl(alt.href, 'alternate link');\r\n xml += ` <xhtml:link rel=\"alternate\" hreflang=\"${escapeXml(alt.hreflang)}\" href=\"${escapeXml(cleanAltUrl)}\" />\\n`;\r\n }\r\n }\r\n\r\n let lastmodValue = entry.lastmod;\r\n if (options.autoLastmod && !lastmodValue) {\r\n lastmodValue = now;\r\n }\r\n\r\n if (lastmodValue) {\r\n const date = lastmodValue instanceof Date ? lastmodValue.toISOString() : lastmodValue;\r\n xml += ` <lastmod>${date}</lastmod>\\n`;\r\n }\r\n\r\n if (entry.changefreq) {\r\n xml += ` <changefreq>${entry.changefreq}</changefreq>\\n`;\r\n }\r\n\r\n if (entry.priority !== undefined) {\r\n xml += ` <priority>${(entry.priority as number).toFixed(1)}</priority>\\n`;\r\n }\r\n\r\n // Extension Images - enrichie en v1.1.0\r\n if (entry.images?.length) {\r\n for (const img of entry.images) {\r\n const cleanImgUrl = sanitizeAndValidateUrl(img.loc, 'image location');\r\n \r\n xml += ` <image:image>\\n`;\r\n xml += ` <image:loc>${escapeXml(cleanImgUrl)}</image:loc>\\n`;\r\n if (img.title) xml += ` <image:title>${escapeXml(img.title)}</image:title>\\n`;\r\n if (img.caption) xml += ` <image:caption>${escapeXml(img.caption)}</image:caption>\\n`;\r\n \r\n // SEO Local v1.1.0\r\n if (img.geo_location) {\r\n xml += ` <image:geo_location>${escapeXml(img.geo_location)}</image:geo_location>\\n`;\r\n }\r\n \r\n // Gestion des Licences Google Images v1.1.0\r\n if (img.license) {\r\n const cleanLicenseUrl = sanitizeAndValidateUrl(img.license, 'image license URL');\r\n xml += ` <image:license>${escapeXml(cleanLicenseUrl)}</image:license>\\n`;\r\n }\r\n \r\n xml += ` </image:image>\\n`;\r\n }\r\n }\r\n\r\n // Extension Vidéos\r\n if (entry.videos?.length) {\r\n for (const vid of entry.videos) {\r\n const cleanThumbLoc = sanitizeAndValidateUrl(vid.thumbnail_loc, 'video thumbnail');\r\n const cleanContentLoc = vid.content_loc ? sanitizeAndValidateUrl(vid.content_loc, 'video content location') : undefined;\r\n const cleanPlayerLoc = vid.player_loc ? sanitizeAndValidateUrl(vid.player_loc, 'video player location') : undefined;\r\n\r\n xml += ` <video:video>\\n`;\r\n xml += ` <video:thumbnail_loc>${escapeXml(cleanThumbLoc)}</video:thumbnail_loc>\\n`;\r\n xml += ` <video:title>${escapeXml(vid.title)}</video:title>\\n`;\r\n xml += ` <video:description>${escapeXml(vid.description)}</video:description>\\n`;\r\n \r\n if (cleanContentLoc) xml += ` <video:content_loc>${escapeXml(cleanContentLoc)}</video:content_loc>\\n`;\r\n if (cleanPlayerLoc) xml += ` <video:player_loc>${escapeXml(cleanPlayerLoc)}</video:player_loc>\\n`;\r\n \r\n if (vid.publication_date) {\r\n const vDate = vid.publication_date instanceof Date ? vid.publication_date.toISOString() : vid.publication_date;\r\n xml += ` <video:publication_date>${vDate}</video:publication_date>\\n`;\r\n }\r\n\r\n // Support du Live Streaming v1.1.1\r\n if (vid.live) {\r\n xml += ` <video:live>${vid.live}</video:live>\\n`;\r\n }\r\n\r\n xml += ` </video:video>\\n`;\r\n }\r\n }\r\n\r\n // Extension News\r\n if (entry.news) {\r\n const nDate = entry.news.publication_date instanceof Date ? entry.news.publication_date.toISOString() : entry.news.publication_date;\r\n xml += ` <news:news>\\n`;\r\n xml += ` <news:publication>\\n`;\r\n xml += ` <news:name>${escapeXml(entry.news.name)}</news:name>\\n`;\r\n xml += ` <news:language>${escapeXml(entry.news.language)}</news:language>\\n`;\r\n xml += ` </news:publication>\\n`;\r\n xml += ` <news:publication_date>${nDate}</news:publication_date>\\n`;\r\n xml += ` <news:title>${escapeXml(entry.news.title)}</news:title>\\n`;\r\n xml += ` </news:news>\\n`;\r\n }\r\n\r\n xml += ` </url>\\n`;\r\n }\r\n\r\n xml += `</urlset>`;\r\n return xml;\r\n}","/* * Copyright (c) 2026 Fordi / FomaDev. \r\n * Licensed under FomaDev Public License.\r\n * See LICENSE file in the project root for full license information.\r\n */\r\n\r\nimport { SitemapEntry, SitemapOptions } from './types/sitemap.js';\r\nimport { generateXml } from './core/generator.js';\r\n\r\nexport * from './types/sitemap.js';\r\n\r\n/**\r\n * Génère une réponse HTTP compatible Next.js (App Router) avec options de configuration.\r\n * v1.0.9 : Injection dynamique et personnalisable de l'en-tête Cache-Control via l'option maxAge\r\n * * @param entries - Liste des entrées du sitemap\r\n * @param options - Options de génération et de mise en cache (ex: autoLastmod, maxAge)\r\n * @returns Une instance de Response contenant le flux XML configuré\r\n */\r\nexport function getServerSitemapResponse(\r\n entries: SitemapEntry[], \r\n options: SitemapOptions = {}\r\n): Response {\r\n const xml = generateXml(entries, options);\r\n\r\n // Détermination de la stratégie de mise en cache (v1.0.9)\r\n const cacheControlHeader = options.maxAge !== undefined\r\n ? `public, max-age=${options.maxAge}, must-revalidate`\r\n : 'public, s-maxage=86400, stale-while-revalidate';\r\n\r\n return new Response(xml, {\r\n headers: {\r\n 'Content-Type': 'application/xml',\r\n 'Cache-Control': cacheControlHeader,\r\n },\r\n });\r\n}"],"mappings":";AASO,SAAS,UAAU,QAA2C;AACnE,MAAI,CAAC,OAAQ,QAAO;AAEpB,SAAO,OAAO,QAAQ,YAAY,CAAC,MAAM;AACvC,YAAQ,GAAG;AAAA,MACT,KAAK;AAAK,eAAO;AAAA,MACjB,KAAK;AAAK,eAAO;AAAA,MACjB,KAAK;AAAK,eAAO;AAAA,MACjB,KAAK;AAAK,eAAO;AAAA,MACjB,KAAK;AAAK,eAAO;AAAA,MACjB;AAAS,eAAO;AAAA,IAClB;AAAA,EACF,CAAC;AACH;;;ACVA,SAAS,uBAAuB,QAAgB,SAAyB;AACvE,QAAM,MAAM,SAAS,OAAO,KAAK,IAAI;AAErC,MAAI,CAAC,IAAI,WAAW,SAAS,KAAK,CAAC,IAAI,WAAW,UAAU,GAAG;AAC7D,UAAM,IAAI;AAAA,MACR,0CAA0C,OAAO,MAAM,GAAG;AAAA,IAC5D;AAAA,EACF;AAEA,MAAI,IAAI,SAAS,GAAG,GAAG;AACrB,UAAM,IAAI;AAAA,MACR,+DAA+D,OAAO,MAAM,GAAG;AAAA,IACjF;AAAA,EACF;AAEA,MAAI,UAAU;AACd,MAAI,OAAO,IAAI,aAAa,YAAY;AACtC,cAAU,IAAI,SAAS,GAAG;AAAA,EAC5B,OAAO;AACL,QAAI;AACF,UAAI,IAAI,GAAG;AACX,gBAAU;AAAA,IACZ,QAAQ;AACN,gBAAU;AAAA,IACZ;AAAA,EACF;AAEA,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR,+DAA+D,OAAO,MAAM,GAAG;AAAA,IACjF;AAAA,EACF;AAEA,SAAO;AACT;AAMO,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IAAI,IAAI;AAAA;AAAA,QACtC;AAEA,eAAO;AAAA;AAAA,MACT;AAAA,IACF;AAGA,QAAI,MAAM,MAAM;AACd,YAAM,QAAQ,MAAM,KAAK,4BAA4B,OAAO,MAAM,KAAK,iBAAiB,YAAY,IAAI,MAAM,KAAK;AACnH,aAAO;AAAA;AACP,aAAO;AAAA;AACP,aAAO,sBAAsB,UAAU,MAAM,KAAK,IAAI,CAAC;AAAA;AACvD,aAAO,0BAA0B,UAAU,MAAM,KAAK,QAAQ,CAAC;AAAA;AAC/D,aAAO;AAAA;AACP,aAAO,gCAAgC,KAAK;AAAA;AAC5C,aAAO,qBAAqB,UAAU,MAAM,KAAK,KAAK,CAAC;AAAA;AACvD,aAAO;AAAA;AAAA,IACT;AAEA,WAAO;AAAA;AAAA,EACT;AAEA,SAAO;AACP,SAAO;AACT;;;AC7JO,SAAS,yBACd,SACA,UAA0B,CAAC,GACjB;AACV,QAAM,MAAM,YAAY,SAAS,OAAO;AAGxC,QAAM,qBAAqB,QAAQ,WAAW,SAC1C,mBAAmB,QAAQ,MAAM,sBACjC;AAEJ,SAAO,IAAI,SAAS,KAAK;AAAA,IACvB,SAAS;AAAA,MACP,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,IACnB;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/xml-escape.ts","../src/core/generator.ts","../src/index.ts"],"sourcesContent":["/* * Copyright (c) 2026 Fordi / FomaDev. \n * Licensed under FomaDev Public License.\n * See LICENSE file in the project root for full license information.\n */\n\n/**\n * Convertit les caractères spéciaux en entités XML pour éviter la corruption du fichier.\n * Gère : <, >, &, \", '\n */\nexport function escapeXml(unsafe: string | undefined | null): string {\n if (!unsafe) return '';\n \n return unsafe.replace(/[<>&\"']/g, (c) => {\n switch (c) {\n case '<': return '<';\n case '>': return '>';\n case '&': return '&';\n case '\"': return '"';\n case \"'\": return ''';\n default: return c;\n }\n });\n}","/* * Copyright (c) 2026 Fordi / FomaDev. \n * Licensed under FomaDev Public License.\n * See LICENSE file in the project root for full license information.\n */\n\nimport { SitemapEntry, SitemapOptions } from '../types/sitemap.js';\nimport { escapeXml } from '../utils/xml-escape.js';\n\n/**\n * Nettoie et valide de manière stricte le format et la structure d'une URL.\n * v1.0.7 : Intégration de l'Auto-Trimming (nettoyage des espaces de début et de fin)\n */\nfunction sanitizeAndValidateUrl(rawUrl: string, context: string): string {\n const url = rawUrl ? rawUrl.trim() : '';\n\n if (!url.startsWith('http://') && !url.startsWith('https://')) {\n throw new Error(\n `[next-advanced-sitemap] Invalid URL in ${context}: \"${url}\". URLs must start with http:// or https://`\n );\n }\n\n if (url.includes(' ')) {\n throw new Error(\n `[next-advanced-sitemap] Malformed URL structure detected in ${context}: \"${url}\". Please verify spaces or special characters.`\n );\n }\n\n let isValid = false;\n if (typeof URL.canParse === 'function') {\n isValid = URL.canParse(url);\n } else {\n try {\n new URL(url);\n isValid = true;\n } catch {\n isValid = false;\n }\n }\n\n if (!isValid) {\n throw new Error(\n `[next-advanced-sitemap] Malformed URL structure detected in ${context}: \"${url}\". Please verify spaces or special characters.`\n );\n }\n\n return url;\n}\n\n/**\n * Génère le flux XML complet du sitemap incluant les extensions Images, Vidéos, News et Hreflang.\n * v1.1.3 : Validation stricte des statistiques vidéo (duration entre 0-28800s & view_count >= 0)\n */\nexport function generateXml(entries: SitemapEntry[], options: SitemapOptions = {}): string {\n const now = new Date().toISOString();\n let finalEntries = [...entries];\n\n if (options.sortByPriority) {\n finalEntries.sort((a, b) => {\n const priorityA = a.priority !== undefined ? (a.priority as number) : 0.5;\n const priorityB = b.priority !== undefined ? (b.priority as number) : 0.5;\n return priorityB - priorityA;\n });\n }\n \n let xml = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n`;\n xml += `<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\\n`;\n xml += ` xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"\\n`;\n xml += ` xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\"\\n`;\n xml += ` xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\"\\n`;\n xml += ` xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\\n`;\n\n for (const entry of finalEntries) {\n const cleanMainUrl = sanitizeAndValidateUrl(entry.url, 'main entry');\n\n xml += ` <url>\\n`;\n xml += ` <loc>${escapeXml(cleanMainUrl)}</loc>\\n`;\n\n if (entry.alternates?.length) {\n for (const alt of entry.alternates) {\n const cleanAltUrl = sanitizeAndValidateUrl(alt.href, 'alternate link');\n xml += ` <xhtml:link rel=\"alternate\" hreflang=\"${escapeXml(alt.hreflang)}\" href=\"${escapeXml(cleanAltUrl)}\" />\\n`;\n }\n }\n\n let lastmodValue = entry.lastmod;\n if (options.autoLastmod && !lastmodValue) {\n lastmodValue = now;\n }\n\n if (lastmodValue) {\n const date = lastmodValue instanceof Date ? lastmodValue.toISOString() : lastmodValue;\n xml += ` <lastmod>${date}</lastmod>\\n`;\n }\n\n if (entry.changefreq) {\n xml += ` <changefreq>${entry.changefreq}</changefreq>\\n`;\n }\n\n if (entry.priority !== undefined) {\n xml += ` <priority>${(entry.priority as number).toFixed(1)}</priority>\\n`;\n }\n\n // Extension Images\n if (entry.images?.length) {\n for (const img of entry.images) {\n const cleanImgUrl = sanitizeAndValidateUrl(img.loc, 'image location');\n \n xml += ` <image:image>\\n`;\n xml += ` <image:loc>${escapeXml(cleanImgUrl)}</image:loc>\\n`;\n \n if (img.title && img.title.trim() !== '') {\n xml += ` <image:title>${escapeXml(img.title.trim())}</image:title>\\n`;\n }\n if (img.caption && img.caption.trim() !== '') {\n xml += ` <image:caption>${escapeXml(img.caption.trim())}</image:caption>\\n`;\n }\n \n if (img.geo_location && img.geo_location.trim() !== '') {\n xml += ` <image:geo_location>${escapeXml(img.geo_location.trim())}</image:geo_location>\\n`;\n }\n \n if (img.license) {\n const cleanLicenseUrl = sanitizeAndValidateUrl(img.license, 'image license URL');\n xml += ` <image:license>${escapeXml(cleanLicenseUrl)}</image:license>\\n`;\n }\n \n xml += ` </image:image>\\n`;\n }\n }\n\n // Extension Vidéos - v1.1.3 sécurisée\n if (entry.videos?.length) {\n for (const vid of entry.videos) {\n const cleanThumbLoc = sanitizeAndValidateUrl(vid.thumbnail_loc, 'video thumbnail');\n const cleanContentLoc = vid.content_loc ? sanitizeAndValidateUrl(vid.content_loc, 'video content location') : undefined;\n const cleanPlayerLoc = vid.player_loc ? sanitizeAndValidateUrl(vid.player_loc, 'video player location') : undefined;\n\n xml += ` <video:video>\\n`;\n xml += ` <video:thumbnail_loc>${escapeXml(cleanThumbLoc)}</video:thumbnail_loc>\\n`;\n xml += ` <video:title>${escapeXml(vid.title)}</video:title>\\n`;\n xml += ` <video:description>${escapeXml(vid.description)}</video:description>\\n`;\n \n if (cleanContentLoc) xml += ` <video:content_loc>${escapeXml(cleanContentLoc)}</video:content_loc>\\n`;\n if (cleanPlayerLoc) xml += ` <video:player_loc>${escapeXml(cleanPlayerLoc)}</video:player_loc>\\n`;\n \n if (vid.publication_date) {\n const vDate = vid.publication_date instanceof Date ? vid.publication_date.toISOString() : vid.publication_date;\n xml += ` <video:publication_date>${vDate}</video:publication_date>\\n`;\n }\n\n // ✨ Validation et Sérialisation de la durée (0 - 28800s)\n if (vid.duration !== undefined) {\n const finalDuration = Math.floor(vid.duration);\n if (finalDuration < 0 || finalDuration > 28800) {\n throw new Error(\n `[next-advanced-sitemap] Invalid video duration: ${finalDuration}. Duration must be an integer between 0 and 28800 seconds (8 hours).`\n );\n }\n xml += ` <video:duration>${finalDuration}</video:duration>\\n`;\n }\n\n // ✨ Validation et Sérialisation du nombre de vues (>= 0)\n if (vid.view_count !== undefined) {\n const finalViewCount = Math.floor(vid.view_count);\n if (finalViewCount < 0) {\n throw new Error(\n `[next-advanced-sitemap] Invalid video view_count: ${finalViewCount}. View count cannot be negative.`\n );\n }\n xml += ` <video:view_count>${finalViewCount}</video:view_count>\\n`;\n }\n\n if (vid.live) {\n xml += ` <video:live>${vid.live}</video:live>\\n`;\n }\n\n xml += ` </video:video>\\n`;\n }\n }\n\n // Extension News\n if (entry.news) {\n const nDate = entry.news.publication_date instanceof Date ? entry.news.publication_date.toISOString() : entry.news.publication_date;\n xml += ` <news:news>\\n`;\n xml += ` <news:publication>\\n`;\n xml += ` <news:name>${escapeXml(entry.news.name)}</news:name>\\n`;\n xml += ` <news:language>${escapeXml(entry.news.language)}</news:language>\\n`;\n xml += ` </news:publication>\\n`;\n xml += ` <news:publication_date>${nDate}</news:publication_date>\\n`;\n xml += ` <news:title>${escapeXml(entry.news.title)}</news:title>\\n`;\n xml += ` </news:news>\\n`;\n }\n\n xml += ` </url>\\n`;\n }\n\n xml += `</urlset>`;\n return xml;\n}","/* * Copyright (c) 2026 Fordi / FomaDev. \n * Licensed under FomaDev Public License.\n * See LICENSE file in the project root for full license information.\n */\n\nimport { SitemapEntry, SitemapOptions } from './types/sitemap.js';\nimport { generateXml } from './core/generator.js';\n\nexport * from './types/sitemap.js';\n\n/**\n * Génère une réponse HTTP compatible Next.js (App Router) avec options de configuration.\n * v1.0.9 : Injection dynamique et personnalisable de l'en-tête Cache-Control via l'option maxAge\n * * @param entries - Liste des entrées du sitemap\n * @param options - Options de génération et de mise en cache (ex: autoLastmod, maxAge)\n * @returns Une instance de Response contenant le flux XML configuré\n */\nexport function getServerSitemapResponse(\n entries: SitemapEntry[], \n options: SitemapOptions = {}\n): Response {\n const xml = generateXml(entries, options);\n\n // Détermination de la stratégie de mise en cache (v1.0.9)\n const cacheControlHeader = options.maxAge !== undefined\n ? `public, max-age=${options.maxAge}, must-revalidate`\n : 'public, s-maxage=86400, stale-while-revalidate';\n\n return new Response(xml, {\n headers: {\n 'Content-Type': 'application/xml',\n 'Cache-Control': cacheControlHeader,\n },\n });\n}"],"mappings":";AASO,SAAS,UAAU,QAA2C;AACnE,MAAI,CAAC,OAAQ,QAAO;AAEpB,SAAO,OAAO,QAAQ,YAAY,CAAC,MAAM;AACvC,YA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": "Advanced sitemap generator for Next.js. Powerful support for Google Images, Video, News, and Hreflang (multilingual). Type-safe, zero-dependency, and built for App Router.",
|
|
6
|
-
"main": "./dist/index.cjs",
|
|
7
|
-
"module": "./dist/index.js",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"import": "./dist/index.js",
|
|
13
|
-
"require": "./dist/index.cjs"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"dist"
|
|
18
|
-
],
|
|
19
|
-
"scripts": {
|
|
20
|
-
"dev": "tsup src/index.ts --watch",
|
|
21
|
-
"build": "tsup",
|
|
22
|
-
"test": "vitest run",
|
|
23
|
-
"prepublishOnly": "npm run test && npm run build"
|
|
24
|
-
},
|
|
25
|
-
"keywords": [
|
|
26
|
-
"nextjs",
|
|
27
|
-
"sitemap",
|
|
28
|
-
"seo",
|
|
29
|
-
"google-images",
|
|
30
|
-
"google-video",
|
|
31
|
-
"google-news",
|
|
32
|
-
"hreflang",
|
|
33
|
-
"multilingual",
|
|
34
|
-
"typescript",
|
|
35
|
-
"app-router"
|
|
36
|
-
],
|
|
37
|
-
"author": "fomadev",
|
|
38
|
-
"license": "FomaDev Public License",
|
|
39
|
-
"repository": {
|
|
40
|
-
"type": "git",
|
|
41
|
-
"url": "git+https://github.com/fomadev/next-advanced-sitemap.git"
|
|
42
|
-
},
|
|
43
|
-
"bugs": {
|
|
44
|
-
"url": "https://github.com/fomadev/next-advanced-sitemap/issues"
|
|
45
|
-
},
|
|
46
|
-
"homepage": "https://github.com/fomadev/next-advanced-sitemap#readme",
|
|
47
|
-
"devDependencies": {
|
|
48
|
-
"tsup": "^8.5.1",
|
|
49
|
-
"typescript": "^5.7.3",
|
|
50
|
-
"vitest": "^1.4.0"
|
|
51
|
-
},
|
|
52
|
-
"peerDependencies": {
|
|
53
|
-
"next": ">=13.0.0",
|
|
54
|
-
"react": ">=18.0.0"
|
|
55
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "next-advanced-sitemap",
|
|
3
|
+
"version": "1.1.3",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Advanced sitemap generator for Next.js. Powerful support for Google Images, Video, News, and Hreflang (multilingual). Type-safe, zero-dependency, and built for App Router.",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"dev": "tsup src/index.ts --watch",
|
|
21
|
+
"build": "tsup",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"prepublishOnly": "npm run test && npm run build"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"nextjs",
|
|
27
|
+
"sitemap",
|
|
28
|
+
"seo",
|
|
29
|
+
"google-images",
|
|
30
|
+
"google-video",
|
|
31
|
+
"google-news",
|
|
32
|
+
"hreflang",
|
|
33
|
+
"multilingual",
|
|
34
|
+
"typescript",
|
|
35
|
+
"app-router"
|
|
36
|
+
],
|
|
37
|
+
"author": "fomadev",
|
|
38
|
+
"license": "FomaDev Public License",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/fomadev/next-advanced-sitemap.git"
|
|
42
|
+
},
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/fomadev/next-advanced-sitemap/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/fomadev/next-advanced-sitemap#readme",
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"tsup": "^8.5.1",
|
|
49
|
+
"typescript": "^5.7.3",
|
|
50
|
+
"vitest": "^1.4.0"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"next": ">=13.0.0",
|
|
54
|
+
"react": ">=18.0.0"
|
|
55
|
+
}
|
|
56
56
|
}
|