sitemap-static
Advanced tools
Comparing version 0.0.0 to 0.1.0
30
index.js
@@ -0,1 +1,3 @@ | ||
#!/usr/bin/env node | ||
var findit = require('findit'), | ||
@@ -6,3 +8,25 @@ argv = require('minimist')(process.argv.slice(2)); | ||
var prefix = argv.prefix; | ||
if (prefix === undefined) { | ||
process.stdout.write('Error: Missing Prefix.\n') | ||
process.stdout.write(' Eg: sitemap-static --prefix=http://www.domain.com\n') | ||
process.exit() | ||
} | ||
if (!prefix.match(/\/$/)) prefix += '/' | ||
var ignore_file = argv['ignore-file']; | ||
var ignore = [] | ||
var ignore_folders = [] | ||
if (ignore_file) { | ||
ignore = require(process.cwd() + '/' + ignore_file); | ||
var len = ignore.length | ||
for (var i = 0; i < len; i++) { | ||
var l = ignore[i].length | ||
if (ignore[i].substr(l-5) !== '.html') { | ||
ignore_folders.push(new RegExp('^' + ignore[i])) | ||
} | ||
} | ||
} | ||
process.stdout.write('<?xml version="1.0" encoding="UTF-8"?>'); | ||
@@ -12,3 +36,7 @@ process.stdout.write('<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'); | ||
finder.on('file', function(file, stat) { | ||
if (file.indexOf('.html') === -1) return; | ||
if (file.indexOf('.html') === -1 || | ||
ignore.indexOf(file) !== -1) return; | ||
for (var i = 0; i < ignore_folders.length; i++) { | ||
if (file.match(ignore_folders[i])) return; | ||
} | ||
process.stdout.write('<url>\n'); | ||
@@ -15,0 +43,0 @@ process.stdout.write('<loc>'); |
{ | ||
"name": "sitemap-static", | ||
"version": "0.0.0", | ||
"version": "0.1.0", | ||
"description": "generate a sitemap for a static website", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -14,2 +14,18 @@ # sitemap-static | ||
sitemap-static --prefix=http://foo.bar/foo/ . | ||
sitemap-static --prefix=http://foo.bar/foo/ . > sitemap.xml | ||
## Ignore File | ||
Added in v0.0.1 you can pass the name of a json file to load. File file needs to be | ||
in your current working directory and should be an array of file names (without the / at the front) | ||
that you want ignored. You can ignore entire directories by leaving off the .html. | ||
Example JSON: | ||
[ | ||
"ignore-me.html", | ||
"ignore-everything-in-me/" | ||
] | ||
Example Command: | ||
sitemap-static --ignore-file=ignore.json --prefix=http://foo.bar/foo/ . > sitemap.xml |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
2947
41
31
1