@power-seo/sitemap 1.0.6 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -97
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# @power-seo/sitemap
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
XML sitemap generation for TypeScript — streaming output, automatic index splitting, image/video/news extensions, and URL validation — works in Next.js, Remix, Express, and edge runtimes with zero runtime dependencies.
|
|
6
|
+
|
|
3
7
|
[](https://www.npmjs.com/package/@power-seo/sitemap)
|
|
4
8
|
[](https://www.npmjs.com/package/@power-seo/sitemap)
|
|
5
9
|
[](https://socket.dev/npm/package/@power-seo/sitemap)
|
|
@@ -8,8 +12,6 @@
|
|
|
8
12
|
[](https://www.typescriptlang.org/)
|
|
9
13
|
[](https://bundlephobia.com/package/@power-seo/sitemap)
|
|
10
14
|
|
|
11
|
-
XML sitemap generation for TypeScript — streaming output, automatic index splitting, image/video/news extensions, and URL validation — works in Next.js, Remix, Express, and edge runtimes with zero runtime dependencies.
|
|
12
|
-
|
|
13
15
|
`@power-seo/sitemap` produces standards-compliant `<urlset>` and `<sitemapindex>` XML from typed URL arrays. Provide a hostname and URL list — get back a valid XML string ready to serve as `Content-Type: application/xml`. For large catalogs, stream chunks with constant memory usage or auto-split at the 50,000-URL spec limit with a generated index file. All five functions are independently importable and tree-shakeable.
|
|
14
16
|
|
|
15
17
|
> **Zero runtime dependencies** — only `@power-seo/core` as a peer.
|
|
@@ -18,16 +20,18 @@ XML sitemap generation for TypeScript — streaming output, automatic index spli
|
|
|
18
20
|
|
|
19
21
|
## Why @power-seo/sitemap?
|
|
20
22
|
|
|
21
|
-
|
|
|
22
|
-
|
|
23
|
-
| Spec compliance
|
|
24
|
-
| Large sites
|
|
25
|
-
| Memory usage
|
|
26
|
-
| Image indexing
|
|
27
|
-
| Video SEO
|
|
28
|
-
| News sitemaps
|
|
29
|
-
| Hostname handling | ❌ Hardcode absolute URLs everywhere
|
|
30
|
-
| Validation
|
|
23
|
+
| | Without | With |
|
|
24
|
+
| ----------------- | ----------------------------------------- | --------------------------------------------------- |
|
|
25
|
+
| Spec compliance | ❌ Hand-built XML, wrong namespaces | ✅ Correct `<urlset>` + namespace declarations |
|
|
26
|
+
| Large sites | ❌ Single file breaks at 50,000 URLs | ✅ Auto-split + sitemap index generation |
|
|
27
|
+
| Memory usage | ❌ String concat spikes on large catalogs | ✅ Synchronous generator yields chunks |
|
|
28
|
+
| Image indexing | ❌ Product images undiscoverable | ✅ `<image:image>` extension per URL |
|
|
29
|
+
| Video SEO | ❌ No structured video metadata | ✅ `<video:video>` extension with title, duration |
|
|
30
|
+
| News sitemaps | ❌ Missing publication + date tags | ✅ `<news:news>` extension for Google News |
|
|
31
|
+
| Hostname handling | ❌ Hardcode absolute URLs everywhere | ✅ Pass `hostname` once; use relative `loc` paths |
|
|
32
|
+
| Validation | ❌ Silent bad data reaches Google | ✅ `validateSitemapUrl()` returns errors + warnings |
|
|
33
|
+
|
|
34
|
+

|
|
31
35
|
|
|
32
36
|
---
|
|
33
37
|
|
|
@@ -49,24 +53,28 @@ XML sitemap generation for TypeScript — streaming output, automatic index spli
|
|
|
49
53
|
- **Zero runtime dependencies** — pure TypeScript, no external XML libraries
|
|
50
54
|
- **Tree-shakeable** — import only the functions you use
|
|
51
55
|
|
|
56
|
+

|
|
57
|
+
|
|
52
58
|
---
|
|
53
59
|
|
|
54
60
|
## Comparison
|
|
55
61
|
|
|
56
|
-
| Feature
|
|
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
|
|
68
|
-
| Tree-shakeable
|
|
69
|
-
| Next.js `app/sitemap.ts` adapter |
|
|
62
|
+
| Feature | @power-seo/sitemap | next-sitemap | sitemap (npm) | xmlbuilder2 |
|
|
63
|
+
| -------------------------------- | :----------------: | :----------: | :-----------: | :---------: |
|
|
64
|
+
| Image sitemap extension | ✅ | ✅ | ✅ | ❌ |
|
|
65
|
+
| Video sitemap extension | ✅ | ❌ | ✅ | ❌ |
|
|
66
|
+
| News sitemap extension | ✅ | ❌ | ✅ | ❌ |
|
|
67
|
+
| Streaming generation | ✅ | ❌ | ❌ | ❌ |
|
|
68
|
+
| Auto index splitting | ✅ | ✅ | ❌ | ❌ |
|
|
69
|
+
| URL validation | ✅ | ❌ | ❌ | ❌ |
|
|
70
|
+
| Hostname + relative loc paths | ✅ | ❌ | ❌ | ❌ |
|
|
71
|
+
| Zero runtime dependencies | ✅ | ❌ | ❌ | ❌ |
|
|
72
|
+
| Edge runtime compatible | ✅ | ❌ | ❌ | ❌ |
|
|
73
|
+
| TypeScript-first | ✅ | Partial | ❌ | ❌ |
|
|
74
|
+
| Tree-shakeable | ✅ | ❌ | ❌ | ❌ |
|
|
75
|
+
| Next.js `app/sitemap.ts` adapter | ✅ | ✅ | ❌ | ❌ |
|
|
76
|
+
|
|
77
|
+

|
|
70
78
|
|
|
71
79
|
---
|
|
72
80
|
|
|
@@ -84,10 +92,6 @@ yarn add @power-seo/sitemap
|
|
|
84
92
|
pnpm add @power-seo/sitemap
|
|
85
93
|
```
|
|
86
94
|
|
|
87
|
-
```bash
|
|
88
|
-
bun add @power-seo/sitemap
|
|
89
|
-
```
|
|
90
|
-
|
|
91
95
|
---
|
|
92
96
|
|
|
93
97
|
## Quick Start
|
|
@@ -112,6 +116,8 @@ const xml = generateSitemap({
|
|
|
112
116
|
|
|
113
117
|
`hostname` is required — it is prepended to any `loc` value that is a relative path. Absolute `loc` values (starting with `http`) are used as-is.
|
|
114
118
|
|
|
119
|
+

|
|
120
|
+
|
|
115
121
|
---
|
|
116
122
|
|
|
117
123
|
## Usage
|
|
@@ -317,12 +323,12 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
|
|
317
323
|
function generateSitemap(config: SitemapConfig): string;
|
|
318
324
|
```
|
|
319
325
|
|
|
320
|
-
| Prop
|
|
321
|
-
|
|
|
322
|
-
| `hostname`
|
|
323
|
-
| `urls`
|
|
324
|
-
| `maxUrlsPerSitemap` | `number`
|
|
325
|
-
| `outputDir`
|
|
326
|
+
| Prop | Type | Required | Description |
|
|
327
|
+
| ------------------- | -------------- | -------- | ------------------------------------------------------------------------- |
|
|
328
|
+
| `hostname` | `string` | ✅ | Base URL prepended to relative `loc` paths (e.g. `'https://example.com'`) |
|
|
329
|
+
| `urls` | `SitemapURL[]` | ✅ | Array of URL entries |
|
|
330
|
+
| `maxUrlsPerSitemap` | `number` | — | Override the 50,000-URL chunk size (used by `splitSitemap`) |
|
|
331
|
+
| `outputDir` | `string` | — | Optional output directory hint (informational; does not write files) |
|
|
326
332
|
|
|
327
333
|
### `streamSitemap(hostname, urls)`
|
|
328
334
|
|
|
@@ -335,10 +341,10 @@ function streamSitemap(
|
|
|
335
341
|
|
|
336
342
|
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
343
|
|
|
338
|
-
| Param
|
|
339
|
-
|
|
|
340
|
-
| `hostname` | `string`
|
|
341
|
-
| `urls`
|
|
344
|
+
| Param | Type | Description |
|
|
345
|
+
| ---------- | ---------------------- | ------------------------------------------------------------------ |
|
|
346
|
+
| `hostname` | `string` | Base URL prepended to relative `loc` paths |
|
|
347
|
+
| `urls` | `Iterable<SitemapURL>` | Any iterable of URL entries — arrays, generators, database cursors |
|
|
342
348
|
|
|
343
349
|
### `splitSitemap(config, sitemapUrlPattern?)`
|
|
344
350
|
|
|
@@ -351,17 +357,17 @@ function splitSitemap(
|
|
|
351
357
|
|
|
352
358
|
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
359
|
|
|
354
|
-
| Param
|
|
355
|
-
|
|
|
356
|
-
| `config`
|
|
357
|
-
| `sitemapUrlPattern` | `string`
|
|
360
|
+
| Param | Type | Default | Description |
|
|
361
|
+
| ------------------- | --------------- | ------------------------ | --------------------------------------- |
|
|
362
|
+
| `config` | `SitemapConfig` | — | Same config as `generateSitemap()` |
|
|
363
|
+
| `sitemapUrlPattern` | `string` | `'/sitemap-{index}.xml'` | Filename pattern for each split sitemap |
|
|
358
364
|
|
|
359
365
|
**Return value:**
|
|
360
366
|
|
|
361
|
-
| Field
|
|
362
|
-
|
|
|
363
|
-
| `index`
|
|
364
|
-
| `sitemaps` | `Array<{ filename: string; xml: string }>` | Each split sitemap with its filename and XML string
|
|
367
|
+
| Field | Type | Description |
|
|
368
|
+
| ---------- | ------------------------------------------ | ---------------------------------------------------------------- |
|
|
369
|
+
| `index` | `string` | Sitemap index XML (`<sitemapindex>`) referencing all split files |
|
|
370
|
+
| `sitemaps` | `Array<{ filename: string; xml: string }>` | Each split sitemap with its filename and XML string |
|
|
365
371
|
|
|
366
372
|
### `generateSitemapIndex(config)`
|
|
367
373
|
|
|
@@ -369,8 +375,8 @@ Splits a large URL set into multiple sitemap files and returns the index XML and
|
|
|
369
375
|
function generateSitemapIndex(config: SitemapIndexConfig): string;
|
|
370
376
|
```
|
|
371
377
|
|
|
372
|
-
| Prop
|
|
373
|
-
|
|
|
378
|
+
| Prop | Type | Description |
|
|
379
|
+
| ---------- | --------------------- | ---------------------------------------------------- |
|
|
374
380
|
| `sitemaps` | `SitemapIndexEntry[]` | Array of `{ loc: string; lastmod?: string }` entries |
|
|
375
381
|
|
|
376
382
|
### `validateSitemapUrl(url)`
|
|
@@ -391,45 +397,45 @@ function toNextSitemap(urls: SitemapURL[]): NextSitemapEntry[];
|
|
|
391
397
|
|
|
392
398
|
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
399
|
|
|
394
|
-
| Field | Type
|
|
395
|
-
| ----------------- |
|
|
396
|
-
| `url` | `string`
|
|
397
|
-
| `lastModified` | `Date \| string`
|
|
398
|
-
| `changeFrequency` | `string`
|
|
399
|
-
| `priority` | `number`
|
|
400
|
+
| Field | Type | Description |
|
|
401
|
+
| ----------------- | ---------------- | ------------------------------------ |
|
|
402
|
+
| `url` | `string` | Absolute URL (`loc`) |
|
|
403
|
+
| `lastModified` | `Date \| string` | From `lastmod` (converted to `Date`) |
|
|
404
|
+
| `changeFrequency` | `string` | From `changefreq` |
|
|
405
|
+
| `priority` | `number` | From `priority` |
|
|
400
406
|
|
|
401
407
|
---
|
|
402
408
|
|
|
403
409
|
## Types
|
|
404
410
|
|
|
405
|
-
| Type
|
|
406
|
-
|
|
|
407
|
-
| `SitemapConfig`
|
|
408
|
-
| `SitemapURL`
|
|
409
|
-
| `SitemapImage`
|
|
410
|
-
| `SitemapVideo`
|
|
411
|
-
| `SitemapNews`
|
|
412
|
-
| `SitemapIndexConfig`
|
|
413
|
-
| `SitemapIndexEntry`
|
|
414
|
-
| `SitemapValidationResult` | `{ valid: boolean; errors: string[]; warnings: string[] }`
|
|
411
|
+
| Type | Description |
|
|
412
|
+
| ------------------------- | --------------------------------------------------------------------------------------------- |
|
|
413
|
+
| `SitemapConfig` | `{ hostname: string; urls: SitemapURL[]; maxUrlsPerSitemap?: number; outputDir?: string }` |
|
|
414
|
+
| `SitemapURL` | Single URL entry — see field table below |
|
|
415
|
+
| `SitemapImage` | `{ loc: string; caption?: string; geoLocation?: string; title?: string; license?: string }` |
|
|
416
|
+
| `SitemapVideo` | Video extension entry with `thumbnailLoc`, `title`, `description`, and optional fields |
|
|
417
|
+
| `SitemapNews` | `{ publication: { name: string; language: string }; publicationDate: string; title: string }` |
|
|
418
|
+
| `SitemapIndexConfig` | `{ sitemaps: SitemapIndexEntry[] }` |
|
|
419
|
+
| `SitemapIndexEntry` | `{ loc: string; lastmod?: string }` |
|
|
420
|
+
| `SitemapValidationResult` | `{ valid: boolean; errors: string[]; warnings: string[] }` |
|
|
415
421
|
|
|
416
422
|
### `SitemapURL` Fields
|
|
417
423
|
|
|
418
|
-
| Prop
|
|
419
|
-
|
|
|
420
|
-
| `loc`
|
|
421
|
-
| `lastmod`
|
|
422
|
-
| `changefreq` | `'always' \| 'hourly' \| 'daily' \| 'weekly' \| 'monthly' \| 'yearly' \| 'never'` | —
|
|
423
|
-
| `priority`
|
|
424
|
-
| `images`
|
|
425
|
-
| `videos`
|
|
426
|
-
| `news`
|
|
424
|
+
| Prop | Type | Default | Description |
|
|
425
|
+
| ------------ | --------------------------------------------------------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------ |
|
|
426
|
+
| `loc` | `string` | — | **Required.** URL path (e.g. `/about`) or absolute URL. Hostname is prepended to relative paths. |
|
|
427
|
+
| `lastmod` | `string` | — | Last modified date — ISO 8601 or `YYYY-MM-DD` |
|
|
428
|
+
| `changefreq` | `'always' \| 'hourly' \| 'daily' \| 'weekly' \| 'monthly' \| 'yearly' \| 'never'` | — | Suggested crawl frequency |
|
|
429
|
+
| `priority` | `number` | (no tag emitted) | Priority 0.0–1.0. When omitted, no `<priority>` tag is written. |
|
|
430
|
+
| `images` | `SitemapImage[]` | — | Image extension entries — emits `<image:image>` blocks |
|
|
431
|
+
| `videos` | `SitemapVideo[]` | — | Video extension entries — emits `<video:video>` blocks |
|
|
432
|
+
| `news` | `SitemapNews` | — | News extension entry — emits `<news:news>` block |
|
|
427
433
|
|
|
428
434
|
### Constants
|
|
429
435
|
|
|
430
|
-
| Constant
|
|
431
|
-
|
|
|
432
|
-
| `MAX_URLS_PER_SITEMAP`
|
|
436
|
+
| Constant | Value | Description |
|
|
437
|
+
| ------------------------ | ------------ | ------------------------------------------------------------- |
|
|
438
|
+
| `MAX_URLS_PER_SITEMAP` | `50_000` | Maximum URLs allowed per sitemap file (spec limit) |
|
|
433
439
|
| `MAX_SITEMAP_SIZE_BYTES` | `52_428_800` | Maximum sitemap file size in bytes (50 MB = 50 × 1024 × 1024) |
|
|
434
440
|
|
|
435
441
|
---
|
|
@@ -476,25 +482,25 @@ Converts a `SitemapURL[]` to the array format expected by Next.js App Router's `
|
|
|
476
482
|
|
|
477
483
|
All 17 packages are independently installable — use only what you need.
|
|
478
484
|
|
|
479
|
-
| Package
|
|
480
|
-
|
|
|
481
|
-
| [`@power-seo/core`](https://www.npmjs.com/package/@power-seo/core)
|
|
482
|
-
| [`@power-seo/react`](https://www.npmjs.com/package/@power-seo/react)
|
|
483
|
-
| [`@power-seo/meta`](https://www.npmjs.com/package/@power-seo/meta)
|
|
484
|
-
| [`@power-seo/schema`](https://www.npmjs.com/package/@power-seo/schema)
|
|
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)
|
|
487
|
-
| [`@power-seo/preview`](https://www.npmjs.com/package/@power-seo/preview)
|
|
488
|
-
| [`@power-seo/sitemap`](https://www.npmjs.com/package/@power-seo/sitemap)
|
|
489
|
-
| [`@power-seo/redirects`](https://www.npmjs.com/package/@power-seo/redirects)
|
|
490
|
-
| [`@power-seo/links`](https://www.npmjs.com/package/@power-seo/links)
|
|
491
|
-
| [`@power-seo/audit`](https://www.npmjs.com/package/@power-seo/audit)
|
|
492
|
-
| [`@power-seo/images`](https://www.npmjs.com/package/@power-seo/images)
|
|
493
|
-
| [`@power-seo/ai`](https://www.npmjs.com/package/@power-seo/ai)
|
|
494
|
-
| [`@power-seo/analytics`](https://www.npmjs.com/package/@power-seo/analytics)
|
|
495
|
-
| [`@power-seo/search-console`](https://www.npmjs.com/package/@power-seo/search-console)
|
|
496
|
-
| [`@power-seo/integrations`](https://www.npmjs.com/package/@power-seo/integrations)
|
|
497
|
-
| [`@power-seo/tracking`](https://www.npmjs.com/package/@power-seo/tracking)
|
|
485
|
+
| Package | Install | Description |
|
|
486
|
+
| ------------------------------------------------------------------------------------------ | ----------------------------------- | ----------------------------------------------------------------------- |
|
|
487
|
+
| [`@power-seo/core`](https://www.npmjs.com/package/@power-seo/core) | `npm i @power-seo/core` | Framework-agnostic utilities, types, validators, and constants |
|
|
488
|
+
| [`@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 |
|
|
489
|
+
| [`@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 |
|
|
490
|
+
| [`@power-seo/schema`](https://www.npmjs.com/package/@power-seo/schema) | `npm i @power-seo/schema` | Type-safe JSON-LD structured data — 23 builders + 21 React components |
|
|
491
|
+
| [`@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 |
|
|
492
|
+
| [`@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 |
|
|
493
|
+
| [`@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 |
|
|
494
|
+
| [`@power-seo/sitemap`](https://www.npmjs.com/package/@power-seo/sitemap) | `npm i @power-seo/sitemap` | XML sitemap generation, streaming, index splitting, and validation |
|
|
495
|
+
| [`@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 |
|
|
496
|
+
| [`@power-seo/links`](https://www.npmjs.com/package/@power-seo/links) | `npm i @power-seo/links` | Link graph analysis — orphan detection, suggestions, equity scoring |
|
|
497
|
+
| [`@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 |
|
|
498
|
+
| [`@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 |
|
|
499
|
+
| [`@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 |
|
|
500
|
+
| [`@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 |
|
|
501
|
+
| [`@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 |
|
|
502
|
+
| [`@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 |
|
|
503
|
+
| [`@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
504
|
|
|
499
505
|
---
|
|
500
506
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@power-seo/sitemap",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "XML sitemap generation, streaming, and validation with image, video, and news support",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@power-seo/core": "1.0.
|
|
21
|
+
"@power-seo/core": "1.0.10"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"rimraf": "^6.1.3",
|