Socket
Socket
Sign inDemoInstall

nextjs-sitemap-generator

Package Overview
Dependencies
1
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.3 to 0.4.0

29

core.js

@@ -15,4 +15,6 @@ const fs = require("fs");

nextConfigPath,
ignoredExtensions
ignoredExtensions,
pagesConfig
}) {
this.pagesConfig = pagesConfig || {};
this.alternatesUrls = alternateUrls || {};

@@ -34,3 +36,3 @@ this.baseUrl = baseUrl;

if(typeof this.nextConfig === "function"){
if (typeof this.nextConfig === "function") {
this.nextConfig = this.nextConfig([], {});

@@ -128,3 +130,8 @@ }

if (exportPathMap) {
try{
pathMap = await exportPathMap(pathMap, {});
}
catch(err){
console.log(err);
}
}

@@ -138,2 +145,4 @@

let alternates = "";
let priority = "";
let changefreq = "";

@@ -144,7 +153,15 @@ for (let langSite in this.alternatesUrls) {

let xmlObject =
`<url><loc>${this.baseUrl}${pagePath}</loc>` +
alternates +
`<lastmod>${date}</lastmod></url>`;
if (this.pagesConfig && this.pagesConfig[pagePath.toLowerCase()]) {
let pageConfig = this.pagesConfig[pagePath];
priority = pageConfig.priority ? `<priority>${pageConfig.priority}</priority>` : '';
changefreq = pageConfig.changefreq ? `<changefreq>${pageConfig.changefreq}</changefreq>` : '';
}
let xmlObject = `<url><loc>${this.baseUrl}${pagePath}</loc>
${alternates}
${priority}
${changefreq}
<lastmod>${date}</lastmod>
</url>`;
fs.writeFileSync(

@@ -151,0 +168,0 @@ path.resolve(this.targetDirectory, "./sitemap.xml"),

{
"name": "nextjs-sitemap-generator",
"version": "0.3.3",
"version": "0.4.0",
"description": "Generate sitemap.xml from nextjs pages",

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

@@ -38,3 +38,9 @@ ![npmv1](https://img.shields.io/npm/v/nextjs-sitemap-generator.svg)

'jpg'
]
],
pagesConfig: {
'/login': {
priority: '0.5',
changefreq: 'daily'
}
}
});

@@ -51,2 +57,3 @@

- **targetDirectory**: The directory where sitemap.xml going to be written.
- **pagesConfig**: Object configuration of priority and changefreq per route.
- **nextConfigPath**(Used for dynamic routes): Calls `exportPathMap` if exported from `nextConfigPath` js file.

@@ -53,0 +60,0 @@ See this to understand how to do it (https://github.com/zeit/next.js/blob/canary/examples/with-static-export/next.config.js)(OPTIONAL)

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