1.1.0 • Published 4 years ago

@astronomersiva/sitemap-static v1.1.0

Weekly downloads
7
License
MIT
Repository
github
Last release
4 years ago

sitemap-static

Generate a sitemap for a static website based on files on disk.

This is a fork of sitemap-static that adds several features and removes certain existing functionality.

install

npm install --save @astronomersiva/sitemap-static

Usage

let generateSitemap = require('sitemap-static');
let fs = require('fs');

let writer = fs.createWriteStream('/path/to/your/sitemap.xml');

generateSitemap(writer, {
  findRoot: '.',
  ignoreFiles: [/ ** An array of files to ignore in the sitemap */],
  prefix: 'https://www.sivasubramanyam.me/',
  pretty: false
})

findRoot

The base directory whose contents you want a sitemap for.

Ignore Files

An array of files and directories to ignore in the sitemap. Example,

[
  'ignore-me.html',
  'ignore-everything-in-me/'
]

Pretty URLs

If you pass --pretty to the CLI (or pretty: true to the JS API), sitemap-static will output pretty URLs rather than the whole path to each file. For example:

Not prettyPretty
http://www.example.com/index.htmlhttp://www.example.com/
http://www.example.com/about.htmlhttp://www.example.com/about
http://www.example.com/author/index.htmlhttp://www.example.com/author
http://www.example.com/author/main.htmlhttp://www.example.com/author/main

addTrailingSlash

If you pass this as true when --pretty is also true, a trailing slash will be added to the URLs. For example,

!addTrailingSlashaddTrailingSlash
http://www.example.com/http://www.example.com/
http://www.example.com/abouthttp://www.example.com/about/
http://www.example.com/authorhttp://www.example.com/author/
http://www.example.com/author/mainhttp://www.example.com/author/main/