1.8.0 • Published 7 years ago

express-sitemap v1.8.0

Weekly downloads
1,942
License
GPL-3.0
Repository
github
Last release
7 years ago

express-sitemap

NPM version Linux Status Windows Status Dependency Status Coveralls

Sitemap and Robots for expressjs 3 and 4

Installation

Install through NPM

npm install express-sitemap

or

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

API

inside expressjs project

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

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

sitemap.generate(app);

Methods

if you want 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

  • http - String Website HTTP protocol (http | https) (default "http")
  • cache - Integer Enable cache integration, refresh map after this millisecond value (default "false")
  • url - String Website URL (default "127.0.0.1")
  • port - Number Website Port (default "80")
  • sitemap - String Name of sitemap file (default "sitemap.xml")
  • robots - String Name of robots file (default "robots.txt")
  • sitemapSubmission - String Set Sitemap absolute location into robots (default "disable")
  • route - Object Add extra information to sitemap related to this documentation (default "disabled")
  • lastmod - Date Integrity not controlled
  • changefreq - String Integrity not controlled
  • priority - Float Integrity not controlled
  • alternatepages - Array Add alternate language pages related to this documentation
    • rel - String Integrity not controlled
    • hreflang - String Integrity not controlled
    • href - String Integrity not controlled
  • allow - Boolean Flag for "allow" this route from parsing, and save into robots.txt (default "null")
  • disallow - Boolean Flag for "disallow" this route from parsing, and save into robots.txt (default "null")
  • hide - Boolean Flag for hide this route from globally parsing (no .xml or .txt) (default "false")
  • map - Object Force route () detection and building (default "disabled")
  • hideByRegex - Array Array of RegEx that remove routes from output (default "disabled")
  • generate - Object Fastly generate sitemap from express app (default "disabled")

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

Examples

Take a look at my examples

License GPLv3

1.8.0

7 years ago

1.7.0

7 years ago

1.6.5

8 years ago

1.6.4

8 years ago

1.6.3

8 years ago

1.6.2

8 years ago

1.6.1

9 years ago

1.6.0

9 years ago

1.5.6

9 years ago

1.5.5

9 years ago

1.5.4

9 years ago

1.5.3

9 years ago

1.5.2

9 years ago

1.5.1

9 years ago

1.5.0

9 years ago

1.4.0

9 years ago

1.3.8

9 years ago

1.3.7

10 years ago

1.3.6

10 years ago

1.3.5

10 years ago

1.3.4

10 years ago

1.3.3

10 years ago

1.3.2

10 years ago

1.3.1

10 years ago

1.3.0

10 years ago

1.2.3

10 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago