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 1.0.0 to 2.0.0

72

package.json
{
"name": "sitemaps",
"version": "1.0.0",
"description": "A simple sitemap.xml generator.",
"main": "index.js",
"scripts": {
"test": "mocha \"**/*.test.js\" --exit"
},
"repository": {
"type": "git",
"url": "git+https://github.com/diogocapela/sitemaps.git"
},
"author": "Diogo Capela",
"license": "MIT",
"bugs": {
"url": "https://github.com/diogocapela/sitemaps/issues"
},
"homepage": "https://github.com/diogocapela/sitemaps#readme",
"devDependencies": {
"eslint": "7.7.0",
"eslint-config-airbnb-base": "14.2.0",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-import": "2.22.0",
"eslint-plugin-prettier": "3.1.4",
"lodash": "4.17.20",
"mocha": "8.1.1",
"prettier": "2.0.5"
}
"name": "sitemaps",
"version": "2.0.0",
"description": "A simple sitemap.xml generator.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc",
"test": "mocha \"**/*.test.js\" --exit",
"prepublish": "npm run build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/diogocapela/sitemaps.git"
},
"keywords": [
"sitemap",
"generator",
"xml",
"typescript"
],
"author": "Diogo Capela",
"license": "MIT",
"bugs": {
"url": "https://github.com/diogocapela/sitemaps/issues"
},
"homepage": "https://github.com/diogocapela/sitemaps#readme",
"files": [
"dist/**/*"
],
"devDependencies": {
"@types/lodash": "4.14.191",
"@types/node": "18.14.2",
"@typescript-eslint/eslint-plugin": "5.53.0",
"@typescript-eslint/parser": "5.53.0",
"eslint": "8.35.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-airbnb-typescript": "17.0.0",
"eslint-config-prettier": "8.6.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-prettier": "4.2.1",
"lodash": "4.17.2",
"mocha": "8.1.1",
"prettier": "2.8.4",
"typescript": "4.9.5"
}
}

@@ -8,6 +8,6 @@ # sitemaps

## Install
## Installation
```bash
$ npm i sitemaps --save
npm i sitemaps --save
```

@@ -17,37 +17,77 @@

```javascript
const sitemaps = require('sitemaps');
### `createSitemap()`
const filePath = `${__dirname}/sitemap.xml`;
Generates a sitemap XML file with the custom URLs on the specified path.
const links = [
```typescript
import path from 'path';
import { createSitemap } from 'sitemaps';
createSitemap({
filePath: path.join(__dirname, 'sitemap.xml'),
urls: [
{
loc: 'https://example.com',
priority: '1.00',
changefreq: 'weekly',
loc: 'https://example.com',
lastmod: '2023-01-31',
changefreq: 'weekly',
priority: 1,
},
{
loc: 'https://example.com/about',
priority: '0.80',
changefreq: 'monthly',
loc: 'https://example.com/about',
lastmod: '2022-10-21',
changefreq: 'monthly',
priority: 0.8,
},
{
loc: 'https://example.com/services',
priority: '0.80',
changefreq: 'monthly',
loc: 'https://example.com/contact',
lastmod: '2021-04-30',
changefreq: 'yearly',
priority: 0.4,
},
],
});
// The sitemap.xml file will be created in the specified path.
```
| Attribute | Type | Description |
| ------------ | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `loc` | string (required) | URL of the page. This URL must begin with the protocol (such as http). This value must be less than 2,048 characters. |
| `lastmod` | string (optional) | The date of last modification of the page. This date should be in [W3C Datetime](https://www.w3.org/TR/NOTE-datetime) format. This format allows you to omit the time portion, if desired, and use `YYYY-MM-DD`. |
| `changefreq` | enum (optional) | How frequently the page is likely to change. Valid values are `always`, `hourly`, `daily`, `weekly`, `monthly`, `yearly`, and, `never`. |
| `priority` | number (optional) | The priority of this URL relative to other URLs on your site. Valid values range from `0` to `1`. The default `priority` of a page is `0.5`. |
### `createSitemapIndex()`
Generates a sitemap index XML file with the custom sitemaps on the specified path.
```typescript
import path from 'path';
import { createSitemapIndex } from 'sitemaps';
createSitemapIndex({
filePath: path.join(__dirname, 'sitemap-index.xml'),
sitemaps: [
{
loc: 'https://example.com/contact',
priority: '0.60',
changefreq: 'monthly',
loc: 'https://example.com/sitemap-1.xml',
lastmod: '2023-01-31',
},
];
{
loc: 'https://example.com/sitemap-2.xml',
lastmod: '2023-01-31',
},
],
});
sitemaps(filePath, links);
console.log(`Sitemap.xml generated at: ${filePath}`);
// The sitemapIndex.xml file will be created in the specified path.
```
| Attribute | Type | Description |
| --------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `loc` | string (required) | Identifies the location of the Sitemap. |
| `lastmod` | string (optional) | Identifies the time that the corresponding Sitemap file was modified. The value should be in [W3C Datetime](https://www.w3.org/TR/NOTE-datetime) format. |
| |
## License
Open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
Open source under the terms of the [MIT License](/LICENSE).
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