Socket
Socket
Sign inDemoInstall

sitemaps

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1 to 0.0.2

.travis.yml

2

package.json
{
"name": "sitemaps",
"version": "0.0.1",
"version": "0.0.2",
"description": "A simple sitemap.xml generator.",

@@ -5,0 +5,0 @@ "main": "index.js",

# sitemaps
[![](https://img.shields.io/npm/v/sitemaps.svg)](https://www.npmjs.com/package/sitemaps)
[![NPM](https://img.shields.io/npm/v/sitemaps.svg)](https://www.npmjs.com/package/sitemaps)
[![Build Status](https://travis-ci.org/diogocapela/sitemaps.svg?branch=master)](https://travis-ci.org/diogocapela/sitemaps)

@@ -18,3 +19,5 @@ A simple sitemap.xml generator.

const highPriority = ['https://example.com'];
const highPriority = [
'https://example.com',
];
const lowPriority = [

@@ -33,21 +36,7 @@ 'https://example.com/about',

console.log(`Sitemap.xml generated at: ${filePath}`);
console.log(xml);
});
```
## Scripts
```bash
# Install all the dependencies
$ npm i
# Run the tests
$ npm run test
# Delete node_modules and package-lock.json
$ npm run clean
```
## License
Open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
const fs = require('fs');
module.exports = (highPriority, lowPriority, filePath, callback) => {
let XML = '<?xml version="1.0" encoding="UTF-8"?>\n\n';
const timestamp = new Date().toISOString();
let xml = '<?xml version="1.0" encoding="UTF-8"?>\n\n';
XML += '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"\n';
XML += '\txmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n';
XML += '\txsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9\n';
XML += '\thttp://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">\n\n';
xml += '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"\n';
xml += '\txmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n';
xml += '\txsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9\n';
xml += '\thttp://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">\n\n';
highPriority.forEach((link) => {
XML += '\t<url>\n';
XML += `\t\t<loc>${link}</loc>\n`;
XML += `\t\t<lastmod>${new Date().toISOString()}</lastmod>\n`;
XML += '\t\t<priority>1.00</priority>\n';
XML += '\t</url>\n';
xml += '\t<url>\n';
xml += `\t\t<loc>${link}</loc>\n`;
xml += `\t\t<lastmod>${timestamp}</lastmod>\n`;
xml += '\t\t<priority>1.00</priority>\n';
xml += '\t</url>\n';
});
lowPriority.forEach((link) => {
XML += '\t<url>\n';
XML += `\t\t<loc>${link}</loc>\n`;
XML += `\t\t<lastmod>${new Date().toISOString()}</lastmod>\n`;
XML += '\t\t<priority>0.80</priority>\n';
XML += '\t</url>\n';
xml += '\t<url>\n';
xml += `\t\t<loc>${link}</loc>\n`;
xml += `\t\t<lastmod>${timestamp}</lastmod>\n`;
xml += '\t\t<priority>0.80</priority>\n';
xml += '\t</url>\n';
});
XML += '\n</urlset>\n';
xml += '\n</urlset>\n';
fs.writeFile(filePath, XML, (error) => {
fs.writeFile(filePath, xml, (error) => {
if (error) {
callback(null, error);
} else {
callback(XML, null);
callback(xml, null);
}
});
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc