sitemap-manager
Advanced tools
Comparing version 1.1.1 to 2.0.0
@@ -0,1 +1,16 @@ | ||
# [2.0.0](https://github.com/CBW2007/sitemap-manager/compare/v1.1.1...v2.0.0) (2021-07-24) | ||
### Bug Fixes | ||
* **main:** it's urlset instead of urlindex ([90de614](https://github.com/CBW2007/sitemap-manager/commit/90de614156d8db37173d1b71c7410874dc744893)) | ||
### Features | ||
* **stylesheet:** add new stylesheet ([ee91970](https://github.com/CBW2007/sitemap-manager/commit/ee919703431de068e3d1957fdb4835ab256cf91c)) | ||
* v1 -> v2 ([cab316c](https://github.com/CBW2007/sitemap-manager/commit/cab316cdeafa2ac01900003e9d9348f3c99c778e)) | ||
## [1.1.1](https://github.com/CBW2007/sitemap-manager/compare/v1.1.0...v1.1.1) (2021-03-13) | ||
@@ -2,0 +17,0 @@ |
{ | ||
"name": "sitemap-manager", | ||
"version": "1.1.1", | ||
"version": "2.0.0", | ||
"description": "An easy way to create sitemaps!", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"build": "babel src -d dist", | ||
"build": "tsc", | ||
"prepare": "npm run build", | ||
@@ -30,7 +30,6 @@ "pretest": "npm run build", | ||
"devDependencies": { | ||
"@babel/cli": "^7.13.0", | ||
"@babel/core": "^7.13.1", | ||
"@babel/preset-env": "^7.13.5", | ||
"@types/xml": "^1.0.5" | ||
"@tsconfig/node12": "^1.0.9", | ||
"@types/xml": "^1.0.5", | ||
"typescript": "^4.3.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 | ||
todo |
@@ -1,226 +0,23 @@ | ||
const { CreateSitemap, CreateIndexSitemap, CreateSitemapStylesheet } = require('../dist/index') | ||
const { mkDir, rmDir, exists } = require('../dist/utils') | ||
const path = require('path') | ||
const { SitemapManager } = require('../dist/main') | ||
const fs = require('fs') | ||
const data=JSON.parse(` | ||
{ | ||
"data": { | ||
"site": { | ||
"siteMetadata": { | ||
"siteUrl": "https://example.com" | ||
} | ||
}, | ||
"postsQuery": { | ||
"edges": [{ | ||
"node": { | ||
"id": "00a79c3f-0ec9-504e-9b32-28a1f7e0b77a", | ||
"fields": { | ||
"slug": "/test/" | ||
} | ||
} | ||
}, { | ||
"node": { | ||
"id": "ef47f21b-2e7e-58ae-9f70-43b408188969", | ||
"fields": { | ||
"slug": "/blog/one/" | ||
} | ||
} | ||
}, { | ||
"node": { | ||
"id": "a8327a61-e913-5d9b-a21a-48c68fe0628e", | ||
"fields": { | ||
"slug": "/blog/two/" | ||
} | ||
} | ||
}, { | ||
"node": { | ||
"id": "779744c7-13e6-599b-9d4b-deba11f0ecd3", | ||
"fields": { | ||
"slug": "/empty/" | ||
} | ||
} | ||
}, { | ||
"node": { | ||
"id": "2ee42eea-58de-5a56-846c-985f79be3c9b", | ||
"fields": { | ||
"slug": "/" | ||
} | ||
} | ||
}, { | ||
"node": { | ||
"id": "8e823adf-5de6-5a6f-81e3-559faddda74b", | ||
"fields": { | ||
"slug": "/math/" | ||
} | ||
} | ||
}, { | ||
"node": { | ||
"id": "2b123280-0275-54d5-8c5c-7ae5b061fba5", | ||
"fields": { | ||
"slug": "/math/poly/div-mod/" | ||
} | ||
} | ||
}, { | ||
"node": { | ||
"id": "d923ddcc-0e6c-5cc7-88cd-66cf38aefa79", | ||
"fields": { | ||
"slug": "/math/poly/intro/" | ||
} | ||
} | ||
}, { | ||
"node": { | ||
"id": "d95c2b31-f6bd-52bc-8078-8b7f5c5c9912", | ||
"fields": { | ||
"slug": "/math/poly/fft/" | ||
} | ||
} | ||
}, { | ||
"node": { | ||
"id": "e50d721e-5570-50dc-8089-dde25e0727dc", | ||
"fields": { | ||
"slug": "/math/poly/fwt/" | ||
} | ||
} | ||
}, { | ||
"node": { | ||
"id": "9bc90933-d44f-57fe-b36d-1c6ee5d5477e", | ||
"fields": { | ||
"slug": "/math/poly/inv-tri-func/" | ||
} | ||
} | ||
}, { | ||
"node": { | ||
"id": "c4bb4bf7-5b67-525c-b03b-1e653f08df1a", | ||
"fields": { | ||
"slug": "/math/poly/inv/" | ||
} | ||
} | ||
}, { | ||
"node": { | ||
"id": "d02a27a1-7a5d-5722-805b-349185305c8c", | ||
"fields": { | ||
"slug": "/math/poly/lagrange/" | ||
} | ||
} | ||
}, { | ||
"node": { | ||
"id": "492c557d-6279-51e9-9e4d-300114300382", | ||
"fields": { | ||
"slug": "/math/poly/multipoint-eval-interpolation/" | ||
} | ||
} | ||
}, { | ||
"node": { | ||
"id": "8e9b4fe1-6ad9-5917-a948-1cc9c875b523", | ||
"fields": { | ||
"slug": "/math/poly/ln-exp/" | ||
} | ||
} | ||
}, { | ||
"node": { | ||
"id": "23778dce-fb19-5569-ada1-28247a506162", | ||
"fields": { | ||
"slug": "/math/poly/newton/" | ||
} | ||
} | ||
}, { | ||
"node": { | ||
"id": "f71fe369-5225-50bc-8c04-28a882844abb", | ||
"fields": { | ||
"slug": "/math/poly/ntt/" | ||
} | ||
} | ||
}, { | ||
"node": { | ||
"id": "e032c60c-ab98-5a7c-9686-ffbf89018d2a", | ||
"fields": { | ||
"slug": "/math/poly/sqrt/" | ||
} | ||
} | ||
}, { | ||
"node": { | ||
"id": "a9ba831f-b536-5cb9-a7de-1b04b3e82dcf", | ||
"fields": { | ||
"slug": "/math/poly/tri-func/" | ||
} | ||
} | ||
}] | ||
}, | ||
"tagsQuery": { | ||
"group": [{ | ||
"fieldValue": "Chicago" | ||
}, { | ||
"fieldValue": "Chinese" | ||
}, { | ||
"fieldValue": "TEST" | ||
}, { | ||
"fieldValue": "WIP" | ||
}, { | ||
"fieldValue": "animals" | ||
}, { | ||
"fieldValue": "math" | ||
}, { | ||
"fieldValue": "polynomial" | ||
}, { | ||
"fieldValue": "zoos" | ||
}, { | ||
"fieldValue": "中文" | ||
}] | ||
} | ||
} | ||
}`).data | ||
if (fs.existsSync('./public')) | ||
fs.rmdirSync('./public',{recursive: true}) | ||
fs.mkdirSync('./public') | ||
const siteURL = data.site.siteMetadata.siteUrl | ||
const pathPrefix = '/aaa/' | ||
const MySitemap = new SitemapManager({ | ||
siteURL: 'https://example.com/', | ||
pathPrefix: 'aaa' | ||
}) | ||
if (exists('public')) | ||
{ | ||
console.log("delete files from previous test") | ||
rmDir('public', { | ||
recursive: true | ||
}) | ||
} | ||
console.log('create public folder') | ||
mkDir('./public') | ||
mkDir('./public/aaa') | ||
MySitemap.addUrl('aa',[ | ||
{loc: 'https://example.com/aaa/a/'}, | ||
{loc: 'https://example.com/aaa/中文/'}, | ||
{loc: 'https://example.com/aaa/b/', lastmod: new Date()}, | ||
{loc: 'https://example.com/aaa/c/', lastmod: '2021-07-01T08:00:00'}, | ||
]) | ||
console.log('create sitemaps') | ||
CreateSitemap( | ||
path.resolve('./public/aaa/sitemap-articles.xml'), | ||
pathPrefix, | ||
siteURL, | ||
data.postsQuery.edges, | ||
(data) => { return data.node.fields.slug }, | ||
) | ||
CreateSitemap( | ||
path.resolve('./public/aaa/sitemap-logs.xml'), | ||
pathPrefix, | ||
siteURL, | ||
data.postsQuery.edges, | ||
(data) => { return data.node.fields.slug + 'changelog/' }, | ||
) | ||
CreateSitemap( | ||
path.resolve('./public/aaa/sitemap-tags.xml'), | ||
pathPrefix, | ||
siteURL, | ||
data.tagsQuery.group, | ||
(data) => { return `/tags/${data.fieldValue}/` }, | ||
) | ||
CreateSitemap( | ||
path.resolve('./public/aaa/sitemap-pages.xml'), | ||
pathPrefix, | ||
siteURL, | ||
['/pages/', '/settings/'], | ||
(data) => { return data }, | ||
) | ||
CreateIndexSitemap( | ||
path.resolve('./public/aaa/sitemap.xml'), | ||
pathPrefix, | ||
siteURL, | ||
['sitemap-pages.xml', 'sitemap-articles.xml', 'sitemap-logs.xml', 'sitemap-tags.xml'], | ||
) | ||
CreateSitemapStylesheet( | ||
path.resolve('./public/aaa/sitemap.xsl'), | ||
pathPrefix, | ||
siteURL, | ||
) | ||
MySitemap.addUrl('bb',[{loc: 'https://example.com/aaa/ab/'}]) | ||
MySitemap.addUrl('bb',[{loc: 'https://example.com/aaa/ac/'}]) | ||
MySitemap.finish() |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
3
19545
10
229
4
3
1