DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 964,423 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Ρ‚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)

Take a look at this:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. πŸ›