New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sitemap-manager

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sitemap-manager - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

scripts/test.js

18

CHANGELOG.md

@@ -0,1 +1,19 @@

# [1.1.0](https://github.com/CBW2007/sitemap-manager/compare/v1.0.0...v1.1.0) (2021-03-11)
### Bug Fixes
* **stylesheet:** fix slogan in the stylesheet file ([de03185](https://github.com/CBW2007/sitemap-manager/commit/de03185339ace1d018ecc1e910a452d3808e9b8f))
### Features
* allow to customize output file ([79aab94](https://github.com/CBW2007/sitemap-manager/commit/79aab94819582f9ca1a914e9b162e13e126c8355))
### Others
* remove reporter,just throw the error ([698d06e](https://github.com/CBW2007/sitemap-manager/commit/698d06e44708f822a839c4d11fcccdd7e68522c7))
# 1.0.0 (2021-02-28)

@@ -2,0 +20,0 @@

8

dist/CreateIndexSitemap.js

@@ -22,3 +22,3 @@ "use strict";

async function CreateIndexSitemap(pathPrefix, siteURL, data, reporter) {
function CreateIndexSitemap(outFile, pathPrefix, siteURL, data) {
let xmlData = '';

@@ -38,6 +38,6 @@ const lastModified = (0, _moment.default)(new Date(), _moment.default.ISO_8601).toISOString();

try {
await utils.writeFile('./public/sitemap.xml', xmlData);
} catch (error) {
reporter.panicOnBuild('Failed to write sitemap.xml .');
utils.writeFile(outFile, xmlData);
} catch (e) {
throw new Error(`Failed to write ${outFile}:\n ${e.message}`);
}
}

@@ -22,3 +22,3 @@ "use strict";

async function CreateSitemap(name, pathPrefix, siteURL, data, pathResolver, reporter) {
function CreateSitemap(outFile, pathPrefix, siteURL, data, pathResolver) {
let xmlData = '';

@@ -38,6 +38,6 @@ const lastModified = (0, _moment.default)(new Date(), _moment.default.ISO_8601).toISOString();

try {
await utils.writeFile(`./public/sitemap-${name}.xml`, xmlData);
} catch (error) {
reporter.panicOnBuild(`Failed to write sitemap-${name}.xml .`);
utils.writeFile(outFile, xmlData);
} catch (e) {
throw new Error(`Failed to write ${outFile}:\n ${e.message}`);
}
}

@@ -18,3 +18,3 @@ "use strict";

async function CreateSitemapStylesheet(pathPrefix, siteUrl) {
function CreateSitemapStylesheet(outFile, pathPrefix, siteUrl) {
// Replace the `{{blog-url}}` variable with our real site URL

@@ -24,3 +24,7 @@ const sitemapStylesheet = utils.xmlStylesheetTemplate(new URL(_path.default.join(pathPrefix, 'sitemap.xml'), siteUrl).toString()); // Save the updated stylesheet to the public folder, so it will be

await utils.writeFile(_path.default.join('./public', 'sitemap.xsl'), sitemapStylesheet);
try {
utils.writeFile(outFile, sitemapStylesheet);
} catch (e) {
throw new Error(`Failed to write ${outFile}:\n ${e.message}`);
}
}

@@ -6,14 +6,18 @@ "use strict";

});
exports.xmlStylesheetTemplate = exports.sitemapIndexTemplate = exports.sitemapTemplate = exports.readFile = exports.writeFile = void 0;
exports.xmlStylesheetTemplate = exports.sitemapIndexTemplate = exports.sitemapTemplate = exports.exists = exports.rmDir = exports.mkDir = exports.readFile = exports.writeFile = void 0;
var _fs = _interopRequireDefault(require("fs"));
var _pify = _interopRequireDefault(require("pify"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const writeFile = (0, _pify.default)(_fs.default.writeFile);
const writeFile = _fs.default.writeFileSync;
exports.writeFile = writeFile;
const readFile = (0, _pify.default)(_fs.default.readFile);
const readFile = _fs.default.readFileSync;
exports.readFile = readFile;
const mkDir = _fs.default.mkdirSync;
exports.mkDir = mkDir;
const rmDir = _fs.default.rmdirSync;
exports.rmDir = rmDir;
const exists = _fs.default.existsSync;
exports.exists = exists;

@@ -95,3 +99,3 @@ const sitemapTemplate = data => {

<p class="desc">
Advanced Sitemap for search engine consumption, by <a href="https://ghost.org">Ghost</a>.
Advanced Sitemap for search engine consumption, powered by <a href="https://github.com/CBW2007/sitemap-manager">sitemap manager</a>, stylesheet by <a href="https://ghost.org">Ghost</a>.
</p>

@@ -98,0 +102,0 @@ <xsl:if test="count(sitemap:sitemapindex/sitemap:sitemap) &gt; 0">

{
"name": "sitemap-manager",
"version": "1.0.0",
"version": "1.1.0",
"description": "An easy way to create sitemaps!",

@@ -9,3 +9,4 @@ "main": "dist/index.js",

"prepare": "npm run build",
"test": "echo \"Error: no test specified\" && exit 1"
"pretest": "npm run build",
"test": "node scripts/test.js"
},

@@ -27,3 +28,2 @@ "repository": {

"moment": "^2.29.1",
"pify": "^5.0.0",
"xml": "^1.0.1"

@@ -35,5 +35,4 @@ },

"@babel/preset-env": "^7.13.5",
"@types/pify": "^5.0.0",
"@types/xml": "^1.0.5"
}
}
# sitemap-manager
An easy way to create sitemaps!
## Features
Quick, Fast, And Beautiful!
## Usage
First run
```shell
$ npm i sitemap-manager --save
or
$ yarn add sitemap-manager
```
Then just try it:
```js
const { CreateSitemap, CreateIndexSitemap, CreateSitemapStylesheet } = require('sitemap-manager')
const data = {/* data here */} //see more in scripts/test.js
const siteURL = data.site.siteMetadata.siteUrl
const pathPrefix = '/aaa/'
// Create Sitemaps for each kind of pages.
CreateSitemap(
path.resolve('./public/sitemap-articles.xml'), // The path of the file which will be generated.
pathPrefix, // Prefix of the path. If your site doesn't at the root of the domain,just try this.
// Example:
// given path: /foo/
// handled path: /aaa/foo/
siteURL, // The domain of your site.
data.postsQuery.edges, // Your data, shoud be an array
(data) => { return data.node.fields.slug }, // How to turn the data to a path
)
CreateSitemap(
path.resolve('./public/sitemap-logs.xml'),
pathPrefix,
siteURL,
data.postsQuery.edges,
(data) => { return data.node.fields.slug + 'changelog/' },
)
CreateSitemap(
path.resolve('./public/sitemap-tags.xml'),
pathPrefix,
siteURL,
data.tagsQuery.group,
(data) => { return `/tags/${data.fieldValue}/` },
)
CreateSitemap(
path.resolve('./public/sitemap-pages.xml'),
pathPrefix,
siteURL,
['/pages/', '/settings/'],
(data) => { return data },
)
// Create an index for all sitemaps.
CreateIndexSitemap(
path.resolve('./public/sitemap.xml'), // The path of the file which will be generated.
pathPrefix, // Prefix of the path. If your site doesn't at the root of the domain,just try this.
siteURL, // The domain of your site.
['sitemap-pages.xml', 'sitemap-articles.xml', 'sitemap-logs.xml', 'sitemap-tags.xml'], // All the sitemaps should be here.
)
// Create the xml template file.
// !IMPORTANT
// Should be at the same dir as any other sitemaps.
// E.g.
// |
// \
// aaa
// | sitemap.xml
// | sitemap.xsl
// | sitemap-artcles.xml
// | sitemap-logs.xml
// ...
CreateSitemapStylesheet(
path.resolve('./public/sitemap.xsl'), // The path of the file which will be generated.
pathPrefix, // Prefix of the path. If your site doesn't at the root of the domain,just try this.
siteURL, // The domain of your site.
)
```
## LICENSE
MIT

@@ -6,3 +6,3 @@ import * as utils from './utils'

export default async function CreateIndexSitemap (pathPrefix, siteURL, data, reporter) {
export default function CreateIndexSitemap (outFile, pathPrefix, siteURL, data) {
let xmlData = ''

@@ -20,6 +20,6 @@ const lastModified = moment(new Date(), moment.ISO_8601).toISOString()

try {
await utils.writeFile('./public/sitemap.xml', xmlData)
} catch (error) {
reporter.panicOnBuild('Failed to write sitemap.xml .')
utils.writeFile(outFile, xmlData)
} catch (e) {
throw new Error(`Failed to write ${outFile}:\n ${e.message}`)
}
}

@@ -6,3 +6,3 @@ import * as utils from './utils'

export default async function CreateSitemap (name, pathPrefix, siteURL, data, pathResolver, reporter) {
export default function CreateSitemap (outFile, pathPrefix, siteURL, data, pathResolver) {
let xmlData = ''

@@ -20,6 +20,6 @@ const lastModified = moment(new Date(), moment.ISO_8601).toISOString()

try {
await utils.writeFile(`./public/sitemap-${name}.xml`, xmlData)
} catch (error) {
reporter.panicOnBuild(`Failed to write sitemap-${name}.xml .`)
utils.writeFile(outFile, xmlData)
} catch (e) {
throw new Error(`Failed to write ${outFile}:\n ${e.message}`)
}
}
import * as utils from './utils'
import path from 'path'
export default async function CreateSitemapStylesheet (pathPrefix, siteUrl) {
export default function CreateSitemapStylesheet (outFile, pathPrefix, siteUrl) {

@@ -11,3 +11,7 @@ // Replace the `{{blog-url}}` variable with our real site URL

// available for the xml sitemap files
await utils.writeFile(path.join('./public', 'sitemap.xsl'), sitemapStylesheet)
try {
utils.writeFile(outFile, sitemapStylesheet)
} catch (e) {
throw new Error(`Failed to write ${outFile}:\n ${e.message}`)
}
}
import fs from 'fs'
import pify from 'pify'
export const writeFile = pify(fs.writeFile)
export const readFile = pify(fs.readFile)
export const writeFile = fs.writeFileSync
export const readFile = fs.readFileSync
export const mkDir = fs.mkdirSync
export const rmDir = fs.rmdirSync
export const exists = fs.existsSync

@@ -72,3 +74,3 @@ export const sitemapTemplate = (data) => { return `<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="sitemap.xsl"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">${data}</urlset>` }

<p class="desc">
Advanced Sitemap for search engine consumption, by <a href="https://ghost.org">Ghost</a>.
Advanced Sitemap for search engine consumption, powered by <a href="https://github.com/CBW2007/sitemap-manager">sitemap manager</a>, stylesheet by <a href="https://ghost.org">Ghost</a>.
</p>

@@ -75,0 +77,0 @@ <xsl:if test="count(sitemap:sitemapindex/sitemap:sitemap) &gt; 0">

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc