@robinpath/sitemap
0.1.1Node.jsPublicXML sitemap generation, parsing, validation, and manipulation with image/video/alternate support
Sitemap
XML sitemap generation, parsing, validation, and manipulation with image/video/alternate support
Package: @robinpath/sitemap | Category: Web | Type: Utility
Authentication
No authentication required. All functions are available immediately.
Use Cases
Use the sitemap module when you need to:
- Create XML sitemap -- Use
sitemap.createto perform this operation - Create sitemap index -- Use
sitemap.createIndexto perform this operation - Parse XML sitemap -- Use
sitemap.parseto perform this operation - Parse sitemap index -- Use
sitemap.parseIndexto perform this operation - Add URL to sitemap XML -- Use
sitemap.addUrlto perform this operation
Quick Reference
| Function | Description | Returns |
|---|---|---|
create | Create XML sitemap | XML sitemap |
createIndex | Create sitemap index | XML sitemap index |
parse | Parse XML sitemap | Array of URL objects |
parseIndex | Parse sitemap index | Array of {loc, lastmod} |
addUrl | Add URL to sitemap XML | Updated XML |
removeUrl | Remove URL from sitemap XML | Updated XML |
filterByChangefreq | Filter URLs by change frequency | Filtered URLs |
filterByPriority | Filter URLs by priority range | Filtered URLs |
sortByPriority | Sort URLs by priority | Sorted URLs |
sortByLastmod | Sort URLs by last modified | Sorted URLs |
count | Count URLs in sitemap | URL count |
extractLocs | Extract all loc URLs | Array of URL strings |
validate | Validate sitemap XML | {valid, errors[], urlCount} |
Functions
create
Create XML sitemap
Module: sitemap | Returns: string -- XML sitemap
sitemap.create [{"loc": "https://example.com/", "priority": 1.0}]
| Parameter | Type | Required | Description |
|---|---|---|---|
urls | array | Yes | Array of {loc, lastmod, changefreq, priority, images, videos, alternates} |
options | object | No | {pretty} |
createIndex
Create sitemap index
Module: sitemap | Returns: string -- XML sitemap index
sitemap.createIndex [{"loc": "https://example.com/sitemap1.xml"}]
| Parameter | Type | Required | Description |
|---|---|---|---|
sitemaps | array | Yes | Array of {loc, lastmod} |
parse
Parse XML sitemap
Module: sitemap | Returns: array -- Array of URL objects
sitemap.parse $xml
| Parameter | Type | Required | Description |
|---|---|---|---|
xml | string | Yes | XML sitemap content |
parseIndex
Parse sitemap index
Module: sitemap | Returns: array -- Array of {loc, lastmod}
sitemap.parseIndex $xml
| Parameter | Type | Required | Description |
|---|---|---|---|
xml | string | Yes | XML sitemap index |
addUrl
Add URL to sitemap XML
Module: sitemap | Returns: string -- Updated XML
sitemap.addUrl $xml {"loc": "https://example.com/new"}
| Parameter | Type | Required | Description |
|---|---|---|---|
xml | string | Yes | Existing sitemap XML |
url | object | Yes | URL object |
removeUrl
Remove URL from sitemap XML
Module: sitemap | Returns: string -- Updated XML
sitemap.removeUrl $xml "https://example.com/old"
| Parameter | Type | Required | Description |
|---|---|---|---|
xml | string | Yes | Sitemap XML |
loc | string | Yes | URL to remove |
filterByChangefreq
Filter URLs by change frequency
Module: sitemap | Returns: array -- Filtered URLs
sitemap.filterByChangefreq $urls "daily"
| Parameter | Type | Required | Description |
|---|---|---|---|
urls | array | Yes | Parsed URLs |
changefreq | string | Yes | Frequency |
filterByPriority
Filter URLs by priority range
Module: sitemap | Returns: array -- Filtered URLs
sitemap.filterByPriority $urls 0.8 1.0
| Parameter | Type | Required | Description |
|---|---|---|---|
urls | array | Yes | Parsed URLs |
min | number | Yes | Min priority |
max | number | No | Max priority |
sortByPriority
Sort URLs by priority
Module: sitemap | Returns: array -- Sorted URLs
sitemap.sortByPriority $urls
| Parameter | Type | Required | Description |
|---|---|---|---|
urls | array | Yes | Parsed URLs |
descending | boolean | No | Descending (default true) |
sortByLastmod
Sort URLs by last modified
Module: sitemap | Returns: array -- Sorted URLs
sitemap.sortByLastmod $urls
| Parameter | Type | Required | Description |
|---|---|---|---|
urls | array | Yes | Parsed URLs |
descending | boolean | No | Descending (default true) |
count
Count URLs in sitemap
Module: sitemap | Returns: number -- URL count
sitemap.count $urls
| Parameter | Type | Required | Description |
|---|---|---|---|
urls | array | Yes | Parsed URLs |
extractLocs
Extract all loc URLs
Module: sitemap | Returns: array -- Array of URL strings
sitemap.extractLocs $urls
| Parameter | Type | Required | Description |
|---|---|---|---|
urls | array | Yes | Parsed URLs |
validate
Validate sitemap XML
Module: sitemap | Returns: object -- {valid, errors[], urlCount}
sitemap.validate $xml
| Parameter | Type | Required | Description |
|---|---|---|---|
xml | string | Yes | Sitemap XML |
Error Handling
All functions throw on failure. Common errors:
| Error | Cause |
|---|---|
| (standard errors) | Check function parameters and authentication |
@desc "Create and validate result"
do
set $result as sitemap.create [{"loc": "https://example.com/", "priority": 1.0}]
if $result != null
print "Success"
else
print "No result"
end
enddo
Recipes
1. Create a new item with create
Create a new resource and capture the result.
set $result as sitemap.create [{"loc": "https://example.com/", "priority": 1.0}]
print "Created: " + $result
2. Multi-step Sitemap workflow
Chain multiple sitemap operations together.
@desc "Create, create index, and more"
do
set $r_create as sitemap.create [{"loc": "https://example.com/", "priority": 1.0}]
set $r_createIndex as sitemap.createIndex [{"loc": "https://example.com/sitemap1.xml"}]
set $r_parse as sitemap.parse $xml
print "All operations complete"
enddo
3. Safe create with validation
Check results before proceeding.
@desc "Create and validate result"
do
set $result as sitemap.create [{"loc": "https://example.com/", "priority": 1.0}]
if $result != null
print "Success: " + $result
else
print "Operation returned no data"
end
enddo
Related Modules
- json -- JSON module for complementary functionality
Versions (1)
| Version | Tag | Published |
|---|---|---|
| 0.1.1 | latest | 1 months ago |
Related Modules
ftp
JS@robinpathv0.1.3
FTP and SFTP file transfer operations
http
JS@robinpathv0.1.3
HTTP server for RobinPath scripts. Register routes with static responses (JSON, HTML, files), enable CORS, serve static directories. No callbacks needed.
form
JS@robinpathv0.2.1
Declarative form builder for RobinPath scripts � define fields inline, generate schemas, validate submissions
api
JS@robinpathv0.1.2
HTTP client for making requests to external APIs with profiles, auth, download/upload, and auto-JSON parsing
$ robinpath add @robinpath/sitemap
