@power-seo/sitemap 1.0.5 → 1.0.6

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CCBD SEO Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -18,16 +18,16 @@ XML sitemap generation for TypeScript — streaming output, automatic index spli
18
18
 
19
19
  ## Why @power-seo/sitemap?
20
20
 
21
- | | Without | With |
22
- | ----------------- | ----------------------------------------- | --------------------------------------------------- |
23
- | Spec compliance | ❌ Hand-built XML, wrong namespaces | ✅ Correct `<urlset>` + namespace declarations |
24
- | Large sites | ❌ Single file breaks at 50,000 URLs | ✅ Auto-split + sitemap index generation |
25
- | Memory usage | ❌ String concat spikes on large catalogs | ✅ Synchronous generator yields chunks |
26
- | Image indexing | ❌ Product images undiscoverable | ✅ `<image:image>` extension per URL |
27
- | Video SEO | ❌ No structured video metadata | ✅ `<video:video>` extension with title, duration |
28
- | News sitemaps | ❌ Missing publication + date tags | ✅ `<news:news>` extension for Google News |
29
- | Hostname handling | ❌ Hardcode absolute URLs everywhere | ✅ Pass `hostname` once; use relative `loc` paths |
30
- | Validation | ❌ Silent bad data reaches Google | ✅ `validateSitemapUrl()` returns errors + warnings |
21
+ | | Without | With |
22
+ |---|---|---|
23
+ | Spec compliance | ❌ Hand-built XML, wrong namespaces | ✅ Correct `<urlset>` + namespace declarations |
24
+ | Large sites | ❌ Single file breaks at 50,000 URLs | ✅ Auto-split + sitemap index generation |
25
+ | Memory usage | ❌ String concat spikes on large catalogs | ✅ Synchronous generator yields chunks |
26
+ | Image indexing | ❌ Product images undiscoverable | ✅ `<image:image>` extension per URL |
27
+ | Video SEO | ❌ No structured video metadata | ✅ `<video:video>` extension with title, duration |
28
+ | News sitemaps | ❌ Missing publication + date tags | ✅ `<news:news>` extension for Google News |
29
+ | Hostname handling | ❌ Hardcode absolute URLs everywhere | ✅ Pass `hostname` once; use relative `loc` paths |
30
+ | Validation | ❌ Silent bad data reaches Google | ✅ `validateSitemapUrl()` returns errors + warnings |
31
31
 
32
32
  ---
33
33
 
@@ -53,20 +53,20 @@ XML sitemap generation for TypeScript — streaming output, automatic index spli
53
53
 
54
54
  ## Comparison
55
55
 
56
- | Feature | @power-seo/sitemap | next-sitemap | sitemap (npm) | xmlbuilder2 |
57
- | -------------------------------- | :----------------: | :----------: | :-----------: | :---------: |
58
- | Image sitemap extension | | | | |
59
- | Video sitemap extension | | | | |
60
- | News sitemap extension | | | | |
61
- | Streaming generation | | | | |
62
- | Auto index splitting | | | | |
63
- | URL validation | | | | |
64
- | Hostname + relative loc paths | | | | |
65
- | Zero runtime dependencies | | | | |
66
- | Edge runtime compatible | | | | |
67
- | TypeScript-first | | Partial | | |
68
- | Tree-shakeable | | | | |
69
- | Next.js `app/sitemap.ts` adapter | | | | |
56
+ | Feature | @power-seo/sitemap | next-sitemap | sitemap (npm) | xmlbuilder2 |
57
+ | ------------------------------ | :----------------: | :----------: | :-----------: | :---------: |
58
+ | Image sitemap extension | | | | |
59
+ | Video sitemap extension | | | | |
60
+ | News sitemap extension | | | | |
61
+ | Streaming generation | | | | |
62
+ | Auto index splitting | | | | |
63
+ | URL validation | | | | |
64
+ | Hostname + relative loc paths | | | | |
65
+ | Zero runtime dependencies | | | | |
66
+ | Edge runtime compatible | | | | |
67
+ | TypeScript-first | | Partial | | |
68
+ | Tree-shakeable | | | | |
69
+ | Next.js `app/sitemap.ts` adapter | | | | |
70
70
 
71
71
  ---
72
72
 
