npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nextjs-sitemap-generator-patch

v0.0.1

Published

Generate sitemap.xml from nextjs pages - patch

Downloads

6

Readme

npmv1 All Contributors

You can make donations for the maintenance of the project. Donate

Simple sitemap.xml mapper for NextJs projects.

Usage

This module have been created to be used at node server side of NextJs. It is meant to be used in server.js so that when the server is initialized it will only run once. If you place it in any of the request handler of the node server performance may be affected.

Usage for static HTML apps

If you are exporting the next project as a static HTML app, create a next-sitemap-generator script file in the base directory. The option pagesDirectory should point to the static files output folder. After generating the output files, run node your_nextjs_sitemap_generator.js to generate the sitemap.

OPTIONS

const sitemap = require('nextjs-sitemap-generator');  

sitemap({  
  alternateUrls: {  
      en: 'https://example.en',  
      es: 'https://example.es',  
      ja: 'https://example.jp',  
      fr: 'https://example.fr',  
  },  
  baseUrl: 'https://example.com',  
  ignoredPaths: ['admin'],  
  pagesDirectory: __dirname + "\\pages",  
  targetDirectory : 'static/',
  nextConfigPath: __dirname + "\\next.config.js",
  ignoredExtensions: [
        'png',
        'jpg'
  ],
  pagesConfig: {
    '/login': {
      priority: '0.5',
      changefreq: 'daily'
    }
  },
  sitemapStylesheet: [
    {
      type: "text/css",
      styleFile: "/test/styles.css"
    },
    {
      type: "text/xsl",
      styleFile: "test/test/styles.xls"
    }
  ]
});

OPTIONS description

  • alternateUrls: You can add the alternate domains corresponding to the available language. (OPTIONAL)
  • baseUrl: The url that it's going to be used at the beginning of each page.
  • ignoreIndexFiles: Whether index file should be in URL or just directory ending with the slash (OPTIONAL)
  • ignoredPaths: File or directory to not map (like admin routes).(OPTIONAL)
  • ignoredExtensions: Ignore files by extension.(OPTIONAL)
  • pagesDirectory: The directory where Nextjs pages live. You can use another directory while they are nextjs pages. It must to be an absolute path.
  • targetDirectory: The directory where sitemap.xml going to be written.
  • pagesConfig: Object configuration of priority and changefreq per route.(OPTIONAL)
  • sitemapStylesheet: Array of style objects that will be applied to sitemap.(OPTIONAL)
  • nextConfigPath(Used for dynamic routes): Calls exportPathMap if exported from nextConfigPath js file. See this to understand how to do it (https://github.com/zeit/next.js/blob/canary/examples/with-static-export/next.config.js) (OPTIONAL)

Considerations

For now the ignoredPaths matches whatever cointaning the thing you put, ignoring if there are files or directories. In the next versions this going to be fixed.

Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!