🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
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

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
131
-20.12%
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

sitemap

FAQs

Package last updated on 13 Nov 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