@@ -317,12 +317,12 @@ export async function loader({ request }: LoaderFunctionArgs) {
317
317
  function generateSitemap(config: SitemapConfig): string;
318
318
  ```
319
319
 
320
- | Prop | Type | Required | Description |
321
- | ------------------- | -------------- | -------- | ------------------------------------------------------------------------- |
322
- | `hostname` | `string` | ✅ | Base URL prepended to relative `loc` paths (e.g. `'https://example.com'`) |
323
- | `urls` | `SitemapURL[]` | ✅ | Array of URL entries |
324
- | `maxUrlsPerSitemap` | `number` | — | Override the 50,000-URL chunk size (used by `splitSitemap`) |
325
- | `outputDir` | `string` | — | Optional output directory hint (informational; does not write files) |
320
+ | Prop | Type | Required | Description |
321
+ | --- | --- | --- | --- |
322
+ | `hostname` | `string` | ✅ | Base URL prepended to relative `loc` paths (e.g. `'https://example.com'`) |
323
+ | `urls` | `SitemapURL[]` | ✅ | Array of URL entries |
324
+ | `maxUrlsPerSitemap` | `number` | — | Override the 50,000-URL chunk size (used by `splitSitemap`) |
325
+ | `outputDir` | `string` | — | Optional output directory hint (informational; does not write files) |
326
326
 
327
327
  ### `streamSitemap(hostname, urls)`
328
328
 
@@ -335,10 +335,10 @@ function streamSitemap(
335
335
 
336
336
  Synchronous generator. Yields XML string chunks — one for the XML declaration and opening tag, one per `<url>` block, and one for the closing tag. Does not buffer the full XML in memory.
337
337
 
338
- | Param | Type | Description |
339
- | ---------- | ---------------------- | ------------------------------------------------------------------ |
340
- | `hostname` | `string` | Base URL prepended to relative `loc` paths |
341
- | `urls` | `Iterable<SitemapURL>` | Any iterable of URL entries — arrays, generators, database cursors |
338
+ | Param | Type | Description |
339
+ | --- | --- | --- |
340
+ | `hostname` | `string` | Base URL prepended to relative `loc` paths |
341
+ | `urls` | `Iterable<SitemapURL>` | Any iterable of URL entries — arrays, generators, database cursors |
342
342
 
343
343
  ### `splitSitemap(config, sitemapUrlPattern?)`
344
344
 
@@ -351,17 +351,17 @@ function splitSitemap(
351
351
 
352
352
  Splits a large URL set into multiple sitemap files and returns the index XML and all sitemap XMLs. The `sitemapUrlPattern` parameter controls generated filenames using `{index}` as a placeholder.
353
353
 
354
- | Param | Type | Default | Description |
355
- | ------------------- | --------------- | ------------------------ | --------------------------------------- |
356
- | `config` | `SitemapConfig` | — | Same config as `generateSitemap()` |
357
- | `sitemapUrlPattern` | `string` | `'/sitemap-{index}.xml'` | Filename pattern for each split sitemap |
354
+ | Param | Type | Default | Description |
355
+ | --- | --- | --- | --- |
356
+ | `config` | `SitemapConfig` | — | Same config as `generateSitemap()` |
357
+ | `sitemapUrlPattern` | `string` | `'/sitemap-{index}.xml'` | Filename pattern for each split sitemap |
358
358
 
359
359
  **Return value:**
360
360
 
361
- | Field | Type | Description |
362
- | ---------- | ------------------------------------------ | ---------------------------------------------------------------- |
363
- | `index` | `string` | Sitemap index XML (`<sitemapindex>`) referencing all split files |
364
- | `sitemaps` | `Array<{ filename: string; xml: string }>` | Each split sitemap with its filename and XML string |
361
+ | Field | Type | Description |
362
+ | --- | --- | --- |
363
+ | `index` | `string` | Sitemap index XML (`<sitemapindex>`) referencing all split files |
364
+ | `sitemaps` | `Array<{ filename: string; xml: string }>` | Each split sitemap with its filename and XML string |
365
365
 
366
366
  ### `generateSitemapIndex(config)`
367
367
 
@@ -369,8 +369,8 @@ Splits a large URL set into multiple sitemap files and returns the index XML and
369
369
  function generateSitemapIndex(config: SitemapIndexConfig): string;
370
370
  ```
371
371
 
372
- | Prop | Type | Description |
373
- | ---------- | --------------------- | ---------------------------------------------------- |
372
+ | Prop | Type | Description |
373
+ | --- | --- | --- |
374
374
  | `sitemaps` | `SitemapIndexEntry[]` | Array of `{ loc: string; lastmod?: string }` entries |
375
375
 
376
376
  ### `validateSitemapUrl(url)`
@@ -391,45 +391,45 @@ function toNextSitemap(urls: SitemapURL[]): NextSitemapEntry[];
391
391
 
392
392
  Converts a `SitemapURL[]` to the array format expected by Next.js App Router's `app/sitemap.ts` file convention. Invalid URLs (per `validateSitemapUrl`) are filtered out automatically. `lastmod` strings are converted to `Date` objects; `changefreq` is mapped to `changeFrequency`.
393
393
 
394
- | Field | Type | Description |
395
- | ----------------- | ---------------- | ------------------------------------ |
396
- | `url` | `string` | Absolute URL (`loc`) |
397
- | `lastModified` | `Date \| string` | From `lastmod` (converted to `Date`) |
398
- | `changeFrequency` | `string` | From `changefreq` |
399
- | `priority` | `number` | From `priority` |
394
+ | Field | Type | Description |
395
+ | ----------------- | ---------------------- | ---------------------------------------- |
396
+ | `url` | `string` | Absolute URL (`loc`) |
397
+ | `lastModified` | `Date \| string` | From `lastmod` (converted to `Date`) |
398
+ | `changeFrequency` | `string` | From `changefreq` |
399
+ | `priority` | `number` | From `priority` |
400
400
 
401
401
  ---
402
402
 
403
403
  ## Types
404
404
 
405
- | Type | Description |
406
- | ------------------------- | --------------------------------------------------------------------------------------------- |
407
- | `SitemapConfig` | `{ hostname: string; urls: SitemapURL[]; maxUrlsPerSitemap?: number; outputDir?: string }` |
408
- | `SitemapURL` | Single URL entry — see field table below |
409
- | `SitemapImage` | `{ loc: string; caption?: string; geoLocation?: string; title?: string; license?: string }` |
410
- | `SitemapVideo` | Video extension entry with `thumbnailLoc`, `title`, `description`, and optional fields |
411
- | `SitemapNews` | `{ publication: { name: string; language: string }; publicationDate: string; title: string }` |
412
- | `SitemapIndexConfig` | `{ sitemaps: SitemapIndexEntry[] }` |
413
- | `SitemapIndexEntry` | `{ loc: string; lastmod?: string }` |
414
- | `SitemapValidationResult` | `{ valid: boolean; errors: string[]; warnings: string[] }` |
405
+ | Type | Description |
406
+ | --- | --- |
407
+ | `SitemapConfig` | `{ hostname: string; urls: SitemapURL[]; maxUrlsPerSitemap?: number; outputDir?: string }` |
408
+ | `SitemapURL` | Single URL entry — see field table below |
409
+ | `SitemapImage` | `{ loc: string; caption?: string; geoLocation?: string; title?: string; license?: string }` |
410
+ | `SitemapVideo` | Video extension entry with `thumbnailLoc`, `title`, `description`, and optional fields |
411
+ | `SitemapNews` | `{ publication: { name: string; language: string }; publicationDate: string; title: string }` |
412
+ | `SitemapIndexConfig` | `{ sitemaps: SitemapIndexEntry[] }` |
413
+ | `SitemapIndexEntry` | `{ loc: string; lastmod?: string }` |
414
+ | `SitemapValidationResult` | `{ valid: boolean; errors: string[]; warnings: string[] }` |
415
415
 
416
416
  ### `SitemapURL` Fields
417
417
 
418
- | Prop | Type | Default | Description |
419
- | ------------ | --------------------------------------------------------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------ |
420
- | `loc` | `string` | — | **Required.** URL path (e.g. `/about`) or absolute URL. Hostname is prepended to relative paths. |
421
- | `lastmod` | `string` | — | Last modified date — ISO 8601 or `YYYY-MM-DD` |
422
- | `changefreq` | `'always' \| 'hourly' \| 'daily' \| 'weekly' \| 'monthly' \| 'yearly' \| 'never'` | — | Suggested crawl frequency |
423
- | `priority` | `number` | (no tag emitted) | Priority 0.0–1.0. When omitted, no `<priority>` tag is written. |
424
- | `images` | `SitemapImage[]` | — | Image extension entries — emits `<image:image>` blocks |
425
- | `videos` | `SitemapVideo[]` | — | Video extension entries — emits `<video:video>` blocks |
426
- | `news` | `SitemapNews` | — | News extension entry — emits `<news:news>` block |
418
+ | Prop | Type | Default | Description |
419
+ | --- | --- | --- | --- |
420
+ | `loc` | `string` | — | **Required.** URL path (e.g. `/about`) or absolute URL. Hostname is prepended to relative paths. |
421
+ | `lastmod` | `string` | — | Last modified date — ISO 8601 or `YYYY-MM-DD` |
422
+ | `changefreq` | `'always' \| 'hourly' \| 'daily' \| 'weekly' \| 'monthly' \| 'yearly' \| 'never'` | — | Suggested crawl frequency |
423
+ | `priority` | `number` | (no tag emitted) | Priority 0.0–1.0. When omitted, no `<priority>` tag is written. |
424
+ | `images` | `SitemapImage[]` | — | Image extension entries — emits `<image:image>` blocks |
425
+ | `videos` | `SitemapVideo[]` | — | Video extension entries — emits `<video:video>` blocks |
426
+ | `news` | `SitemapNews` | — | News extension entry — emits `<news:news>` block |
427
427
 
428
428
  ### Constants
429
429
 
430
- | Constant | Value | Description |
431
- | ------------------------ | ------------ | ------------------------------------------------------------- |
432
- | `MAX_URLS_PER_SITEMAP` | `50_000` | Maximum URLs allowed per sitemap file (spec limit) |
430
+ | Constant | Value | Description |
431
+ | --- | --- | --- |
432
+ | `MAX_URLS_PER_SITEMAP` | `50_000` | Maximum URLs allowed per sitemap file (spec limit) |
433
433
  | `MAX_SITEMAP_SIZE_BYTES` | `52_428_800` | Maximum sitemap file size in bytes (50 MB = 50 × 1024 × 1024) |
434
434
 
435
435
  ---
@@ -476,25 +476,25 @@ Converts a `SitemapURL[]` to the array format expected by Next.js App Router's `
476
476
 
477
477
  All 17 packages are independently installable — use only what you need.
478
478
 
479
- | Package | Install | Description |
480
- | ------------------------------------------------------------------------------------------ | ----------------------------------- | ----------------------------------------------------------------------- |
481
- | [`@power-seo/core`](https://www.npmjs.com/package/@power-seo/core) | `npm i @power-seo/core` | Framework-agnostic utilities, types, validators, and constants |
482
- | [`@power-seo/react`](https://www.npmjs.com/package/@power-seo/react) | `npm i @power-seo/react` | React SEO components — meta, Open Graph, Twitter Card, breadcrumbs |
483
- | [`@power-seo/meta`](https://www.npmjs.com/package/@power-seo/meta) | `npm i @power-seo/meta` | SSR meta helpers for Next.js App Router, Remix v2, and generic SSR |
484
- | [`@power-seo/schema`](https://www.npmjs.com/package/@power-seo/schema) | `npm i @power-seo/schema` | Type-safe JSON-LD structured data — 20 builders + 18 React components |
485
- | [`@power-seo/content-analysis`](https://www.npmjs.com/package/@power-seo/content-analysis) | `npm i @power-seo/content-analysis` | Yoast-style SEO content scoring engine with React components |
486
- | [`@power-seo/readability`](https://www.npmjs.com/package/@power-seo/readability) | `npm i @power-seo/readability` | Readability scoring — Flesch-Kincaid, Gunning Fog, Coleman-Liau, ARI |
487
- | [`@power-seo/preview`](https://www.npmjs.com/package/@power-seo/preview) | `npm i @power-seo/preview` | SERP, Open Graph, and Twitter/X Card preview generators |
488
- | [`@power-seo/sitemap`](https://www.npmjs.com/package/@power-seo/sitemap) | `npm i @power-seo/sitemap` | XML sitemap generation, streaming, index splitting, and validation |
489
- | [`@power-seo/redirects`](https://www.npmjs.com/package/@power-seo/redirects) | `npm i @power-seo/redirects` | Redirect engine with Next.js, Remix, and Express adapters |
490
- | [`@power-seo/links`](https://www.npmjs.com/package/@power-seo/links) | `npm i @power-seo/links` | Link graph analysis — orphan detection, suggestions, equity scoring |
491
- | [`@power-seo/audit`](https://www.npmjs.com/package/@power-seo/audit) | `npm i @power-seo/audit` | Full SEO audit engine — meta, content, structure, performance rules |
492
- | [`@power-seo/images`](https://www.npmjs.com/package/@power-seo/images) | `npm i @power-seo/images` | Image SEO — alt text, lazy loading, format analysis, image sitemaps |
493
- | [`@power-seo/ai`](https://www.npmjs.com/package/@power-seo/ai) | `npm i @power-seo/ai` | LLM-agnostic AI prompt templates and parsers for SEO tasks |
494
- | [`@power-seo/analytics`](https://www.npmjs.com/package/@power-seo/analytics) | `npm i @power-seo/analytics` | Merge GSC + audit data, trend analysis, ranking insights, dashboard |
495
- | [`@power-seo/search-console`](https://www.npmjs.com/package/@power-seo/search-console) | `npm i @power-seo/search-console` | Google Search Console API — OAuth2, service account, URL inspection |
496
- | [`@power-seo/integrations`](https://www.npmjs.com/package/@power-seo/integrations) | `npm i @power-seo/integrations` | Semrush and Ahrefs API clients with rate limiting and pagination |
497
- | [`@power-seo/tracking`](https://www.npmjs.com/package/@power-seo/tracking) | `npm i @power-seo/tracking` | GA4, Clarity, PostHog, Plausible, Fathom — scripts + consent management |
479
+ | Package | Install | Description |
480
+ | --- | --- | --- |
481
+ | [`@power-seo/core`](https://www.npmjs.com/package/@power-seo/core) | `npm i @power-seo/core` | Framework-agnostic utilities, types, validators, and constants |
482
+ | [`@power-seo/react`](https://www.npmjs.com/package/@power-seo/react) | `npm i @power-seo/react` | React SEO components — meta, Open Graph, Twitter Card, breadcrumbs |
483
+ | [`@power-seo/meta`](https://www.npmjs.com/package/@power-seo/meta) | `npm i @power-seo/meta` | SSR meta helpers for Next.js App Router, Remix v2, and generic SSR |
484
+ | [`@power-seo/schema`](https://www.npmjs.com/package/@power-seo/schema) | `npm i @power-seo/schema` | Type-safe JSON-LD structured data — 20 builders + 18 React components |
485
+ | [`@power-seo/content-analysis`](https://www.npmjs.com/package/@power-seo/content-analysis) | `npm i @power-seo/content-analysis` | Yoast-style SEO content scoring engine with React components |
486
+ | [`@power-seo/readability`](https://www.npmjs.com/package/@power-seo/readability) | `npm i @power-seo/readability` | Readability scoring — Flesch-Kincaid, Gunning Fog, Coleman-Liau, ARI |
487
+ | [`@power-seo/preview`](https://www.npmjs.com/package/@power-seo/preview) | `npm i @power-seo/preview` | SERP, Open Graph, and Twitter/X Card preview generators |
488
+ | [`@power-seo/sitemap`](https://www.npmjs.com/package/@power-seo/sitemap) | `npm i @power-seo/sitemap` | XML sitemap generation, streaming, index splitting, and validation |
489
+ | [`@power-seo/redirects`](https://www.npmjs.com/package/@power-seo/redirects) | `npm i @power-seo/redirects` | Redirect engine with Next.js, Remix, and Express adapters |
490
+ | [`@power-seo/links`](https://www.npmjs.com/package/@power-seo/links) | `npm i @power-seo/links` | Link graph analysis — orphan detection, suggestions, equity scoring |
491
+ | [`@power-seo/audit`](https://www.npmjs.com/package/@power-seo/audit) | `npm i @power-seo/audit` | Full SEO audit engine — meta, content, structure, performance rules |
492
+ | [`@power-seo/images`](https://www.npmjs.com/package/@power-seo/images) | `npm i @power-seo/images` | Image SEO — alt text, lazy loading, format analysis, image sitemaps |
493
+ | [`@power-seo/ai`](https://www.npmjs.com/package/@power-seo/ai) | `npm i @power-seo/ai` | LLM-agnostic AI prompt templates and parsers for SEO tasks |
494
+ | [`@power-seo/analytics`](https://www.npmjs.com/package/@power-seo/analytics) | `npm i @power-seo/analytics` | Merge GSC + audit data, trend analysis, ranking insights, dashboard |
495
+ | [`@power-seo/search-console`](https://www.npmjs.com/package/@power-seo/search-console) | `npm i @power-seo/search-console` | Google Search Console API — OAuth2, service account, URL inspection |
496
+ | [`@power-seo/integrations`](https://www.npmjs.com/package/@power-seo/integrations) | `npm i @power-seo/integrations` | Semrush and Ahrefs API clients with rate limiting and pagination |
497
+ | [`@power-seo/tracking`](https://www.npmjs.com/package/@power-seo/tracking) | `npm i @power-seo/tracking` | GA4, Clarity, PostHog, Plausible, Fathom — scripts + consent management |
498
498
 
499
499
  ---
500
500
 
package/dist/index.cjs CHANGED
@@ -364,15 +364,9 @@ function toNextSitemap(urls) {
364
364
  const { valid } = validateSitemapUrl(url);
365
365
  if (!valid) continue;
366
366
  const entry = { url: url.loc };
367
- if (url.lastmod) {
368
- entry.lastModified = url.lastmod;
369
- }
370
- if (url.changefreq) {
371
- entry.changeFrequency = url.changefreq;
372
- }
373
- if (url.priority !== void 0) {
374
- entry.priority = url.priority;
375
- }
367
+ if (url.lastmod) entry.lastModified = url.lastmod;
368
+ if (url.changefreq) entry.changeFrequency = url.changefreq;
369
+ if (url.priority !== void 0) entry.priority = url.priority;
376
370
  entries.push(entry);
377
371
  }
378
372
  return entries;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/generator.ts","../src/types.ts","../src/sitemap-index.ts","../src/stream.ts","../src/validate.ts","../src/next-adapter.ts"],"sourcesContent":["// ============================================================================\n// @power-seo/sitemap — Public API\n// ============================================================================\n\nexport { generateSitemap } from './generator.js';\nexport { generateSitemapIndex, splitSitemap } from './sitemap-index.js';\nexport { streamSitemap } from './stream.js';\nexport { validateSitemapUrl } from './validate.js';\nexport { toNextSitemap } from './next-adapter.js';\nexport type { NextSitemapEntry } from './next-adapter.js';\n\nexport type {\n SitemapURL,\n SitemapImage,\n SitemapVideo,\n SitemapNews,\n SitemapConfig,\n SitemapIndexEntry,\n SitemapIndexConfig,\n SitemapValidationResult,\n} from './types.js';\n\nexport { MAX_URLS_PER_SITEMAP, MAX_SITEMAP_SIZE_BYTES } from './types.js';\n","// ============================================================================\n// @power-seo/sitemap — XML Sitemap Generator\n// ============================================================================\n\nimport type {\n SitemapConfig,\n SitemapURL,\n SitemapImage,\n SitemapVideo,\n SitemapNews,\n} from '@power-seo/core';\nimport { normalizeUrl } from '@power-seo/core';\n\n/** Escape special XML characters. */\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&apos;');\n}\n\n/** Determine which namespace extensions are needed. */\nfunction detectNamespaces(urls: SitemapURL[]): { image: boolean; video: boolean; news: boolean } {\n let image = false;\n let video = false;\n let news = false;\n for (const url of urls) {\n if (url.images && url.images.length > 0) image = true;\n if (url.videos && url.videos.length > 0) video = true;\n if (url.news) news = true;\n if (image && video && news) break;\n }\n return { image, video, news };\n}\n\nfunction buildImageXml(images: SitemapImage[]): string {\n return images\n .map((img) => {\n let xml = ' <image:image>\\n';\n xml += ` <image:loc>${escapeXml(img.loc)}</image:loc>\\n`;\n if (img.caption) xml += ` <image:caption>${escapeXml(img.caption)}</image:caption>\\n`;\n if (img.geoLocation)\n xml += ` <image:geo_location>${escapeXml(img.geoLocation)}</image:geo_location>\\n`;\n if (img.title) xml += ` <image:title>${escapeXml(img.title)}</image:title>\\n`;\n if (img.license) xml += ` <image:license>${escapeXml(img.license)}</image:license>\\n`;\n xml += ' </image:image>\\n';\n return xml;\n })\n .join('');\n}\n\nfunction buildVideoXml(videos: SitemapVideo[]): string {\n return videos\n .map((vid) => {\n let xml = ' <video:video>\\n';\n xml += ` <video:thumbnail_loc>${escapeXml(vid.thumbnailLoc)}</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 if (vid.contentLoc)\n xml += ` <video:content_loc>${escapeXml(vid.contentLoc)}</video:content_loc>\\n`;\n if (vid.playerLoc)\n xml += ` <video:player_loc>${escapeXml(vid.playerLoc)}</video:player_loc>\\n`;\n if (vid.duration !== undefined)\n xml += ` <video:duration>${vid.duration}</video:duration>\\n`;\n if (vid.expirationDate)\n xml += ` <video:expiration_date>${escapeXml(vid.expirationDate)}</video:expiration_date>\\n`;\n if (vid.rating !== undefined) xml += ` <video:rating>${vid.rating}</video:rating>\\n`;\n if (vid.viewCount !== undefined)\n xml += ` <video:view_count>${vid.viewCount}</video:view_count>\\n`;\n if (vid.publicationDate)\n xml += ` <video:publication_date>${escapeXml(vid.publicationDate)}</video:publication_date>\\n`;\n if (vid.familyFriendly !== undefined)\n xml += ` <video:family_friendly>${vid.familyFriendly ? 'yes' : 'no'}</video:family_friendly>\\n`;\n if (vid.live !== undefined)\n xml += ` <video:live>${vid.live ? 'yes' : 'no'}</video:live>\\n`;\n xml += ' </video:video>\\n';\n return xml;\n })\n .join('');\n}\n\nfunction buildNewsXml(news: SitemapNews): string {\n let xml = ' <news:news>\\n';\n xml += ' <news:publication>\\n';\n xml += ` <news:name>${escapeXml(news.publication.name)}</news:name>\\n`;\n xml += ` <news:language>${escapeXml(news.publication.language)}</news:language>\\n`;\n xml += ' </news:publication>\\n';\n xml += ` <news:publication_date>${escapeXml(news.publicationDate)}</news:publication_date>\\n`;\n xml += ` <news:title>${escapeXml(news.title)}</news:title>\\n`;\n xml += ' </news:news>\\n';\n return xml;\n}\n\nfunction buildUrlXml(url: SitemapURL, hostname: string): string {\n const loc = url.loc.startsWith('http')\n ? url.loc\n : normalizeUrl(`${hostname}${url.loc.startsWith('/') ? '' : '/'}${url.loc}`);\n\n let xml = ' <url>\\n';\n xml += ` <loc>${escapeXml(loc)}</loc>\\n`;\n if (url.lastmod) xml += ` <lastmod>${escapeXml(url.lastmod)}</lastmod>\\n`;\n if (url.changefreq) xml += ` <changefreq>${url.changefreq}</changefreq>\\n`;\n if (url.priority !== undefined) xml += ` <priority>${url.priority.toFixed(1)}</priority>\\n`;\n if (url.images && url.images.length > 0) xml += buildImageXml(url.images);\n if (url.videos && url.videos.length > 0) xml += buildVideoXml(url.videos);\n if (url.news) xml += buildNewsXml(url.news);\n xml += ' </url>\\n';\n return xml;\n}\n\n/**\n * Generate an XML sitemap string from a sitemap configuration.\n *\n * @example\n * ```ts\n * const xml = generateSitemap({\n * hostname: 'https://example.com',\n * urls: [\n * { loc: '/', changefreq: 'daily', priority: 1.0 },\n * { loc: '/about', changefreq: 'monthly', priority: 0.8 },\n * ],\n * });\n * ```\n */\nexport function generateSitemap(config: SitemapConfig): string {\n const { hostname, urls } = config;\n const ns = detectNamespaces(urls);\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 if (ns.image) xml += '\\n xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"';\n if (ns.video) xml += '\\n xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\"';\n if (ns.news) xml += '\\n xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\"';\n xml += '>\\n';\n\n for (const url of urls) {\n xml += buildUrlXml(url, hostname);\n }\n\n xml += '</urlset>\\n';\n return xml;\n}\n","// ============================================================================\n// @power-seo/sitemap — Types\n// ============================================================================\n\nexport type {\n SitemapURL,\n SitemapImage,\n SitemapVideo,\n SitemapNews,\n SitemapConfig,\n} from '@power-seo/core';\n\n/** A sitemap entry in a sitemap index. */\nexport interface SitemapIndexEntry {\n loc: string;\n lastmod?: string;\n}\n\n/** Configuration for the sitemap index generator. */\nexport interface SitemapIndexConfig {\n sitemaps: SitemapIndexEntry[];\n}\n\n/** Result of URL validation. */\nexport interface SitemapValidationResult {\n valid: boolean;\n errors: string[];\n warnings: string[];\n}\n\n/** Maximum URLs allowed per sitemap file. */\nexport const MAX_URLS_PER_SITEMAP = 50_000 as const;\n\n/** Maximum sitemap file size in bytes (50MB). */\nexport const MAX_SITEMAP_SIZE_BYTES = 52_428_800 as const;\n","// ============================================================================\n// @power-seo/sitemap — Sitemap Index Generator\n// ============================================================================\n\nimport type { SitemapConfig } from '@power-seo/core';\nimport type { SitemapIndexConfig, SitemapIndexEntry } from './types.js';\nimport { MAX_URLS_PER_SITEMAP } from './types.js';\nimport { generateSitemap } from './generator.js';\n\n/** Escape special XML characters. */\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&apos;');\n}\n\n/**\n * Generate a sitemap index XML string.\n *\n * @example\n * ```ts\n * const indexXml = generateSitemapIndex({\n * sitemaps: [\n * { loc: 'https://example.com/sitemap-0.xml', lastmod: '2024-01-01' },\n * { loc: 'https://example.com/sitemap-1.xml', lastmod: '2024-01-01' },\n * ],\n * });\n * ```\n */\nexport function generateSitemapIndex(config: SitemapIndexConfig): string {\n let xml = '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n';\n xml += '<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\\n';\n\n for (const sitemap of config.sitemaps) {\n xml += ' <sitemap>\\n';\n xml += ` <loc>${escapeXml(sitemap.loc)}</loc>\\n`;\n if (sitemap.lastmod) {\n xml += ` <lastmod>${escapeXml(sitemap.lastmod)}</lastmod>\\n`;\n }\n xml += ' </sitemap>\\n';\n }\n\n xml += '</sitemapindex>\\n';\n return xml;\n}\n\n/**\n * Split a large sitemap config into multiple sitemaps + an index.\n *\n * When a site has more than 50,000 URLs, this function splits them into\n * multiple sitemap files and returns both the individual sitemaps and\n * the index that references them.\n *\n * @example\n * ```ts\n * const { index, sitemaps } = splitSitemap({\n * hostname: 'https://example.com',\n * urls: largeUrlArray,\n * });\n * // sitemaps[0].xml, sitemaps[1].xml, etc.\n * // index = sitemap index XML\n * ```\n */\nexport function splitSitemap(\n config: SitemapConfig,\n sitemapUrlPattern = '/sitemap-{index}.xml',\n): { index: string; sitemaps: Array<{ filename: string; xml: string }> } {\n const maxPerSitemap = config.maxUrlsPerSitemap ?? MAX_URLS_PER_SITEMAP;\n const { hostname, urls } = config;\n\n if (urls.length <= maxPerSitemap) {\n const xml = generateSitemap(config);\n const filename = sitemapUrlPattern.replace('{index}', '0');\n const indexEntries: SitemapIndexEntry[] = [{ loc: `${hostname}${filename}` }];\n return {\n index: generateSitemapIndex({ sitemaps: indexEntries }),\n sitemaps: [{ filename, xml }],\n };\n }\n\n const sitemaps: Array<{ filename: string; xml: string }> = [];\n const indexEntries: SitemapIndexEntry[] = [];\n\n for (let i = 0; i < urls.length; i += maxPerSitemap) {\n const chunk = urls.slice(i, i + maxPerSitemap);\n const chunkIndex = Math.floor(i / maxPerSitemap);\n const filename = sitemapUrlPattern.replace('{index}', String(chunkIndex));\n const xml = generateSitemap({ hostname, urls: chunk });\n\n sitemaps.push({ filename, xml });\n indexEntries.push({ loc: `${hostname}${filename}` });\n }\n\n return {\n index: generateSitemapIndex({ sitemaps: indexEntries }),\n sitemaps,\n };\n}\n","// ============================================================================\n// @power-seo/sitemap — Streaming Sitemap Generator\n// ============================================================================\n\nimport type { SitemapURL } from '@power-seo/core';\nimport { normalizeUrl } from '@power-seo/core';\n\n/** Escape special XML characters. */\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&apos;');\n}\n\n/**\n * A streaming sitemap generator that yields XML chunks.\n *\n * Useful for server responses where you want to stream the sitemap\n * instead of building the entire XML string in memory.\n *\n * @example\n * ```ts\n * const stream = streamSitemap('https://example.com', urls);\n * for (const chunk of stream) {\n * response.write(chunk);\n * }\n * ```\n */\nexport function* streamSitemap(\n hostname: string,\n urls: Iterable<SitemapURL>,\n): Generator<string, void, undefined> {\n yield '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n';\n yield '<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\\n';\n yield ' xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"\\n';\n yield ' xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\"\\n';\n yield ' xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\">\\n';\n\n for (const url of urls) {\n const loc = url.loc.startsWith('http')\n ? url.loc\n : normalizeUrl(`${hostname}${url.loc.startsWith('/') ? '' : '/'}${url.loc}`);\n\n yield ' <url>\\n';\n yield ` <loc>${escapeXml(loc)}</loc>\\n`;\n\n if (url.lastmod) yield ` <lastmod>${escapeXml(url.lastmod)}</lastmod>\\n`;\n if (url.changefreq) yield ` <changefreq>${url.changefreq}</changefreq>\\n`;\n if (url.priority !== undefined) yield ` <priority>${url.priority.toFixed(1)}</priority>\\n`;\n\n // Images\n if (url.images) {\n for (const img of url.images) {\n yield ' <image:image>\\n';\n yield ` <image:loc>${escapeXml(img.loc)}</image:loc>\\n`;\n if (img.caption) yield ` <image:caption>${escapeXml(img.caption)}</image:caption>\\n`;\n if (img.title) yield ` <image:title>${escapeXml(img.title)}</image:title>\\n`;\n yield ' </image:image>\\n';\n }\n }\n\n // Videos\n if (url.videos) {\n for (const vid of url.videos) {\n yield ' <video:video>\\n';\n yield ` <video:thumbnail_loc>${escapeXml(vid.thumbnailLoc)}</video:thumbnail_loc>\\n`;\n yield ` <video:title>${escapeXml(vid.title)}</video:title>\\n`;\n yield ` <video:description>${escapeXml(vid.description)}</video:description>\\n`;\n if (vid.contentLoc)\n yield ` <video:content_loc>${escapeXml(vid.contentLoc)}</video:content_loc>\\n`;\n if (vid.playerLoc)\n yield ` <video:player_loc>${escapeXml(vid.playerLoc)}</video:player_loc>\\n`;\n yield ' </video:video>\\n';\n }\n }\n\n // News\n if (url.news) {\n yield ' <news:news>\\n';\n yield ' <news:publication>\\n';\n yield ` <news:name>${escapeXml(url.news.publication.name)}</news:name>\\n`;\n yield ` <news:language>${escapeXml(url.news.publication.language)}</news:language>\\n`;\n yield ' </news:publication>\\n';\n yield ` <news:publication_date>${escapeXml(url.news.publicationDate)}</news:publication_date>\\n`;\n yield ` <news:title>${escapeXml(url.news.title)}</news:title>\\n`;\n yield ' </news:news>\\n';\n }\n\n yield ' </url>\\n';\n }\n\n yield '</urlset>\\n';\n}\n","// ============================================================================\n// @power-seo/sitemap — URL Validation\n// ============================================================================\n\nimport type { SitemapURL } from '@power-seo/core';\nimport { isAbsoluteUrl, MAX_URL_LENGTH } from '@power-seo/core';\nimport type { SitemapValidationResult } from './types.js';\n\nconst VALID_CHANGEFREQ = ['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'];\n\n/**\n * Validate a sitemap URL entry against the sitemap protocol spec.\n */\nexport function validateSitemapUrl(url: SitemapURL): SitemapValidationResult {\n const errors: string[] = [];\n const warnings: string[] = [];\n\n // loc is required\n if (!url.loc || url.loc.trim().length === 0) {\n errors.push('URL \"loc\" is required and cannot be empty.');\n } else {\n if (!isAbsoluteUrl(url.loc)) {\n errors.push(`URL \"${url.loc}\" must be an absolute URL (starting with http:// or https://).`);\n }\n\n if (url.loc.length > 2048) {\n errors.push(`URL \"${url.loc}\" exceeds the maximum length of 2048 characters.`);\n }\n\n if (url.loc.length > MAX_URL_LENGTH) {\n warnings.push(\n `URL \"${url.loc}\" is ${url.loc.length} characters. URLs under ${MAX_URL_LENGTH} characters are recommended for SEO.`,\n );\n }\n }\n\n // lastmod validation\n if (url.lastmod) {\n const dateRegex = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}(:\\d{2})?([+-]\\d{2}:\\d{2}|Z)?)?$/;\n if (!dateRegex.test(url.lastmod)) {\n errors.push(\n `\"lastmod\" value \"${url.lastmod}\" is not a valid W3C datetime format (YYYY-MM-DD or ISO 8601).`,\n );\n }\n }\n\n // changefreq validation\n if (url.changefreq && !VALID_CHANGEFREQ.includes(url.changefreq)) {\n errors.push(\n `\"changefreq\" value \"${url.changefreq}\" is invalid. Must be one of: ${VALID_CHANGEFREQ.join(', ')}.`,\n );\n }\n\n // priority validation\n if (url.priority !== undefined) {\n if (url.priority < 0 || url.priority > 1) {\n errors.push(`\"priority\" value ${url.priority} is out of range. Must be between 0.0 and 1.0.`);\n }\n }\n\n // Image validation\n if (url.images) {\n for (let i = 0; i < url.images.length; i++) {\n const img = url.images[i]!;\n if (!img.loc || img.loc.trim().length === 0) {\n errors.push(`Image ${i + 1}: \"loc\" is required.`);\n } else if (!isAbsoluteUrl(img.loc)) {\n errors.push(`Image ${i + 1}: \"${img.loc}\" must be an absolute URL.`);\n }\n }\n if (url.images.length > 1000) {\n warnings.push(\n `URL has ${url.images.length} images. Google supports up to 1,000 images per page.`,\n );\n }\n }\n\n // Video validation\n if (url.videos) {\n for (let i = 0; i < url.videos.length; i++) {\n const vid = url.videos[i]!;\n if (!vid.title) errors.push(`Video ${i + 1}: \"title\" is required.`);\n if (!vid.description) errors.push(`Video ${i + 1}: \"description\" is required.`);\n if (!vid.thumbnailLoc) errors.push(`Video ${i + 1}: \"thumbnailLoc\" is required.`);\n if (!vid.contentLoc && !vid.playerLoc) {\n errors.push(`Video ${i + 1}: either \"contentLoc\" or \"playerLoc\" must be provided.`);\n }\n if (vid.rating !== undefined && (vid.rating < 0 || vid.rating > 5)) {\n errors.push(`Video ${i + 1}: \"rating\" must be between 0.0 and 5.0.`);\n }\n }\n }\n\n // News validation\n if (url.news) {\n if (!url.news.publication?.name) errors.push('News: \"publication.name\" is required.');\n if (!url.news.publication?.language) errors.push('News: \"publication.language\" is required.');\n if (!url.news.publicationDate) errors.push('News: \"publicationDate\" is required.');\n if (!url.news.title) errors.push('News: \"title\" is required.');\n }\n\n return {\n valid: errors.length === 0,\n errors,\n warnings,\n };\n}\n","// ============================================================================\n// @power-seo/sitemap — Next.js App Router Adapter\n// ============================================================================\n\nimport type { SitemapURL } from '@power-seo/core';\nimport { validateSitemapUrl } from './validate.js';\n\n/**\n * A plain object that matches the shape of Next.js `MetadataRoute.Sitemap[number]`.\n * Typed locally so `@power-seo/sitemap` has no dependency on `next`.\n */\nexport interface NextSitemapEntry {\n url: string;\n lastModified?: string | Date;\n changeFrequency?:\n | 'always'\n | 'hourly'\n | 'daily'\n | 'weekly'\n | 'monthly'\n | 'yearly'\n | 'never';\n priority?: number;\n alternates?: {\n languages?: Record<string, string>;\n };\n}\n\n/**\n * Convert an array of `SitemapURL` objects to a Next.js-compatible sitemap array.\n *\n * Use this in `app/sitemap.ts` to bridge `@power-seo/sitemap` with Next.js's\n * built-in `MetadataRoute.Sitemap` convention.\n *\n * @example\n * ```ts\n * // app/sitemap.ts\n * import type { MetadataRoute } from 'next';\n * import { toNextSitemap } from '@power-seo/sitemap';\n *\n * export default async function sitemap(): Promise<MetadataRoute.Sitemap> {\n * const urls = [\n * { loc: 'https://example.com', changefreq: 'daily', priority: 1.0 },\n * { loc: 'https://example.com/about', changefreq: 'monthly', priority: 0.8 },\n * ];\n * return toNextSitemap(urls) as MetadataRoute.Sitemap;\n * }\n * ```\n */\nexport function toNextSitemap(urls: SitemapURL[]): NextSitemapEntry[] {\n const entries: NextSitemapEntry[] = [];\n\n for (const url of urls) {\n const { valid } = validateSitemapUrl(url);\n if (!valid) continue;\n\n const entry: NextSitemapEntry = { url: url.loc };\n\n if (url.lastmod) {\n entry.lastModified = url.lastmod;\n }\n\n if (url.changefreq) {\n entry.changeFrequency = url.changefreq as NextSitemapEntry['changeFrequency'];\n }\n\n if (url.priority !== undefined) {\n entry.priority = url.priority;\n }\n\n entries.push(entry);\n }\n\n return entries;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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yC;AAAA,MACrE;AAAA,IACF;AAAA,EACF;AAGA,MAAI,IAAI,MAAM;AACZ,QAAI,CAAC,IAAI,KAAK,aAAa,KAAM,QAAO,KAAK,uCAAuC;AACpF,QAAI,CAAC,IAAI,KAAK,aAAa,SAAU,QAAO,KAAK,2CAA2C;AAC5F,QAAI,CAAC,IAAI,KAAK,gBAAiB,QAAO,KAAK,sCAAsC;AACjF,QAAI,CAAC,IAAI,KAAK,MAAO,QAAO,KAAK,4BAA4B;AAAA,EAC/D;AAEA,SAAO;AAAA,IACL,OAAO,OAAO,WAAW;AAAA,IACzB;AAAA,IACA;AAAA,EACF;AACF;;;ACzDO,SAAS,cAAc,MAAwC;AACpE,QAAM,UAA8B,CAAC;AAErC,aAAW,OAAO,MAAM;AACtB,UAAM,EAAE,MAAM,IAAI,mBAAmB,GAAG;AACxC,QAAI,CAAC,MAAO;AAEZ,UAAM,QAA0B,EAAE,KAAK,IAAI,IAAI;AAE/C,QAAI,IAAI,SAAS;AACf,YAAM,eAAe,IAAI;AAAA,IAC3B;AAEA,QAAI,IAAI,YAAY;AAClB,YAAM,kBAAkB,IAAI;AAAA,IAC9B;AAEA,QAAI,IAAI,aAAa,QAAW;AAC9B,YAAM,WAAW,IAAI;AAAA,IACvB;AAEA,YAAQ,KAAK,KAAK;AAAA,EACpB;AAEA,SAAO;AACT;","names":["escapeXml","indexEntries","import_core","escapeXml","import_core"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/generator.ts","../src/types.ts","../src/sitemap-index.ts","../src/stream.ts","../src/validate.ts","../src/next-adapter.ts"],"sourcesContent":["// @power-seo/sitemap — Public API\n// ----------------------------------------------------------------------------\n\nexport { generateSitemap } from './generator.js';\nexport { generateSitemapIndex, splitSitemap } from './sitemap-index.js';\nexport { streamSitemap } from './stream.js';\nexport { validateSitemapUrl } from './validate.js';\nexport { toNextSitemap } from './next-adapter.js';\nexport type { NextSitemapEntry } from './next-adapter.js';\n\nexport type {\n SitemapURL,\n SitemapImage,\n SitemapVideo,\n SitemapNews,\n SitemapConfig,\n SitemapIndexEntry,\n SitemapIndexConfig,\n SitemapValidationResult,\n} from './types.js';\n\nexport { MAX_URLS_PER_SITEMAP, MAX_SITEMAP_SIZE_BYTES } from './types.js';\n","// @power-seo/sitemap — XML Sitemap Generator\n// ----------------------------------------------------------------------------\n\nimport type {\n SitemapConfig,\n SitemapURL,\n SitemapImage,\n SitemapVideo,\n SitemapNews,\n} from '@power-seo/core';\nimport { normalizeUrl } from '@power-seo/core';\n\n/** Escape special XML characters. */\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&apos;');\n}\n\n/** Determine which namespace extensions are needed. */\nfunction detectNamespaces(urls: SitemapURL[]): { image: boolean; video: boolean; news: boolean } {\n let image = false;\n let video = false;\n let news = false;\n for (const url of urls) {\n if (url.images && url.images.length > 0) image = true;\n if (url.videos && url.videos.length > 0) video = true;\n if (url.news) news = true;\n if (image && video && news) break;\n }\n return { image, video, news };\n}\n\nfunction buildImageXml(images: SitemapImage[]): string {\n return images\n .map((img) => {\n let xml = ' <image:image>\\n';\n xml += ` <image:loc>${escapeXml(img.loc)}</image:loc>\\n`;\n if (img.caption) xml += ` <image:caption>${escapeXml(img.caption)}</image:caption>\\n`;\n if (img.geoLocation)\n xml += ` <image:geo_location>${escapeXml(img.geoLocation)}</image:geo_location>\\n`;\n if (img.title) xml += ` <image:title>${escapeXml(img.title)}</image:title>\\n`;\n if (img.license) xml += ` <image:license>${escapeXml(img.license)}</image:license>\\n`;\n xml += ' </image:image>\\n';\n return xml;\n })\n .join('');\n}\n\nfunction buildVideoXml(videos: SitemapVideo[]): string {\n return videos\n .map((vid) => {\n let xml = ' <video:video>\\n';\n xml += ` <video:thumbnail_loc>${escapeXml(vid.thumbnailLoc)}</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 if (vid.contentLoc)\n xml += ` <video:content_loc>${escapeXml(vid.contentLoc)}</video:content_loc>\\n`;\n if (vid.playerLoc)\n xml += ` <video:player_loc>${escapeXml(vid.playerLoc)}</video:player_loc>\\n`;\n if (vid.duration !== undefined)\n xml += ` <video:duration>${vid.duration}</video:duration>\\n`;\n if (vid.expirationDate)\n xml += ` <video:expiration_date>${escapeXml(vid.expirationDate)}</video:expiration_date>\\n`;\n if (vid.rating !== undefined) xml += ` <video:rating>${vid.rating}</video:rating>\\n`;\n if (vid.viewCount !== undefined)\n xml += ` <video:view_count>${vid.viewCount}</video:view_count>\\n`;\n if (vid.publicationDate)\n xml += ` <video:publication_date>${escapeXml(vid.publicationDate)}</video:publication_date>\\n`;\n if (vid.familyFriendly !== undefined)\n xml += ` <video:family_friendly>${vid.familyFriendly ? 'yes' : 'no'}</video:family_friendly>\\n`;\n if (vid.live !== undefined)\n xml += ` <video:live>${vid.live ? 'yes' : 'no'}</video:live>\\n`;\n xml += ' </video:video>\\n';\n return xml;\n })\n .join('');\n}\n\nfunction buildNewsXml(news: SitemapNews): string {\n let xml = ' <news:news>\\n';\n xml += ' <news:publication>\\n';\n xml += ` <news:name>${escapeXml(news.publication.name)}</news:name>\\n`;\n xml += ` <news:language>${escapeXml(news.publication.language)}</news:language>\\n`;\n xml += ' </news:publication>\\n';\n xml += ` <news:publication_date>${escapeXml(news.publicationDate)}</news:publication_date>\\n`;\n xml += ` <news:title>${escapeXml(news.title)}</news:title>\\n`;\n xml += ' </news:news>\\n';\n return xml;\n}\n\nfunction buildUrlXml(url: SitemapURL, hostname: string): string {\n const loc = url.loc.startsWith('http')\n ? url.loc\n : normalizeUrl(`${hostname}${url.loc.startsWith('/') ? '' : '/'}${url.loc}`);\n\n let xml = ' <url>\\n';\n xml += ` <loc>${escapeXml(loc)}</loc>\\n`;\n if (url.lastmod) xml += ` <lastmod>${escapeXml(url.lastmod)}</lastmod>\\n`;\n if (url.changefreq) xml += ` <changefreq>${url.changefreq}</changefreq>\\n`;\n if (url.priority !== undefined) xml += ` <priority>${url.priority.toFixed(1)}</priority>\\n`;\n if (url.images && url.images.length > 0) xml += buildImageXml(url.images);\n if (url.videos && url.videos.length > 0) xml += buildVideoXml(url.videos);\n if (url.news) xml += buildNewsXml(url.news);\n xml += ' </url>\\n';\n return xml;\n}\n\n/**\n * Generate an XML sitemap string from a sitemap configuration.\n *\n * @example\n * ```ts\n * const xml = generateSitemap({\n * hostname: 'https://example.com',\n * urls: [\n * { loc: '/', changefreq: 'daily', priority: 1.0 },\n * { loc: '/about', changefreq: 'monthly', priority: 0.8 },\n * ],\n * });\n * ```\n */\nexport function generateSitemap(config: SitemapConfig): string {\n const { hostname, urls } = config;\n const ns = detectNamespaces(urls);\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 if (ns.image) xml += '\\n xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"';\n if (ns.video) xml += '\\n xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\"';\n if (ns.news) xml += '\\n xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\"';\n xml += '>\\n';\n\n for (const url of urls) {\n xml += buildUrlXml(url, hostname);\n }\n\n xml += '</urlset>\\n';\n return xml;\n}\n","// @power-seo/sitemap — Types\n// ----------------------------------------------------------------------------\n\nexport type {\n SitemapURL,\n SitemapImage,\n SitemapVideo,\n SitemapNews,\n SitemapConfig,\n} from '@power-seo/core';\n\n/** A sitemap entry in a sitemap index. */\nexport interface SitemapIndexEntry {\n loc: string;\n lastmod?: string;\n}\n\n/** Configuration for the sitemap index generator. */\nexport interface SitemapIndexConfig {\n sitemaps: SitemapIndexEntry[];\n}\n\n/** Result of URL validation. */\nexport interface SitemapValidationResult {\n valid: boolean;\n errors: string[];\n warnings: string[];\n}\n\n/** Maximum URLs allowed per sitemap file. */\nexport const MAX_URLS_PER_SITEMAP = 50_000 as const;\n\n/** Maximum sitemap file size in bytes (50MB). */\nexport const MAX_SITEMAP_SIZE_BYTES = 52_428_800 as const;\n","// @power-seo/sitemap — Sitemap Index Generator\n// ----------------------------------------------------------------------------\n\nimport type { SitemapConfig } from '@power-seo/core';\nimport type { SitemapIndexConfig, SitemapIndexEntry } from './types.js';\nimport { MAX_URLS_PER_SITEMAP } from './types.js';\nimport { generateSitemap } from './generator.js';\n\n/** Escape special XML characters. */\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&apos;');\n}\n\n/**\n * Generate a sitemap index XML string.\n *\n * @example\n * ```ts\n * const indexXml = generateSitemapIndex({\n * sitemaps: [\n * { loc: 'https://example.com/sitemap-0.xml', lastmod: '2024-01-01' },\n * { loc: 'https://example.com/sitemap-1.xml', lastmod: '2024-01-01' },\n * ],\n * });\n * ```\n */\nexport function generateSitemapIndex(config: SitemapIndexConfig): string {\n let xml = '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n';\n xml += '<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\\n';\n\n for (const sitemap of config.sitemaps) {\n xml += ' <sitemap>\\n';\n xml += ` <loc>${escapeXml(sitemap.loc)}</loc>\\n`;\n if (sitemap.lastmod) {\n xml += ` <lastmod>${escapeXml(sitemap.lastmod)}</lastmod>\\n`;\n }\n xml += ' </sitemap>\\n';\n }\n\n xml += '</sitemapindex>\\n';\n return xml;\n}\n\n/**\n * Split a large sitemap config into multiple sitemaps + an index.\n *\n * When a site has more than 50,000 URLs, this function splits them into\n * multiple sitemap files and returns both the individual sitemaps and\n * the index that references them.\n *\n * @example\n * ```ts\n * const { index, sitemaps } = splitSitemap({\n * hostname: 'https://example.com',\n * urls: largeUrlArray,\n * });\n * // sitemaps[0].xml, sitemaps[1].xml, etc.\n * // index = sitemap index XML\n * ```\n */\nexport function splitSitemap(\n config: SitemapConfig,\n sitemapUrlPattern = '/sitemap-{index}.xml',\n): { index: string; sitemaps: Array<{ filename: string; xml: string }> } {\n const maxPerSitemap = config.maxUrlsPerSitemap ?? MAX_URLS_PER_SITEMAP;\n const { hostname, urls } = config;\n\n if (urls.length <= maxPerSitemap) {\n const xml = generateSitemap(config);\n const filename = sitemapUrlPattern.replace('{index}', '0');\n const indexEntries: SitemapIndexEntry[] = [{ loc: `${hostname}${filename}` }];\n return {\n index: generateSitemapIndex({ sitemaps: indexEntries }),\n sitemaps: [{ filename, xml }],\n };\n }\n\n const sitemaps: Array<{ filename: string; xml: string }> = [];\n const indexEntries: SitemapIndexEntry[] = [];\n\n for (let i = 0; i < urls.length; i += maxPerSitemap) {\n const chunk = urls.slice(i, i + maxPerSitemap);\n const chunkIndex = Math.floor(i / maxPerSitemap);\n const filename = sitemapUrlPattern.replace('{index}', String(chunkIndex));\n const xml = generateSitemap({ hostname, urls: chunk });\n\n sitemaps.push({ filename, xml });\n indexEntries.push({ loc: `${hostname}${filename}` });\n }\n\n return {\n index: generateSitemapIndex({ sitemaps: indexEntries }),\n sitemaps,\n };\n}\n","// @power-seo/sitemap — Streaming Sitemap Generator\n// ----------------------------------------------------------------------------\n\nimport type { SitemapURL } from '@power-seo/core';\nimport { normalizeUrl } from '@power-seo/core';\n\n/** Escape special XML characters. */\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&apos;');\n}\n\n/**\n * A streaming sitemap generator that yields XML chunks.\n *\n * Useful for server responses where you want to stream the sitemap\n * instead of building the entire XML string in memory.\n *\n * @example\n * ```ts\n * const stream = streamSitemap('https://example.com', urls);\n * for (const chunk of stream) {\n * response.write(chunk);\n * }\n * ```\n */\nexport function* streamSitemap(\n hostname: string,\n urls: Iterable<SitemapURL>,\n): Generator<string, void, undefined> {\n yield '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n';\n yield '<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\\n';\n yield ' xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"\\n';\n yield ' xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\"\\n';\n yield ' xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\">\\n';\n\n for (const url of urls) {\n const loc = url.loc.startsWith('http')\n ? url.loc\n : normalizeUrl(`${hostname}${url.loc.startsWith('/') ? '' : '/'}${url.loc}`);\n\n yield ' <url>\\n';\n yield ` <loc>${escapeXml(loc)}</loc>\\n`;\n\n if (url.lastmod) yield ` <lastmod>${escapeXml(url.lastmod)}</lastmod>\\n`;\n if (url.changefreq) yield ` <changefreq>${url.changefreq}</changefreq>\\n`;\n if (url.priority !== undefined) yield ` <priority>${url.priority.toFixed(1)}</priority>\\n`;\n\n // Images\n if (url.images) {\n for (const img of url.images) {\n yield ' <image:image>\\n';\n yield ` <image:loc>${escapeXml(img.loc)}</image:loc>\\n`;\n if (img.caption) yield ` <image:caption>${escapeXml(img.caption)}</image:caption>\\n`;\n if (img.title) yield ` <image:title>${escapeXml(img.title)}</image:title>\\n`;\n yield ' </image:image>\\n';\n }\n }\n\n // Videos\n if (url.videos) {\n for (const vid of url.videos) {\n yield ' <video:video>\\n';\n yield ` <video:thumbnail_loc>${escapeXml(vid.thumbnailLoc)}</video:thumbnail_loc>\\n`;\n yield ` <video:title>${escapeXml(vid.title)}</video:title>\\n`;\n yield ` <video:description>${escapeXml(vid.description)}</video:description>\\n`;\n if (vid.contentLoc)\n yield ` <video:content_loc>${escapeXml(vid.contentLoc)}</video:content_loc>\\n`;\n if (vid.playerLoc)\n yield ` <video:player_loc>${escapeXml(vid.playerLoc)}</video:player_loc>\\n`;\n yield ' </video:video>\\n';\n }\n }\n\n // News\n if (url.news) {\n yield ' <news:news>\\n';\n yield ' <news:publication>\\n';\n yield ` <news:name>${escapeXml(url.news.publication.name)}</news:name>\\n`;\n yield ` <news:language>${escapeXml(url.news.publication.language)}</news:language>\\n`;\n yield ' </news:publication>\\n';\n yield ` <news:publication_date>${escapeXml(url.news.publicationDate)}</news:publication_date>\\n`;\n yield ` <news:title>${escapeXml(url.news.title)}</news:title>\\n`;\n yield ' </news:news>\\n';\n }\n\n yield ' </url>\\n';\n }\n\n yield '</urlset>\\n';\n}\n","// @power-seo/sitemap — URL Validation\n// ----------------------------------------------------------------------------\n\nimport type { SitemapURL } from '@power-seo/core';\nimport { isAbsoluteUrl, MAX_URL_LENGTH } from '@power-seo/core';\nimport type { SitemapValidationResult } from './types.js';\n\nconst VALID_CHANGEFREQ = ['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'];\n\n/**\n * Validate a sitemap URL entry against the sitemap protocol spec.\n */\nexport function validateSitemapUrl(url: SitemapURL): SitemapValidationResult {\n const errors: string[] = [];\n const warnings: string[] = [];\n\n // loc is required\n if (!url.loc || url.loc.trim().length === 0) {\n errors.push('URL \"loc\" is required and cannot be empty.');\n } else {\n if (!isAbsoluteUrl(url.loc)) {\n errors.push(`URL \"${url.loc}\" must be an absolute URL (starting with http:// or https://).`);\n }\n\n if (url.loc.length > 2048) {\n errors.push(`URL \"${url.loc}\" exceeds the maximum length of 2048 characters.`);\n }\n\n if (url.loc.length > MAX_URL_LENGTH) {\n warnings.push(\n `URL \"${url.loc}\" is ${url.loc.length} characters. URLs under ${MAX_URL_LENGTH} characters are recommended for SEO.`,\n );\n }\n }\n\n // lastmod validation\n if (url.lastmod) {\n const dateRegex = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}(:\\d{2})?([+-]\\d{2}:\\d{2}|Z)?)?$/;\n if (!dateRegex.test(url.lastmod)) {\n errors.push(\n `\"lastmod\" value \"${url.lastmod}\" is not a valid W3C datetime format (YYYY-MM-DD or ISO 8601).`,\n );\n }\n }\n\n // changefreq validation\n if (url.changefreq && !VALID_CHANGEFREQ.includes(url.changefreq)) {\n errors.push(\n `\"changefreq\" value \"${url.changefreq}\" is invalid. Must be one of: ${VALID_CHANGEFREQ.join(', ')}.`,\n );\n }\n\n // priority validation\n if (url.priority !== undefined) {\n if (url.priority < 0 || url.priority > 1) {\n errors.push(`\"priority\" value ${url.priority} is out of range. Must be between 0.0 and 1.0.`);\n }\n }\n\n // Image validation\n if (url.images) {\n for (let i = 0; i < url.images.length; i++) {\n const img = url.images[i]!;\n if (!img.loc || img.loc.trim().length === 0) {\n errors.push(`Image ${i + 1}: \"loc\" is required.`);\n } else if (!isAbsoluteUrl(img.loc)) {\n errors.push(`Image ${i + 1}: \"${img.loc}\" must be an absolute URL.`);\n }\n }\n if (url.images.length > 1000) {\n warnings.push(\n `URL has ${url.images.length} images. Google supports up to 1,000 images per page.`,\n );\n }\n }\n\n // Video validation\n if (url.videos) {\n for (let i = 0; i < url.videos.length; i++) {\n const vid = url.videos[i]!;\n if (!vid.title) errors.push(`Video ${i + 1}: \"title\" is required.`);\n if (!vid.description) errors.push(`Video ${i + 1}: \"description\" is required.`);\n if (!vid.thumbnailLoc) errors.push(`Video ${i + 1}: \"thumbnailLoc\" is required.`);\n if (!vid.contentLoc && !vid.playerLoc) {\n errors.push(`Video ${i + 1}: either \"contentLoc\" or \"playerLoc\" must be provided.`);\n }\n if (vid.rating !== undefined && (vid.rating < 0 || vid.rating > 5)) {\n errors.push(`Video ${i + 1}: \"rating\" must be between 0.0 and 5.0.`);\n }\n }\n }\n\n // News validation\n if (url.news) {\n if (!url.news.publication?.name) errors.push('News: \"publication.name\" is required.');\n if (!url.news.publication?.language) errors.push('News: \"publication.language\" is required.');\n if (!url.news.publicationDate) errors.push('News: \"publicationDate\" is required.');\n if (!url.news.title) errors.push('News: \"title\" is required.');\n }\n\n return {\n valid: errors.length === 0,\n errors,\n warnings,\n };\n}\n","// @power-seo/sitemap — Next.js App Router Adapter\n\n\nimport type { SitemapURL } from '@power-seo/core';\nimport { validateSitemapUrl } from './validate.js';\n\n/** Plain object matching the shape of Next.js `MetadataRoute.Sitemap[number]`. */\nexport interface NextSitemapEntry {\n url: string;\n lastModified?: string | Date;\n changeFrequency?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';\n priority?: number;\n}\n\n/**\n * Convert `SitemapURL[]` to a plain array compatible with Next.js `MetadataRoute.Sitemap`.\n *\n * @example\n * ```ts\n * // app/sitemap.ts\n * import { toNextSitemap } from '@power-seo/sitemap';\n * export default async function sitemap() {\n * return toNextSitemap(urls) as MetadataRoute.Sitemap;\n * }\n * ```\n */\nexport function toNextSitemap(urls: SitemapURL[]): NextSitemapEntry[] {\n const entries: NextSitemapEntry[] = [];\n for (const url of urls) {\n const { valid } = validateSitemapUrl(url);\n if (!valid) continue;\n const entry: NextSitemapEntry = { url: url.loc };\n if (url.lastmod) entry.lastModified = url.lastmod;\n if (url.changefreq) entry.changeFrequency = url.changefreq as NextSitemapEntry['changeFrequency'];\n if (url.priority !== undefined) entry.priority = url.priority;\n entries.push(entry);\n }\n return entries;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACUA,kBAA6B;AAG7B,SAAS,UAAU,KAAqB;AACtC,SAAO,IACJ,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,QAAQ,EACtB,QAAQ,MAAM,QAAQ;AAC3B;AAGA,SAAS,iBAAiB,MAAuE;AAC/F,MAAI,QAAQ;AACZ,MAAI,QAAQ;AACZ,MAAI,OAAO;AACX,aAAW,OAAO,MAAM;AACtB,QAAI,IAAI,UAAU,IAAI,OAAO,SAAS,EAAG,SAAQ;AACjD,QAAI,IAAI,UAAU,IAAI,OAAO,SAAS,EAAG,SAAQ;AACjD,QAAI,IAAI,KAAM,QAAO;AACrB,QAAI,SAAS,SAAS,KAA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AM;AACtB,UAAM,EAAE,MAAM,IAAI,mBAAmB,GAAG;AACxC,QAAI,CAAC,MAAO;AACZ,UAAM,QAA0B,EAAE,KAAK,IAAI,IAAI;AAC/C,QAAI,IAAI,QAAS,OAAM,eAAe,IAAI;AAC1C,QAAI,IAAI,WAAY,OAAM,kBAAkB,IAAI;AAChD,QAAI,IAAI,aAAa,OAAW,OAAM,WAAW,IAAI;AACrD,YAAQ,KAAK,KAAK;AAAA,EACpB;AACA,SAAO;AACT;","names":["escapeXml","indexEntries","import_core","escapeXml","import_core"]}
package/dist/index.d.cts CHANGED
@@ -97,36 +97,21 @@ declare function streamSitemap(hostname: string, urls: Iterable<SitemapURL>): Ge
97
97
  */
98
98
  declare function validateSitemapUrl(url: SitemapURL): SitemapValidationResult;
99
99
 
100
- /**
101
- * A plain object that matches the shape of Next.js `MetadataRoute.Sitemap[number]`.
102
- * Typed locally so `@power-seo/sitemap` has no dependency on `next`.
103
- */
100
+ /** Plain object matching the shape of Next.js `MetadataRoute.Sitemap[number]`. */
104
101
  interface NextSitemapEntry {
105
102
  url: string;
106
103
  lastModified?: string | Date;
107
104
  changeFrequency?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
108
105
  priority?: number;
109
- alternates?: {
110
- languages?: Record<string, string>;
111
- };
112
106
  }
113
107
  /**
114
- * Convert an array of `SitemapURL` objects to a Next.js-compatible sitemap array.
115
- *
116
- * Use this in `app/sitemap.ts` to bridge `@power-seo/sitemap` with Next.js's
117
- * built-in `MetadataRoute.Sitemap` convention.
108
+ * Convert `SitemapURL[]` to a plain array compatible with Next.js `MetadataRoute.Sitemap`.
118
109
  *
119
110
  * @example
120
111
  * ```ts
121
112
  * // app/sitemap.ts
122
- * import type { MetadataRoute } from 'next';
123
113
  * import { toNextSitemap } from '@power-seo/sitemap';
124
- *
125
- * export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
126
- * const urls = [
127
- * { loc: 'https://example.com', changefreq: 'daily', priority: 1.0 },
128
- * { loc: 'https://example.com/about', changefreq: 'monthly', priority: 0.8 },
129
- * ];
114
+ * export default async function sitemap() {
130
115
  * return toNextSitemap(urls) as MetadataRoute.Sitemap;
131
116
  * }
132
117
  * ```
package/dist/index.d.ts CHANGED
@@ -97,36 +97,21 @@ declare function streamSitemap(hostname: string, urls: Iterable<SitemapURL>): Ge
97
97
  */
98
98
  declare function validateSitemapUrl(url: SitemapURL): SitemapValidationResult;
99
99
 
100
- /**
101
- * A plain object that matches the shape of Next.js `MetadataRoute.Sitemap[number]`.
102
- * Typed locally so `@power-seo/sitemap` has no dependency on `next`.
103
- */
100
+ /** Plain object matching the shape of Next.js `MetadataRoute.Sitemap[number]`. */
104
101
  interface NextSitemapEntry {
105
102
  url: string;
106
103
  lastModified?: string | Date;
107
104
  changeFrequency?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
108
105
  priority?: number;
109
- alternates?: {
110
- languages?: Record<string, string>;
111
- };
112
106
  }
113
107
  /**
114
- * Convert an array of `SitemapURL` objects to a Next.js-compatible sitemap array.
115
- *
116
- * Use this in `app/sitemap.ts` to bridge `@power-seo/sitemap` with Next.js's
117
- * built-in `MetadataRoute.Sitemap` convention.
108
+ * Convert `SitemapURL[]` to a plain array compatible with Next.js `MetadataRoute.Sitemap`.
118
109
  *
119
110
  * @example
120
111
  * ```ts
121
112
  * // app/sitemap.ts
122
- * import type { MetadataRoute } from 'next';
123
113
  * import { toNextSitemap } from '@power-seo/sitemap';
124
- *
125
- * export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
126
- * const urls = [
127
- * { loc: 'https://example.com', changefreq: 'daily', priority: 1.0 },
128
- * { loc: 'https://example.com/about', changefreq: 'monthly', priority: 0.8 },
129
- * ];
114
+ * export default async function sitemap() {
130
115
  * return toNextSitemap(urls) as MetadataRoute.Sitemap;
131
116
  * }
132
117
  * ```
package/dist/index.js CHANGED
@@ -331,15 +331,9 @@ function toNextSitemap(urls) {
331
331
  const { valid } = validateSitemapUrl(url);
332
332
  if (!valid) continue;
333
333
  const entry = { url: url.loc };
334
- if (url.lastmod) {
335
- entry.lastModified = url.lastmod;
336
- }
337
- if (url.changefreq) {
338
- entry.changeFrequency = url.changefreq;
339
- }
340
- if (url.priority !== void 0) {
341
- entry.priority = url.priority;
342
- }
334
+ if (url.lastmod) entry.lastModified = url.lastmod;
335
+ if (url.changefreq) entry.changeFrequency = url.changefreq;
336
+ if (url.priority !== void 0) entry.priority = url.priority;
343
337
  entries.push(entry);
344
338
  }
345
339
  return entries;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/generator.ts","../src/types.ts","../src/sitemap-index.ts","../src/stream.ts","../src/validate.ts","../src/next-adapter.ts"],"sourcesContent":["// ============================================================================\n// @power-seo/sitemap — XML Sitemap Generator\n// ============================================================================\n\nimport type {\n SitemapConfig,\n SitemapURL,\n SitemapImage,\n SitemapVideo,\n SitemapNews,\n} from '@power-seo/core';\nimport { normalizeUrl } from '@power-seo/core';\n\n/** Escape special XML characters. */\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&apos;');\n}\n\n/** Determine which namespace extensions are needed. */\nfunction detectNamespaces(urls: SitemapURL[]): { image: boolean; video: boolean; news: boolean } {\n let image = false;\n let video = false;\n let news = false;\n for (const url of urls) {\n if (url.images && url.images.length > 0) image = true;\n if (url.videos && url.videos.length > 0) video = true;\n if (url.news) news = true;\n if (image && video && news) break;\n }\n return { image, video, news };\n}\n\nfunction buildImageXml(images: SitemapImage[]): string {\n return images\n .map((img) => {\n let xml = ' <image:image>\\n';\n xml += ` <image:loc>${escapeXml(img.loc)}</image:loc>\\n`;\n if (img.caption) xml += ` <image:caption>${escapeXml(img.caption)}</image:caption>\\n`;\n if (img.geoLocation)\n xml += ` <image:geo_location>${escapeXml(img.geoLocation)}</image:geo_location>\\n`;\n if (img.title) xml += ` <image:title>${escapeXml(img.title)}</image:title>\\n`;\n if (img.license) xml += ` <image:license>${escapeXml(img.license)}</image:license>\\n`;\n xml += ' </image:image>\\n';\n return xml;\n })\n .join('');\n}\n\nfunction buildVideoXml(videos: SitemapVideo[]): string {\n return videos\n .map((vid) => {\n let xml = ' <video:video>\\n';\n xml += ` <video:thumbnail_loc>${escapeXml(vid.thumbnailLoc)}</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 if (vid.contentLoc)\n xml += ` <video:content_loc>${escapeXml(vid.contentLoc)}</video:content_loc>\\n`;\n if (vid.playerLoc)\n xml += ` <video:player_loc>${escapeXml(vid.playerLoc)}</video:player_loc>\\n`;\n if (vid.duration !== undefined)\n xml += ` <video:duration>${vid.duration}</video:duration>\\n`;\n if (vid.expirationDate)\n xml += ` <video:expiration_date>${escapeXml(vid.expirationDate)}</video:expiration_date>\\n`;\n if (vid.rating !== undefined) xml += ` <video:rating>${vid.rating}</video:rating>\\n`;\n if (vid.viewCount !== undefined)\n xml += ` <video:view_count>${vid.viewCount}</video:view_count>\\n`;\n if (vid.publicationDate)\n xml += ` <video:publication_date>${escapeXml(vid.publicationDate)}</video:publication_date>\\n`;\n if (vid.familyFriendly !== undefined)\n xml += ` <video:family_friendly>${vid.familyFriendly ? 'yes' : 'no'}</video:family_friendly>\\n`;\n if (vid.live !== undefined)\n xml += ` <video:live>${vid.live ? 'yes' : 'no'}</video:live>\\n`;\n xml += ' </video:video>\\n';\n return xml;\n })\n .join('');\n}\n\nfunction buildNewsXml(news: SitemapNews): string {\n let xml = ' <news:news>\\n';\n xml += ' <news:publication>\\n';\n xml += ` <news:name>${escapeXml(news.publication.name)}</news:name>\\n`;\n xml += ` <news:language>${escapeXml(news.publication.language)}</news:language>\\n`;\n xml += ' </news:publication>\\n';\n xml += ` <news:publication_date>${escapeXml(news.publicationDate)}</news:publication_date>\\n`;\n xml += ` <news:title>${escapeXml(news.title)}</news:title>\\n`;\n xml += ' </news:news>\\n';\n return xml;\n}\n\nfunction buildUrlXml(url: SitemapURL, hostname: string): string {\n const loc = url.loc.startsWith('http')\n ? url.loc\n : normalizeUrl(`${hostname}${url.loc.startsWith('/') ? '' : '/'}${url.loc}`);\n\n let xml = ' <url>\\n';\n xml += ` <loc>${escapeXml(loc)}</loc>\\n`;\n if (url.lastmod) xml += ` <lastmod>${escapeXml(url.lastmod)}</lastmod>\\n`;\n if (url.changefreq) xml += ` <changefreq>${url.changefreq}</changefreq>\\n`;\n if (url.priority !== undefined) xml += ` <priority>${url.priority.toFixed(1)}</priority>\\n`;\n if (url.images && url.images.length > 0) xml += buildImageXml(url.images);\n if (url.videos && url.videos.length > 0) xml += buildVideoXml(url.videos);\n if (url.news) xml += buildNewsXml(url.news);\n xml += ' </url>\\n';\n return xml;\n}\n\n/**\n * Generate an XML sitemap string from a sitemap configuration.\n *\n * @example\n * ```ts\n * const xml = generateSitemap({\n * hostname: 'https://example.com',\n * urls: [\n * { loc: '/', changefreq: 'daily', priority: 1.0 },\n * { loc: '/about', changefreq: 'monthly', priority: 0.8 },\n * ],\n * });\n * ```\n */\nexport function generateSitemap(config: SitemapConfig): string {\n const { hostname, urls } = config;\n const ns = detectNamespaces(urls);\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 if (ns.image) xml += '\\n xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"';\n if (ns.video) xml += '\\n xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\"';\n if (ns.news) xml += '\\n xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\"';\n xml += '>\\n';\n\n for (const url of urls) {\n xml += buildUrlXml(url, hostname);\n }\n\n xml += '</urlset>\\n';\n return xml;\n}\n","// ============================================================================\n// @power-seo/sitemap — Types\n// ============================================================================\n\nexport type {\n SitemapURL,\n SitemapImage,\n SitemapVideo,\n SitemapNews,\n SitemapConfig,\n} from '@power-seo/core';\n\n/** A sitemap entry in a sitemap index. */\nexport interface SitemapIndexEntry {\n loc: string;\n lastmod?: string;\n}\n\n/** Configuration for the sitemap index generator. */\nexport interface SitemapIndexConfig {\n sitemaps: SitemapIndexEntry[];\n}\n\n/** Result of URL validation. */\nexport interface SitemapValidationResult {\n valid: boolean;\n errors: string[];\n warnings: string[];\n}\n\n/** Maximum URLs allowed per sitemap file. */\nexport const MAX_URLS_PER_SITEMAP = 50_000 as const;\n\n/** Maximum sitemap file size in bytes (50MB). */\nexport const MAX_SITEMAP_SIZE_BYTES = 52_428_800 as const;\n","// ============================================================================\n// @power-seo/sitemap — Sitemap Index Generator\n// ============================================================================\n\nimport type { SitemapConfig } from '@power-seo/core';\nimport type { SitemapIndexConfig, SitemapIndexEntry } from './types.js';\nimport { MAX_URLS_PER_SITEMAP } from './types.js';\nimport { generateSitemap } from './generator.js';\n\n/** Escape special XML characters. */\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&apos;');\n}\n\n/**\n * Generate a sitemap index XML string.\n *\n * @example\n * ```ts\n * const indexXml = generateSitemapIndex({\n * sitemaps: [\n * { loc: 'https://example.com/sitemap-0.xml', lastmod: '2024-01-01' },\n * { loc: 'https://example.com/sitemap-1.xml', lastmod: '2024-01-01' },\n * ],\n * });\n * ```\n */\nexport function generateSitemapIndex(config: SitemapIndexConfig): string {\n let xml = '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n';\n xml += '<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\\n';\n\n for (const sitemap of config.sitemaps) {\n xml += ' <sitemap>\\n';\n xml += ` <loc>${escapeXml(sitemap.loc)}</loc>\\n`;\n if (sitemap.lastmod) {\n xml += ` <lastmod>${escapeXml(sitemap.lastmod)}</lastmod>\\n`;\n }\n xml += ' </sitemap>\\n';\n }\n\n xml += '</sitemapindex>\\n';\n return xml;\n}\n\n/**\n * Split a large sitemap config into multiple sitemaps + an index.\n *\n * When a site has more than 50,000 URLs, this function splits them into\n * multiple sitemap files and returns both the individual sitemaps and\n * the index that references them.\n *\n * @example\n * ```ts\n * const { index, sitemaps } = splitSitemap({\n * hostname: 'https://example.com',\n * urls: largeUrlArray,\n * });\n * // sitemaps[0].xml, sitemaps[1].xml, etc.\n * // index = sitemap index XML\n * ```\n */\nexport function splitSitemap(\n config: SitemapConfig,\n sitemapUrlPattern = '/sitemap-{index}.xml',\n): { index: string; sitemaps: Array<{ filename: string; xml: string }> } {\n const maxPerSitemap = config.maxUrlsPerSitemap ?? MAX_URLS_PER_SITEMAP;\n const { hostname, urls } = config;\n\n if (urls.length <= maxPerSitemap) {\n const xml = generateSitemap(config);\n const filename = sitemapUrlPattern.replace('{index}', '0');\n const indexEntries: SitemapIndexEntry[] = [{ loc: `${hostname}${filename}` }];\n return {\n index: generateSitemapIndex({ sitemaps: indexEntries }),\n sitemaps: [{ filename, xml }],\n };\n }\n\n const sitemaps: Array<{ filename: string; xml: string }> = [];\n const indexEntries: SitemapIndexEntry[] = [];\n\n for (let i = 0; i < urls.length; i += maxPerSitemap) {\n const chunk = urls.slice(i, i + maxPerSitemap);\n const chunkIndex = Math.floor(i / maxPerSitemap);\n const filename = sitemapUrlPattern.replace('{index}', String(chunkIndex));\n const xml = generateSitemap({ hostname, urls: chunk });\n\n sitemaps.push({ filename, xml });\n indexEntries.push({ loc: `${hostname}${filename}` });\n }\n\n return {\n index: generateSitemapIndex({ sitemaps: indexEntries }),\n sitemaps,\n };\n}\n","// ============================================================================\n// @power-seo/sitemap — Streaming Sitemap Generator\n// ============================================================================\n\nimport type { SitemapURL } from '@power-seo/core';\nimport { normalizeUrl } from '@power-seo/core';\n\n/** Escape special XML characters. */\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&apos;');\n}\n\n/**\n * A streaming sitemap generator that yields XML chunks.\n *\n * Useful for server responses where you want to stream the sitemap\n * instead of building the entire XML string in memory.\n *\n * @example\n * ```ts\n * const stream = streamSitemap('https://example.com', urls);\n * for (const chunk of stream) {\n * response.write(chunk);\n * }\n * ```\n */\nexport function* streamSitemap(\n hostname: string,\n urls: Iterable<SitemapURL>,\n): Generator<string, void, undefined> {\n yield '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n';\n yield '<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\\n';\n yield ' xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"\\n';\n yield ' xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\"\\n';\n yield ' xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\">\\n';\n\n for (const url of urls) {\n const loc = url.loc.startsWith('http')\n ? url.loc\n : normalizeUrl(`${hostname}${url.loc.startsWith('/') ? '' : '/'}${url.loc}`);\n\n yield ' <url>\\n';\n yield ` <loc>${escapeXml(loc)}</loc>\\n`;\n\n if (url.lastmod) yield ` <lastmod>${escapeXml(url.lastmod)}</lastmod>\\n`;\n if (url.changefreq) yield ` <changefreq>${url.changefreq}</changefreq>\\n`;\n if (url.priority !== undefined) yield ` <priority>${url.priority.toFixed(1)}</priority>\\n`;\n\n // Images\n if (url.images) {\n for (const img of url.images) {\n yield ' <image:image>\\n';\n yield ` <image:loc>${escapeXml(img.loc)}</image:loc>\\n`;\n if (img.caption) yield ` <image:caption>${escapeXml(img.caption)}</image:caption>\\n`;\n if (img.title) yield ` <image:title>${escapeXml(img.title)}</image:title>\\n`;\n yield ' </image:image>\\n';\n }\n }\n\n // Videos\n if (url.videos) {\n for (const vid of url.videos) {\n yield ' <video:video>\\n';\n yield ` <video:thumbnail_loc>${escapeXml(vid.thumbnailLoc)}</video:thumbnail_loc>\\n`;\n yield ` <video:title>${escapeXml(vid.title)}</video:title>\\n`;\n yield ` <video:description>${escapeXml(vid.description)}</video:description>\\n`;\n if (vid.contentLoc)\n yield ` <video:content_loc>${escapeXml(vid.contentLoc)}</video:content_loc>\\n`;\n if (vid.playerLoc)\n yield ` <video:player_loc>${escapeXml(vid.playerLoc)}</video:player_loc>\\n`;\n yield ' </video:video>\\n';\n }\n }\n\n // News\n if (url.news) {\n yield ' <news:news>\\n';\n yield ' <news:publication>\\n';\n yield ` <news:name>${escapeXml(url.news.publication.name)}</news:name>\\n`;\n yield ` <news:language>${escapeXml(url.news.publication.language)}</news:language>\\n`;\n yield ' </news:publication>\\n';\n yield ` <news:publication_date>${escapeXml(url.news.publicationDate)}</news:publication_date>\\n`;\n yield ` <news:title>${escapeXml(url.news.title)}</news:title>\\n`;\n yield ' </news:news>\\n';\n }\n\n yield ' </url>\\n';\n }\n\n yield '</urlset>\\n';\n}\n","// ============================================================================\n// @power-seo/sitemap — URL Validation\n// ============================================================================\n\nimport type { SitemapURL } from '@power-seo/core';\nimport { isAbsoluteUrl, MAX_URL_LENGTH } from '@power-seo/core';\nimport type { SitemapValidationResult } from './types.js';\n\nconst VALID_CHANGEFREQ = ['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'];\n\n/**\n * Validate a sitemap URL entry against the sitemap protocol spec.\n */\nexport function validateSitemapUrl(url: SitemapURL): SitemapValidationResult {\n const errors: string[] = [];\n const warnings: string[] = [];\n\n // loc is required\n if (!url.loc || url.loc.trim().length === 0) {\n errors.push('URL \"loc\" is required and cannot be empty.');\n } else {\n if (!isAbsoluteUrl(url.loc)) {\n errors.push(`URL \"${url.loc}\" must be an absolute URL (starting with http:// or https://).`);\n }\n\n if (url.loc.length > 2048) {\n errors.push(`URL \"${url.loc}\" exceeds the maximum length of 2048 characters.`);\n }\n\n if (url.loc.length > MAX_URL_LENGTH) {\n warnings.push(\n `URL \"${url.loc}\" is ${url.loc.length} characters. URLs under ${MAX_URL_LENGTH} characters are recommended for SEO.`,\n );\n }\n }\n\n // lastmod validation\n if (url.lastmod) {\n const dateRegex = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}(:\\d{2})?([+-]\\d{2}:\\d{2}|Z)?)?$/;\n if (!dateRegex.test(url.lastmod)) {\n errors.push(\n `\"lastmod\" value \"${url.lastmod}\" is not a valid W3C datetime format (YYYY-MM-DD or ISO 8601).`,\n );\n }\n }\n\n // changefreq validation\n if (url.changefreq && !VALID_CHANGEFREQ.includes(url.changefreq)) {\n errors.push(\n `\"changefreq\" value \"${url.changefreq}\" is invalid. Must be one of: ${VALID_CHANGEFREQ.join(', ')}.`,\n );\n }\n\n // priority validation\n if (url.priority !== undefined) {\n if (url.priority < 0 || url.priority > 1) {\n errors.push(`\"priority\" value ${url.priority} is out of range. Must be between 0.0 and 1.0.`);\n }\n }\n\n // Image validation\n if (url.images) {\n for (let i = 0; i < url.images.length; i++) {\n const img = url.images[i]!;\n if (!img.loc || img.loc.trim().length === 0) {\n errors.push(`Image ${i + 1}: \"loc\" is required.`);\n } else if (!isAbsoluteUrl(img.loc)) {\n errors.push(`Image ${i + 1}: \"${img.loc}\" must be an absolute URL.`);\n }\n }\n if (url.images.length > 1000) {\n warnings.push(\n `URL has ${url.images.length} images. Google supports up to 1,000 images per page.`,\n );\n }\n }\n\n // Video validation\n if (url.videos) {\n for (let i = 0; i < url.videos.length; i++) {\n const vid = url.videos[i]!;\n if (!vid.title) errors.push(`Video ${i + 1}: \"title\" is required.`);\n if (!vid.description) errors.push(`Video ${i + 1}: \"description\" is required.`);\n if (!vid.thumbnailLoc) errors.push(`Video ${i + 1}: \"thumbnailLoc\" is required.`);\n if (!vid.contentLoc && !vid.playerLoc) {\n errors.push(`Video ${i + 1}: either \"contentLoc\" or \"playerLoc\" must be provided.`);\n }\n if (vid.rating !== undefined && (vid.rating < 0 || vid.rating > 5)) {\n errors.push(`Video ${i + 1}: \"rating\" must be between 0.0 and 5.0.`);\n }\n }\n }\n\n // News validation\n if (url.news) {\n if (!url.news.publication?.name) errors.push('News: \"publication.name\" is required.');\n if (!url.news.publication?.language) errors.push('News: \"publication.language\" is required.');\n if (!url.news.publicationDate) errors.push('News: \"publicationDate\" is required.');\n if (!url.news.title) errors.push('News: \"title\" is required.');\n }\n\n return {\n valid: errors.length === 0,\n errors,\n warnings,\n };\n}\n","// ============================================================================\n// @power-seo/sitemap — Next.js App Router Adapter\n// ============================================================================\n\nimport type { SitemapURL } from '@power-seo/core';\nimport { validateSitemapUrl } from './validate.js';\n\n/**\n * A plain object that matches the shape of Next.js `MetadataRoute.Sitemap[number]`.\n * Typed locally so `@power-seo/sitemap` has no dependency on `next`.\n */\nexport interface NextSitemapEntry {\n url: string;\n lastModified?: string | Date;\n changeFrequency?:\n | 'always'\n | 'hourly'\n | 'daily'\n | 'weekly'\n | 'monthly'\n | 'yearly'\n | 'never';\n priority?: number;\n alternates?: {\n languages?: Record<string, string>;\n };\n}\n\n/**\n * Convert an array of `SitemapURL` objects to a Next.js-compatible sitemap array.\n *\n * Use this in `app/sitemap.ts` to bridge `@power-seo/sitemap` with Next.js's\n * built-in `MetadataRoute.Sitemap` convention.\n *\n * @example\n * ```ts\n * // app/sitemap.ts\n * import type { MetadataRoute } from 'next';\n * import { toNextSitemap } from '@power-seo/sitemap';\n *\n * export default async function sitemap(): Promise<MetadataRoute.Sitemap> {\n * const urls = [\n * { loc: 'https://example.com', changefreq: 'daily', priority: 1.0 },\n * { loc: 'https://example.com/about', changefreq: 'monthly', priority: 0.8 },\n * ];\n * return toNextSitemap(urls) as MetadataRoute.Sitemap;\n * }\n * ```\n */\nexport function toNextSitemap(urls: SitemapURL[]): NextSitemapEntry[] {\n const entries: NextSitemapEntry[] = [];\n\n for (const url of urls) {\n const { valid } = validateSitemapUrl(url);\n if (!valid) continue;\n\n const entry: NextSitemapEntry = { url: url.loc };\n\n if (url.lastmod) {\n entry.lastModified = url.lastmod;\n }\n\n if (url.changefreq) {\n entry.changeFrequency = url.changefreq as NextSitemapEntry['changeFrequency'];\n }\n\n if (url.priority !== undefined) {\n entry.priority = url.priority;\n }\n\n entries.push(entry);\n }\n\n return entries;\n}\n"],"mappings":";AAWA,SAAS,oBAAoB;AAG7B,SAAS,UAAU,KAAqB;AACtC,SAAO,IACJ,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,QAAQ,EACtB,QAAQ,MAAM,QAAQ;AAC3B;AAGA,SAAS,iBAAiB,MAAuE;AAC/F,MAAI,QAAQ;AACZ,MAAI,QAAQ;AACZ,MAAI,OAAO;AACX,aAAW,OAAO,MAAM;AACtB,QAAI,IAAI,UAAU,IAAI,OAAO,SAAS,EAAG,SAAQ;AACjD,QAAI,IAAI,UAAU,IAAI,OAAO,SAAS,EAAG,SAAQ;AACjD,QAAI,IAAI,KAAM,QAAO;AACrB,QAAI,SAAS,SAAS,KAAM;AAAA,EAC9B;AACA,SAAO,EAAE,OAAO,OAAO,KAAK;AAC9B;AAEA,SAAS,cAAc,QAAgC;AACrD,SAAO,OACJ,IAAI,CAAC,QAAQ;AACZ,QAAI,MAAM;AACV,WAAO,oBAAoB,UAAU,IAAI,GAAG,CAAC;AAAA;AAC7C,QAAI,IAAI,QAAS,QAAO,wBAAwB,UAAU,IAAI,OAAO,CAAC;AAAA;AACtE,QAAI,IAAI;AACN,aAAO,6BAA6B,UAAU,IAAI,WAAW,CAAC;AAAA;AAChE,QAAI,IAAI,MAAO,QAAO,sBAAsB,UAAU,IAAI,KAAK,CAAC;AAAA;AAChE,QAAI,IAAI,QAAS,QAAO,wBAAwB,UAAU,IAAI,OAAO,CAAC;AAAA;AACtE,WAAO;AACP,WAAO;AAAA,EACT,CAAC,EACA,KAAK,EAAE;AACZ;AAEA,SAAS,cAAc,QAAgC;AACrD,SAAO,OACJ,IAAI,CAAC,QAAQ;AACZ,QAAI,MAAM;AACV,WAAO,8BAA8B,U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SAAS,IAAI,CAAC,wDAAwD;AAAA,MACpF;AACA,UAAI,IAAI,WAAW,WAAc,IAAI,SAAS,KAAK,IAAI,SAAS,IAAI;AAClE,eAAO,KAAK,SAAS,IAAI,CAAC,yCAAyC;AAAA,MACrE;AAAA,IACF;AAAA,EACF;AAGA,MAAI,IAAI,MAAM;AACZ,QAAI,CAAC,IAAI,KAAK,aAAa,KAAM,QAAO,KAAK,uCAAuC;AACpF,QAAI,CAAC,IAAI,KAAK,aAAa,SAAU,QAAO,KAAK,2CAA2C;AAC5F,QAAI,CAAC,IAAI,KAAK,gBAAiB,QAAO,KAAK,sCAAsC;AACjF,QAAI,CAAC,IAAI,KAAK,MAAO,QAAO,KAAK,4BAA4B;AAAA,EAC/D;AAEA,SAAO;AAAA,IACL,OAAO,OAAO,WAAW;AAAA,IACzB;AAAA,IACA;AAAA,EACF;AACF;;;ACzDO,SAAS,cAAc,MAAwC;AACpE,QAAM,UAA8B,CAAC;AAErC,aAAW,OAAO,MAAM;AACtB,UAAM,EAAE,MAAM,IAAI,mBAAmB,GAAG;AACxC,QAAI,CAAC,MAAO;AAEZ,UAAM,QAA0B,EAAE,KAAK,IAAI,IAAI;AAE/C,QAAI,IAAI,SAAS;AACf,YAAM,eAAe,IAAI;AAAA,IAC3B;AAEA,QAAI,IAAI,YAAY;AAClB,YAAM,kBAAkB,IAAI;AAAA,IAC9B;AAEA,QAAI,IAAI,aAAa,QAAW;AAC9B,YAAM,WAAW,IAAI;AAAA,IACvB;AAEA,YAAQ,KAAK,KAAK;AAAA,EACpB;AAEA,SAAO;AACT;","names":["escapeXml","indexEntries","normalizeUrl","escapeXml"]}
1
+ {"version":3,"sources":["../src/generator.ts","../src/types.ts","../src/sitemap-index.ts","../src/stream.ts","../src/validate.ts","../src/next-adapter.ts"],"sourcesContent":["// @power-seo/sitemap — XML Sitemap Generator\n// ----------------------------------------------------------------------------\n\nimport type {\n SitemapConfig,\n SitemapURL,\n SitemapImage,\n SitemapVideo,\n SitemapNews,\n} from '@power-seo/core';\nimport { normalizeUrl } from '@power-seo/core';\n\n/** Escape special XML characters. */\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&apos;');\n}\n\n/** Determine which namespace extensions are needed. */\nfunction detectNamespaces(urls: SitemapURL[]): { image: boolean; video: boolean; news: boolean } {\n let image = false;\n let video = false;\n let news = false;\n for (const url of urls) {\n if (url.images && url.images.length > 0) image = true;\n if (url.videos && url.videos.length > 0) video = true;\n if (url.news) news = true;\n if (image && video && news) break;\n }\n return { image, video, news };\n}\n\nfunction buildImageXml(images: SitemapImage[]): string {\n return images\n .map((img) => {\n let xml = ' <image:image>\\n';\n xml += ` <image:loc>${escapeXml(img.loc)}</image:loc>\\n`;\n if (img.caption) xml += ` <image:caption>${escapeXml(img.caption)}</image:caption>\\n`;\n if (img.geoLocation)\n xml += ` <image:geo_location>${escapeXml(img.geoLocation)}</image:geo_location>\\n`;\n if (img.title) xml += ` <image:title>${escapeXml(img.title)}</image:title>\\n`;\n if (img.license) xml += ` <image:license>${escapeXml(img.license)}</image:license>\\n`;\n xml += ' </image:image>\\n';\n return xml;\n })\n .join('');\n}\n\nfunction buildVideoXml(videos: SitemapVideo[]): string {\n return videos\n .map((vid) => {\n let xml = ' <video:video>\\n';\n xml += ` <video:thumbnail_loc>${escapeXml(vid.thumbnailLoc)}</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 if (vid.contentLoc)\n xml += ` <video:content_loc>${escapeXml(vid.contentLoc)}</video:content_loc>\\n`;\n if (vid.playerLoc)\n xml += ` <video:player_loc>${escapeXml(vid.playerLoc)}</video:player_loc>\\n`;\n if (vid.duration !== undefined)\n xml += ` <video:duration>${vid.duration}</video:duration>\\n`;\n if (vid.expirationDate)\n xml += ` <video:expiration_date>${escapeXml(vid.expirationDate)}</video:expiration_date>\\n`;\n if (vid.rating !== undefined) xml += ` <video:rating>${vid.rating}</video:rating>\\n`;\n if (vid.viewCount !== undefined)\n xml += ` <video:view_count>${vid.viewCount}</video:view_count>\\n`;\n if (vid.publicationDate)\n xml += ` <video:publication_date>${escapeXml(vid.publicationDate)}</video:publication_date>\\n`;\n if (vid.familyFriendly !== undefined)\n xml += ` <video:family_friendly>${vid.familyFriendly ? 'yes' : 'no'}</video:family_friendly>\\n`;\n if (vid.live !== undefined)\n xml += ` <video:live>${vid.live ? 'yes' : 'no'}</video:live>\\n`;\n xml += ' </video:video>\\n';\n return xml;\n })\n .join('');\n}\n\nfunction buildNewsXml(news: SitemapNews): string {\n let xml = ' <news:news>\\n';\n xml += ' <news:publication>\\n';\n xml += ` <news:name>${escapeXml(news.publication.name)}</news:name>\\n`;\n xml += ` <news:language>${escapeXml(news.publication.language)}</news:language>\\n`;\n xml += ' </news:publication>\\n';\n xml += ` <news:publication_date>${escapeXml(news.publicationDate)}</news:publication_date>\\n`;\n xml += ` <news:title>${escapeXml(news.title)}</news:title>\\n`;\n xml += ' </news:news>\\n';\n return xml;\n}\n\nfunction buildUrlXml(url: SitemapURL, hostname: string): string {\n const loc = url.loc.startsWith('http')\n ? url.loc\n : normalizeUrl(`${hostname}${url.loc.startsWith('/') ? '' : '/'}${url.loc}`);\n\n let xml = ' <url>\\n';\n xml += ` <loc>${escapeXml(loc)}</loc>\\n`;\n if (url.lastmod) xml += ` <lastmod>${escapeXml(url.lastmod)}</lastmod>\\n`;\n if (url.changefreq) xml += ` <changefreq>${url.changefreq}</changefreq>\\n`;\n if (url.priority !== undefined) xml += ` <priority>${url.priority.toFixed(1)}</priority>\\n`;\n if (url.images && url.images.length > 0) xml += buildImageXml(url.images);\n if (url.videos && url.videos.length > 0) xml += buildVideoXml(url.videos);\n if (url.news) xml += buildNewsXml(url.news);\n xml += ' </url>\\n';\n return xml;\n}\n\n/**\n * Generate an XML sitemap string from a sitemap configuration.\n *\n * @example\n * ```ts\n * const xml = generateSitemap({\n * hostname: 'https://example.com',\n * urls: [\n * { loc: '/', changefreq: 'daily', priority: 1.0 },\n * { loc: '/about', changefreq: 'monthly', priority: 0.8 },\n * ],\n * });\n * ```\n */\nexport function generateSitemap(config: SitemapConfig): string {\n const { hostname, urls } = config;\n const ns = detectNamespaces(urls);\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 if (ns.image) xml += '\\n xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"';\n if (ns.video) xml += '\\n xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\"';\n if (ns.news) xml += '\\n xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\"';\n xml += '>\\n';\n\n for (const url of urls) {\n xml += buildUrlXml(url, hostname);\n }\n\n xml += '</urlset>\\n';\n return xml;\n}\n","// @power-seo/sitemap — Types\n// ----------------------------------------------------------------------------\n\nexport type {\n SitemapURL,\n SitemapImage,\n SitemapVideo,\n SitemapNews,\n SitemapConfig,\n} from '@power-seo/core';\n\n/** A sitemap entry in a sitemap index. */\nexport interface SitemapIndexEntry {\n loc: string;\n lastmod?: string;\n}\n\n/** Configuration for the sitemap index generator. */\nexport interface SitemapIndexConfig {\n sitemaps: SitemapIndexEntry[];\n}\n\n/** Result of URL validation. */\nexport interface SitemapValidationResult {\n valid: boolean;\n errors: string[];\n warnings: string[];\n}\n\n/** Maximum URLs allowed per sitemap file. */\nexport const MAX_URLS_PER_SITEMAP = 50_000 as const;\n\n/** Maximum sitemap file size in bytes (50MB). */\nexport const MAX_SITEMAP_SIZE_BYTES = 52_428_800 as const;\n","// @power-seo/sitemap — Sitemap Index Generator\n// ----------------------------------------------------------------------------\n\nimport type { SitemapConfig } from '@power-seo/core';\nimport type { SitemapIndexConfig, SitemapIndexEntry } from './types.js';\nimport { MAX_URLS_PER_SITEMAP } from './types.js';\nimport { generateSitemap } from './generator.js';\n\n/** Escape special XML characters. */\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&apos;');\n}\n\n/**\n * Generate a sitemap index XML string.\n *\n * @example\n * ```ts\n * const indexXml = generateSitemapIndex({\n * sitemaps: [\n * { loc: 'https://example.com/sitemap-0.xml', lastmod: '2024-01-01' },\n * { loc: 'https://example.com/sitemap-1.xml', lastmod: '2024-01-01' },\n * ],\n * });\n * ```\n */\nexport function generateSitemapIndex(config: SitemapIndexConfig): string {\n let xml = '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n';\n xml += '<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\\n';\n\n for (const sitemap of config.sitemaps) {\n xml += ' <sitemap>\\n';\n xml += ` <loc>${escapeXml(sitemap.loc)}</loc>\\n`;\n if (sitemap.lastmod) {\n xml += ` <lastmod>${escapeXml(sitemap.lastmod)}</lastmod>\\n`;\n }\n xml += ' </sitemap>\\n';\n }\n\n xml += '</sitemapindex>\\n';\n return xml;\n}\n\n/**\n * Split a large sitemap config into multiple sitemaps + an index.\n *\n * When a site has more than 50,000 URLs, this function splits them into\n * multiple sitemap files and returns both the individual sitemaps and\n * the index that references them.\n *\n * @example\n * ```ts\n * const { index, sitemaps } = splitSitemap({\n * hostname: 'https://example.com',\n * urls: largeUrlArray,\n * });\n * // sitemaps[0].xml, sitemaps[1].xml, etc.\n * // index = sitemap index XML\n * ```\n */\nexport function splitSitemap(\n config: SitemapConfig,\n sitemapUrlPattern = '/sitemap-{index}.xml',\n): { index: string; sitemaps: Array<{ filename: string; xml: string }> } {\n const maxPerSitemap = config.maxUrlsPerSitemap ?? MAX_URLS_PER_SITEMAP;\n const { hostname, urls } = config;\n\n if (urls.length <= maxPerSitemap) {\n const xml = generateSitemap(config);\n const filename = sitemapUrlPattern.replace('{index}', '0');\n const indexEntries: SitemapIndexEntry[] = [{ loc: `${hostname}${filename}` }];\n return {\n index: generateSitemapIndex({ sitemaps: indexEntries }),\n sitemaps: [{ filename, xml }],\n };\n }\n\n const sitemaps: Array<{ filename: string; xml: string }> = [];\n const indexEntries: SitemapIndexEntry[] = [];\n\n for (let i = 0; i < urls.length; i += maxPerSitemap) {\n const chunk = urls.slice(i, i + maxPerSitemap);\n const chunkIndex = Math.floor(i / maxPerSitemap);\n const filename = sitemapUrlPattern.replace('{index}', String(chunkIndex));\n const xml = generateSitemap({ hostname, urls: chunk });\n\n sitemaps.push({ filename, xml });\n indexEntries.push({ loc: `${hostname}${filename}` });\n }\n\n return {\n index: generateSitemapIndex({ sitemaps: indexEntries }),\n sitemaps,\n };\n}\n","// @power-seo/sitemap — Streaming Sitemap Generator\n// ----------------------------------------------------------------------------\n\nimport type { SitemapURL } from '@power-seo/core';\nimport { normalizeUrl } from '@power-seo/core';\n\n/** Escape special XML characters. */\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&apos;');\n}\n\n/**\n * A streaming sitemap generator that yields XML chunks.\n *\n * Useful for server responses where you want to stream the sitemap\n * instead of building the entire XML string in memory.\n *\n * @example\n * ```ts\n * const stream = streamSitemap('https://example.com', urls);\n * for (const chunk of stream) {\n * response.write(chunk);\n * }\n * ```\n */\nexport function* streamSitemap(\n hostname: string,\n urls: Iterable<SitemapURL>,\n): Generator<string, void, undefined> {\n yield '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n';\n yield '<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\\n';\n yield ' xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"\\n';\n yield ' xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\"\\n';\n yield ' xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\">\\n';\n\n for (const url of urls) {\n const loc = url.loc.startsWith('http')\n ? url.loc\n : normalizeUrl(`${hostname}${url.loc.startsWith('/') ? '' : '/'}${url.loc}`);\n\n yield ' <url>\\n';\n yield ` <loc>${escapeXml(loc)}</loc>\\n`;\n\n if (url.lastmod) yield ` <lastmod>${escapeXml(url.lastmod)}</lastmod>\\n`;\n if (url.changefreq) yield ` <changefreq>${url.changefreq}</changefreq>\\n`;\n if (url.priority !== undefined) yield ` <priority>${url.priority.toFixed(1)}</priority>\\n`;\n\n // Images\n if (url.images) {\n for (const img of url.images) {\n yield ' <image:image>\\n';\n yield ` <image:loc>${escapeXml(img.loc)}</image:loc>\\n`;\n if (img.caption) yield ` <image:caption>${escapeXml(img.caption)}</image:caption>\\n`;\n if (img.title) yield ` <image:title>${escapeXml(img.title)}</image:title>\\n`;\n yield ' </image:image>\\n';\n }\n }\n\n // Videos\n if (url.videos) {\n for (const vid of url.videos) {\n yield ' <video:video>\\n';\n yield ` <video:thumbnail_loc>${escapeXml(vid.thumbnailLoc)}</video:thumbnail_loc>\\n`;\n yield ` <video:title>${escapeXml(vid.title)}</video:title>\\n`;\n yield ` <video:description>${escapeXml(vid.description)}</video:description>\\n`;\n if (vid.contentLoc)\n yield ` <video:content_loc>${escapeXml(vid.contentLoc)}</video:content_loc>\\n`;\n if (vid.playerLoc)\n yield ` <video:player_loc>${escapeXml(vid.playerLoc)}</video:player_loc>\\n`;\n yield ' </video:video>\\n';\n }\n }\n\n // News\n if (url.news) {\n yield ' <news:news>\\n';\n yield ' <news:publication>\\n';\n yield ` <news:name>${escapeXml(url.news.publication.name)}</news:name>\\n`;\n yield ` <news:language>${escapeXml(url.news.publication.language)}</news:language>\\n`;\n yield ' </news:publication>\\n';\n yield ` <news:publication_date>${escapeXml(url.news.publicationDate)}</news:publication_date>\\n`;\n yield ` <news:title>${escapeXml(url.news.title)}</news:title>\\n`;\n yield ' </news:news>\\n';\n }\n\n yield ' </url>\\n';\n }\n\n yield '</urlset>\\n';\n}\n","// @power-seo/sitemap — URL Validation\n// ----------------------------------------------------------------------------\n\nimport type { SitemapURL } from '@power-seo/core';\nimport { isAbsoluteUrl, MAX_URL_LENGTH } from '@power-seo/core';\nimport type { SitemapValidationResult } from './types.js';\n\nconst VALID_CHANGEFREQ = ['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'];\n\n/**\n * Validate a sitemap URL entry against the sitemap protocol spec.\n */\nexport function validateSitemapUrl(url: SitemapURL): SitemapValidationResult {\n const errors: string[] = [];\n const warnings: string[] = [];\n\n // loc is required\n if (!url.loc || url.loc.trim().length === 0) {\n errors.push('URL \"loc\" is required and cannot be empty.');\n } else {\n if (!isAbsoluteUrl(url.loc)) {\n errors.push(`URL \"${url.loc}\" must be an absolute URL (starting with http:// or https://).`);\n }\n\n if (url.loc.length > 2048) {\n errors.push(`URL \"${url.loc}\" exceeds the maximum length of 2048 characters.`);\n }\n\n if (url.loc.length > MAX_URL_LENGTH) {\n warnings.push(\n `URL \"${url.loc}\" is ${url.loc.length} characters. URLs under ${MAX_URL_LENGTH} characters are recommended for SEO.`,\n );\n }\n }\n\n // lastmod validation\n if (url.lastmod) {\n const dateRegex = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}(:\\d{2})?([+-]\\d{2}:\\d{2}|Z)?)?$/;\n if (!dateRegex.test(url.lastmod)) {\n errors.push(\n `\"lastmod\" value \"${url.lastmod}\" is not a valid W3C datetime format (YYYY-MM-DD or ISO 8601).`,\n );\n }\n }\n\n // changefreq validation\n if (url.changefreq && !VALID_CHANGEFREQ.includes(url.changefreq)) {\n errors.push(\n `\"changefreq\" value \"${url.changefreq}\" is invalid. Must be one of: ${VALID_CHANGEFREQ.join(', ')}.`,\n );\n }\n\n // priority validation\n if (url.priority !== undefined) {\n if (url.priority < 0 || url.priority > 1) {\n errors.push(`\"priority\" value ${url.priority} is out of range. Must be between 0.0 and 1.0.`);\n }\n }\n\n // Image validation\n if (url.images) {\n for (let i = 0; i < url.images.length; i++) {\n const img = url.images[i]!;\n if (!img.loc || img.loc.trim().length === 0) {\n errors.push(`Image ${i + 1}: \"loc\" is required.`);\n } else if (!isAbsoluteUrl(img.loc)) {\n errors.push(`Image ${i + 1}: \"${img.loc}\" must be an absolute URL.`);\n }\n }\n if (url.images.length > 1000) {\n warnings.push(\n `URL has ${url.images.length} images. Google supports up to 1,000 images per page.`,\n );\n }\n }\n\n // Video validation\n if (url.videos) {\n for (let i = 0; i < url.videos.length; i++) {\n const vid = url.videos[i]!;\n if (!vid.title) errors.push(`Video ${i + 1}: \"title\" is required.`);\n if (!vid.description) errors.push(`Video ${i + 1}: \"description\" is required.`);\n if (!vid.thumbnailLoc) errors.push(`Video ${i + 1}: \"thumbnailLoc\" is required.`);\n if (!vid.contentLoc && !vid.playerLoc) {\n errors.push(`Video ${i + 1}: either \"contentLoc\" or \"playerLoc\" must be provided.`);\n }\n if (vid.rating !== undefined && (vid.rating < 0 || vid.rating > 5)) {\n errors.push(`Video ${i + 1}: \"rating\" must be between 0.0 and 5.0.`);\n }\n }\n }\n\n // News validation\n if (url.news) {\n if (!url.news.publication?.name) errors.push('News: \"publication.name\" is required.');\n if (!url.news.publication?.language) errors.push('News: \"publication.language\" is required.');\n if (!url.news.publicationDate) errors.push('News: \"publicationDate\" is required.');\n if (!url.news.title) errors.push('News: \"title\" is required.');\n }\n\n return {\n valid: errors.length === 0,\n errors,\n warnings,\n };\n}\n","// @power-seo/sitemap — Next.js App Router Adapter\n\n\nimport type { SitemapURL } from '@power-seo/core';\nimport { validateSitemapUrl } from './validate.js';\n\n/** Plain object matching the shape of Next.js `MetadataRoute.Sitemap[number]`. */\nexport interface NextSitemapEntry {\n url: string;\n lastModified?: string | Date;\n changeFrequency?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';\n priority?: number;\n}\n\n/**\n * Convert `SitemapURL[]` to a plain array compatible with Next.js `MetadataRoute.Sitemap`.\n *\n * @example\n * ```ts\n * // app/sitemap.ts\n * import { toNextSitemap } from '@power-seo/sitemap';\n * export default async function sitemap() {\n * return toNextSitemap(urls) as MetadataRoute.Sitemap;\n * }\n * ```\n */\nexport function toNextSitemap(urls: SitemapURL[]): NextSitemapEntry[] {\n const entries: NextSitemapEntry[] = [];\n for (const url of urls) {\n const { valid } = validateSitemapUrl(url);\n if (!valid) continue;\n const entry: NextSitemapEntry = { url: url.loc };\n if (url.lastmod) entry.lastModified = url.lastmod;\n if (url.changefreq) entry.changeFrequency = url.changefreq as NextSitemapEntry['changeFrequency'];\n if (url.priority !== undefined) entry.priority = url.priority;\n entries.push(entry);\n }\n return entries;\n}\n"],"mappings":";AAUA,SAAS,oBAAoB;AAG7B,SAAS,UAAU,KAAqB;AACtC,SAAO,IACJ,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,QAAQ,EACtB,QAAQ,MAAM,QAAQ;AAC3B;AAGA,SAAS,iBAAiB,MAAuE;AAC/F,MAAI,QAAQ;AACZ,MAAI,QAAQ;AACZ,MAAI,OAAO;AACX,aAAW,OAAO,MAAM;AACtB,QAAI,IAAI,UAAU,IAAI,OAAO,SAAS,EAAG,SAAQ;AACjD,QAAI,IAAI,UAAU,IAAI,OAAO,SAAS,EAAG,SAAQ;AACjD,QAAI,IAAI,KAAM,QAAO;AACrB,QAAI,SAAS,SAAS,KAAM;AAAA,EAC9B;AACA,SAAO,EAAE,OAAO,OAAO,KAAK;AAC9B;AAEA,SAAS,cAAc,QAAgC;AACrD,SAAO,OACJ,IAAI,CAAC,QAAQ;AACZ,QAAI,MAAM;AACV,WAAO,oBAAoB,UAAU,IAAI,GAAG,CAAC;AAAA;AAC7C,QAAI,IAAI,QAAS,QAAO,wBAAwB,UAAU,IAAI,OAAO,CAAC;AAAA;AACtE,QAAI,IAAI;AACN,aAAO,6BAA6B,UAAU,IAAI,WAAW,CAAC;AAAA;AAChE,QAAI,IAAI,MAAO,QAAO,sB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.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@power-seo/sitemap",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "XML sitemap generation, streaming, and validation with image, video, and news support",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,18 +17,8 @@
17
17
  "files": [
18
18
  "dist"
19
19
  ],
20
- "scripts": {
21
- "build": "tsup",
22
- "dev": "tsup --watch",
23
- "test": "vitest run",
24
- "test:watch": "vitest",
25
- "typecheck": "tsc --noEmit",
26
- "lint": "eslint src/",
27
- "lint:fix": "eslint src/ --fix",
28
- "clean": "rimraf dist"
29
- },
30
20
  "dependencies": {
31
- "@power-seo/core": "workspace:*"
21
+ "@power-seo/core": "1.0.3"
32
22
  },
33
23
  "devDependencies": {
34
24
  "rimraf": "^6.1.3",
@@ -60,5 +50,15 @@
60
50
  "funding": {
61
51
  "type": "github",
62
52
  "url": "https://github.com/sponsors/cybercraftbd"
53
+ },
54
+ "scripts": {
55
+ "build": "tsup",
56
+ "dev": "tsup --watch",
57
+ "test": "vitest run",
58
+ "test:watch": "vitest",
59
+ "typecheck": "tsc --noEmit",
60
+ "lint": "eslint src/",
61
+ "lint:fix": "eslint src/ --fix",
62
+ "clean": "rimraf dist"
63
63
  }
64
- }
64
+ }