Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-sitemap-renderer

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-sitemap-renderer

A bare minimum sitemap renderer

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
153
decreased by-4.37%
Maintainers
1
Weekly downloads
 
Created
Source

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

or

$ yarn add simple-sitemap-renderer

🎈 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',
  },
])

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>

API

renderSitemap(entries: Entry[], options?: RenderOptiopns)

returns sitemap xml string.

Entry
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
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.)

Keywords

FAQs

Package last updated on 27 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc