A bare minimum sitemap renderer
npm install simple-sitemap-rendererA bare minimum sitemap renderer written in TypeScript.
- Render standard sitemap XML
- Zero-dependencies
- Written in TypeScript
``sh`
$ npm i simple-sitemap-renderer
or
`sh`
$ yarn add simple-sitemap-renderer
`ts
import { renderSitemap } from 'simple-sitemap-renderer'
renderSitemap([
{
url: 'https://your-site/your-page-1',
lastmod: '2020-10-10',
changefreq: 'always',
priority: 0.8,
},
{
url: 'https://your-site/your-page-2',
lastmod: '2020-10-10',
},
{
url: 'https://your-site/your-page-3',
},
])
`
> the sample here is formatted for readability, but actual result will always be minified.
`xml`
returns sitemap xml string.
#### Entry
`ts`
type Entry = {
url: string
lastmod?: string // yyyy-mm-dd
changefreq?: ChangeFreq // always|hourly|daily|weekly|monthly|yearly|never
priority?: number // 0.0 ~ 1.0
}
#### RenderOptiopns
`ts`
type RenderOptiopns = {
encodeUrl?: boolean
}
- encodeUrl`: If you want this libary to encode urls for you, set it to true. (Otherwise, you don't need this option.)