next-advanced-sitemap 1.0.4 → 1.0.5
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/README.md +19 -11
- package/dist/index.d.cts +13 -3
- package/dist/index.d.ts +13 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ While Next.js provides a built-in `MetadataRoute.Sitemap` utility, it currently
|
|
|
12
12
|
- **Google Video Support**: Improve search visibility for video content with thumbnail and description metadata.
|
|
13
13
|
- **Google News Support**: Comply with Google News requirements including publication names and dates.
|
|
14
14
|
- **Internationalization**: Seamless integration of `xhtml:link` tags for Hreflang and multi-regional SEO.
|
|
15
|
+
- **Strict SEO Enum Typing (v1.0.5)**: Compile-time validation and IDE autocompletion for `changefreq` and `priority` values to prevent typos.
|
|
15
16
|
- **Strict Structural Validation (v1.0.4)**: Advanced URL parsing using the platform-native engine to intercept syntax errors and unencoded whitespaces before deployment.
|
|
16
17
|
- **Auto-lastmod (v1.0.3)**: Optional automatic injection of the current system date for entries missing a `lastmod` value.
|
|
17
18
|
- **Advanced XML Escaping (v1.0.2)**: Enhanced processor to handle complex special characters (`&`, `"`, `'`, `<`, `>`) in SEO metadata, ensuring XML integrity.
|
|
@@ -35,8 +36,8 @@ export async function GET() {
|
|
|
35
36
|
{
|
|
36
37
|
url: 'https://fomadev.com',
|
|
37
38
|
lastmod: new Date(),
|
|
38
|
-
changefreq: 'daily',
|
|
39
|
-
priority: 1.0,
|
|
39
|
+
changefreq: 'daily', // Strictly typed
|
|
40
|
+
priority: 1.0, // Auto-completed and strictly typed
|
|
40
41
|
alternates: [
|
|
41
42
|
{ hreflang: 'fr', href: 'https://fomadev.com/fr' },
|
|
42
43
|
{ hreflang: 'en', href: 'https://fomadev.com/en' }
|
|
@@ -103,13 +104,13 @@ Generates a standard Next.js `Response` object with the correct `application/xml
|
|
|
103
104
|
</tr>
|
|
104
105
|
<tr>
|
|
105
106
|
<td><code>changefreq</code></td>
|
|
106
|
-
<td class="type-label">
|
|
107
|
-
<td>(Optional)
|
|
107
|
+
<td class="type-label">SitemapChangeFreq</td>
|
|
108
|
+
<td>(Optional) Bounded search engine hint ('always', 'daily', etc.).</td>
|
|
108
109
|
</tr>
|
|
109
110
|
<tr>
|
|
110
111
|
<td><code>priority</code></td>
|
|
111
|
-
<td class="type-label">
|
|
112
|
-
<td>(Optional)
|
|
112
|
+
<td class="type-label">SitemapPriority</td>
|
|
113
|
+
<td>(Optional) Bounded priority float value (0.0 to 1.0).</td>
|
|
113
114
|
</tr>
|
|
114
115
|
<tr>
|
|
115
116
|
<td><code>images</code></td>
|
|
@@ -136,17 +137,24 @@ Generates a standard Next.js `Response` object with the correct `application/xml
|
|
|
136
137
|
|
|
137
138
|
## Technical Implementation
|
|
138
139
|
|
|
139
|
-
###
|
|
140
|
+
### Compile-Time Parameter Guarding (v1.0.5 Update)
|
|
141
|
+
|
|
142
|
+
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:
|
|
143
|
+
|
|
144
|
+
* **SitemapChangeFreq**: A literal string union restricting data ingestion exclusively to authorized keywords (`'always'` | `'hourly'` | `'daily'` | `'weekly'` | `'monthly'` | `'yearly'` | `'never'`).
|
|
145
|
+
|
|
146
|
+
* **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.
|
|
147
|
+
|
|
148
|
+
### Validation & Safety
|
|
140
149
|
|
|
141
|
-
The library executes
|
|
150
|
+
The library executes deterministic validation layers on all URL inputs:
|
|
142
151
|
|
|
143
152
|
1. **Protocol Match**: Enforces that all strings begin strictly with an absolute `http://` or `https://` prefix.
|
|
144
153
|
|
|
145
|
-
2. **Whitespace Interception**: Instantly isolates and rejects strings containing unencoded internal spaces
|
|
154
|
+
2. **Whitespace Interception**: Instantly isolates and rejects strings containing unencoded internal spaces.
|
|
146
155
|
|
|
147
|
-
3. **Structural Compliance**: Leverages the native `URL.canParse`() API (with a clean fallback mechanism to the `new URL()` constructor
|
|
156
|
+
3. **Structural Compliance**: Leverages the native `URL.canParse`() API (with a clean fallback mechanism to the `new URL()` constructor) to validate layout health.
|
|
148
157
|
|
|
149
|
-
If any path breaks standard RFC specifications, the generator throws an explicit runtime exception to prevent the application from deploying a malformed payload.
|
|
150
158
|
|
|
151
159
|
### Advanced XML Security
|
|
152
160
|
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fréquences de changement autorisées dans la spécification des sitemaps
|
|
3
|
+
*/
|
|
4
|
+
type SitemapChangeFreq = 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
|
|
5
|
+
/**
|
|
6
|
+
* Priorités recommandées (de 0.0 à 1.0)
|
|
7
|
+
* L'intersection (number & {}) permet de conserver l'autocomplétion des paliers
|
|
8
|
+
* tout en acceptant n'importe quel autre nombre flottant.
|
|
9
|
+
*/
|
|
10
|
+
type SitemapPriority = 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | 1.0 | (number & {});
|
|
1
11
|
/**
|
|
2
12
|
* Interface pour les liens alternatifs (Hreflang / Multilingue)
|
|
3
13
|
* @see https://developers.google.com/search/docs/specialty/international/localized-versions#sitemap
|
|
@@ -48,8 +58,8 @@ interface SitemapNews {
|
|
|
48
58
|
interface SitemapEntry {
|
|
49
59
|
url: string;
|
|
50
60
|
lastmod?: string | Date;
|
|
51
|
-
changefreq?:
|
|
52
|
-
priority?:
|
|
61
|
+
changefreq?: SitemapChangeFreq;
|
|
62
|
+
priority?: SitemapPriority;
|
|
53
63
|
images?: SitemapImage[];
|
|
54
64
|
videos?: SitemapVideo[];
|
|
55
65
|
news?: SitemapNews;
|
|
@@ -74,4 +84,4 @@ interface SitemapOptions {
|
|
|
74
84
|
*/
|
|
75
85
|
declare function getServerSitemapResponse(entries: SitemapEntry[], options?: SitemapOptions): Response;
|
|
76
86
|
|
|
77
|
-
export { type SitemapAlternate, type SitemapEntry, type SitemapImage, type SitemapNews, type SitemapOptions, type SitemapVideo, getServerSitemapResponse };
|
|
87
|
+
export { type SitemapAlternate, type SitemapChangeFreq, type SitemapEntry, type SitemapImage, type SitemapNews, type SitemapOptions, type SitemapPriority, type SitemapVideo, getServerSitemapResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fréquences de changement autorisées dans la spécification des sitemaps
|
|
3
|
+
*/
|
|
4
|
+
type SitemapChangeFreq = 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
|
|
5
|
+
/**
|
|
6
|
+
* Priorités recommandées (de 0.0 à 1.0)
|
|
7
|
+
* L'intersection (number & {}) permet de conserver l'autocomplétion des paliers
|
|
8
|
+
* tout en acceptant n'importe quel autre nombre flottant.
|
|
9
|
+
*/
|
|
10
|
+
type SitemapPriority = 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | 1.0 | (number & {});
|
|
1
11
|
/**
|
|
2
12
|
* Interface pour les liens alternatifs (Hreflang / Multilingue)
|
|
3
13
|
* @see https://developers.google.com/search/docs/specialty/international/localized-versions#sitemap
|
|
@@ -48,8 +58,8 @@ interface SitemapNews {
|
|
|
48
58
|
interface SitemapEntry {
|
|
49
59
|
url: string;
|
|
50
60
|
lastmod?: string | Date;
|
|
51
|
-
changefreq?:
|
|
52
|
-
priority?:
|
|
61
|
+
changefreq?: SitemapChangeFreq;
|
|
62
|
+
priority?: SitemapPriority;
|
|
53
63
|
images?: SitemapImage[];
|
|
54
64
|
videos?: SitemapVideo[];
|
|
55
65
|
news?: SitemapNews;
|
|
@@ -74,4 +84,4 @@ interface SitemapOptions {
|
|
|
74
84
|
*/
|
|
75
85
|
declare function getServerSitemapResponse(entries: SitemapEntry[], options?: SitemapOptions): Response;
|
|
76
86
|
|
|
77
|
-
export { type SitemapAlternate, type SitemapEntry, type SitemapImage, type SitemapNews, type SitemapOptions, type SitemapVideo, getServerSitemapResponse };
|
|
87
|
+
export { type SitemapAlternate, type SitemapChangeFreq, type SitemapEntry, type SitemapImage, type SitemapNews, type SitemapOptions, type SitemapPriority, type SitemapVideo, getServerSitemapResponse };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-advanced-sitemap",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"type": "module",
|
|
5
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
6
|
"main": "./dist/index.cjs",
|