npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@stdian/express-sitemap

v1.9.1

Published

sitemap and robots for expressjs

Downloads

1

Readme

express-sitemap

NPM version

Sitemap and Robots for Express.js 3 and 4

Installation

Install through NPM

npm install @stdian/express-sitemap

or

git clone git://github.com/stdian/express-sitemap.git

API

inside Express.js project

var sitemap = require('express-sitemap')();

var app = require('express')();

sitemap.generate(app);

Methods

if you want to generate your own url

var sitemap = require('express-sitemap');

sitemap({
    map: {
        '/foo': ['get'],
        '/foo2': ['get','post'],
        '/admin': ['get'],
        '/backdoor': [],
    },
    route: {
        '/foo': {
            lastmod: '2014-06-20',
            changefreq: 'always',
            priority: 1.0,
        },
        '/admin': {
            disallow: true,
        },
        '/backdoor': {
            hide: true,
        },
    },
}).XMLtoFile();

and this will be sitemap.xml

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
        <loc>http://127.0.0.1/foo</loc>
        <lastmod>2014-06-19</lastmod>
        <changefreq>always</changefreq>
        <priority>1</priority>
    </url>
    <url>
        <loc>http://127.0.0.1/foo2</loc>
    </url>
</urlset>

and this will be robots.txt

User-agent: *
Disallow: /admin

reset prototype Object for sitemap

sitemap.reset();

generate sitemap (wrapper)

sitemap.generate(app);

generate sitemap from express 4.x configuration. Add an array with Router path if you want use nested callback

sitemap.generate4(app [, Router]);

generate sitemap from express 3.x configuration

sitemap.generate3(app);

generate prototype Object for sitemap if you use middleware or dynamic building

sitemap.tickle();

write sitemap Object to file (set pathname inside module configuration or like argument)

sitemap.XMLtoFile([path]);

write robots.txt to file (set pathname inside module configuration or like argument)

sitemap.TXTtoFile([path]);

write both to files

sitemap.toFile();

stream sitemap to web

sitemap.XMLtoWeb(res);

stream robots.txt to web

sitemap.TXTtoWeb(res);

sitemap(options)

options

  • httpString Website HTTP protocol (http | https) (default "http")
  • cacheInteger Enable cache integration, refresh map after this millisecond value (default "false")
  • urlString Website URL (default "127.0.0.1")
  • portNumber Website Port (default "80")
  • headString Head of XML file (default "")
  • sitemapString Name of sitemap file (default "sitemap.xml")
  • robotsString Name of robots file (default "robots.txt")
  • sitemapSubmissionString Set Sitemap absolute location into robots (default "disable")
  • routeObject Add extra information to sitemap related to this documentation (default "disabled")
  • lastmodDate Integrity not controlled
  • changefreqString Integrity not controlled
  • priorityFloat Integrity not controlled
  • imageString Integrity not controlled
  • alternatepagesArray Add alternate language pages related to this documentation
    • relString Integrity not controlled
    • hreflangString Integrity not controlled
    • hrefString Integrity not controlled
  • allowBoolean Flag for "allow" this route from parsing, and save into robots.txt (default "null")
  • disallowBoolean Flag for "disallow" this route from parsing, and save into robots.txt (default "null")
  • hideBoolean Flag for hide this route from globally parsing (no .xml or .txt) (default "false")
  • mapObject Force route () detection and building (default "disabled")
  • hideByRegexArray Array of RegEx that remove routes from output (default "disabled")
  • generateObject Fastly generate sitemap from express app (default "disabled")

you can use route: {'ALL': {} } if you want to propagate extra information to all your urls

Examples

Take a look at my examples

License GPLv3