DEV Community

тars
тars

Posted on

simple-sitemap-renderer: A bare minimum sitemap renderer written in TypeScript

If you're looking for a easy to use sitemap renderer and don't need extra features like extended sitemap or sitemap index files, this library might be helpful.

💻 Installation

$ npm i simple-sitemap-renderer
Enter fullscreen mode Exit fullscreen mode

or

yarn add simple-sitemap-renderer
Enter fullscreen mode Exit fullscreen mode

🎈 Usage

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',
  },
])
Enter fullscreen mode Exit fullscreen mode

Rendered Result

the sample here is formatted for readability, but actual result will always be minified.

<?xml version="1.0" encoding="UTF-8"?>
<urlset>
  <url>
    <loc>https://your-site/your-page-1</loc>
    <lastmod>2020-10-10</lastmod>
    <changefreq>always</changefreq>
    <priority>0.8</priority>
  </url>
  <url>
    <loc>https://your-site/your-page-2</loc>
    <lastmod>2020-10-10</lastmod>
  </url>
  <url>
    <loc>https://your-site/your-page-3</loc>
  </url>
</urlset>
Enter fullscreen mode Exit fullscreen mode

More info

GitHub logo tars0x9752 / simple-sitemap-renderer

A bare minimum sitemap renderer written in TypeScript.

simple-sitemap-renderer

A bare minimum sitemap renderer written in TypeScript.

Features

  • Render standard sitemap XML
  • Zero-dependencies
  • Written in TypeScript

💻 Installation

$ npm i simple-sitemap-renderer
Enter fullscreen mode Exit fullscreen mode

or

yarn add simple-sitemap-renderer
Enter fullscreen mode Exit fullscreen mode

🎈 Usage

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',
  },
])
Enter fullscreen mode Exit fullscreen mode

Rendered Result

the sample here is formatted for readability, but actual result will always be minified.

<?xml version="1.0" encoding="UTF-8"?&gt
<urlset&gt
  <url&gt
    <loc>https://your-site/your-page-1</loc>
    <lastmod>2020-10-10</lastmod>
    <changefreq>always</changefreq>
    <priority>0.8</priority>
  </url>
  <url>
    <loc>https://your-site/your-page-2</loc>
    <lastmod>2020-10-10</lastmod>
  </
Enter fullscreen mode Exit fullscreen mode

Top comments (0)