Giter Site home page Giter Site logo

sergeymyssak / nextjs-sitemap Goto Github PK

View Code? Open in Web Editor NEW
121.0 1.0 5.0 318 KB

Generate dynamic sitemap.xml for Next.js projects following the example of Google!

JavaScript 3.24% TypeScript 96.76%
sitemap sitemap-xml sitemap-generator sitemap-builder nextjs sitemap-generation

nextjs-sitemap's Introduction

Next.js sitemap generator

Version Downloads ISC License

Generate dynamic sitemap.xml for Next.js projects following the example of Google!

  • Support for nextjs.config.js
  • Support for dynamic routes
  • Support for localization
  • Support for multiple sitemaps

Checkout the examples folder for source code.

Documentation

Installation

Open a Terminal in the project root and run:

npm install @sergeymyssak/nextjs-sitemap

or

yarn add @sergeymyssak/nextjs-sitemap

Quick start

Example src folder:

└── src
    └── pages
        ├── projects
        │   ├── computers
        │   │   ├── laptop.js
        │   │   └── pc.js
        │   └── phones
        │       ├── android.js
        │       └── ios.js
        ├── admin
        │   ├── account.js
        │   └── cms.js
        └── index.js

All static routes from pages folder will be automatically added to the sitemap.

// import { configureSitemap } from '@sergeymyssak/nextjs-sitemap';
const { configureSitemap } = require('@sergeymyssak/nextjs-sitemap');

const Sitemap = configureSitemap({
  domains: [{ domain: 'example.com', defaultLocale: 'en', http: true }],
  exclude: ['/admin/*'],
  excludeIndex: true,
  pagesConfig: {
    '/projects/*': {
      priority: '0.5',
      changefreq: 'daily',
    },
  },
  trailingSlash: true,
  targetDirectory: __dirname + '/public',
  pagesDirectory: __dirname + '/src/pages',
});

Sitemap.generateSitemap();
Look at the generated sitemap.xml

<?xml version="1.0" encoding="UTF-8" ?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" 
    xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:xhtml="http://www.w3.org/1999/xhtml">
    <url>
        <loc>http://example.com/</loc>
        <lastmod>2021-09-12</lastmod>
        <xhtml:link rel="alternate" hreflang="en" href="http://example.com/" />
    </url>
    <url>
        <loc>http://example.com/projects/computers/laptop/</loc>
        <lastmod>2021-09-12</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.5</priority>
        <xhtml:link rel="alternate" hreflang="en" href="http://example.com/projects/computers/laptop/" />
    </url>
    <url>
        <loc>http://example.com/projects/computers/pc/</loc>
        <lastmod>2021-09-12</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.5</priority>
        <xhtml:link rel="alternate" hreflang="en" href="http://example.com/projects/computers/pc/" />
    </url>
    <url>
        <loc>http://example.com/projects/phones/android/</loc>
        <lastmod>2021-09-12</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.5</priority>
        <xhtml:link rel="alternate" hreflang="en" href="http://example.com/projects/phones/android/" />
    </url>
    <url>
        <loc>http://example.com/projects/phones/ios/</loc>
        <lastmod>2021-09-12</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.5</priority>
        <xhtml:link rel="alternate" hreflang="en" href="http://example.com/projects/phones/ios/" />
    </url>
</urlset>

With exportPathMap

If you specify nextConfigPath prop, then all values indicated in the exportPathMap will be automatically added (pages folder will be ignored).

// import { configureSitemap } from '@sergeymyssak/nextjs-sitemap';
const { configureSitemap } = require('@sergeymyssak/nextjs-sitemap');

const Sitemap = configureSitemap({
  exclude: ['/admin'],
  excludeIndex: true,
  pagesConfig: {
    '/p/*': {
      priority: '0.5',
      changefreq: 'daily',
    },
  },
  nextConfigPath: __dirname + '/next.config.js',
  targetDirectory: __dirname + '/public',
  pagesDirectory: __dirname + '/src/pages',
});

Sitemap.generateSitemap();
Example of exportPathMap in next.config.js

module.exports = {
  i18n: {
    domains: [
      {
        domain: 'example.com',
        defaultLocale: 'en',
        locales: ['en-US', 'en-CA'],
      },
    ],
  },
  trailingSlash: true,
  exportPathMap: async function () {
    return {
      '/': { page: '/' },
      '/admin': { page: '/admin' },
      '/p/learn-nextjs': { page: '/post', query: { title: 'learn-nextjs' } },
    };
  },
};

Look at the generated sitemap.xml

<?xml version="1.0" encoding="UTF-8" ?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" 
    xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:xhtml="http://www.w3.org/1999/xhtml">
    <url>
        <loc>https://example.com/</loc>
        <lastmod>2021-09-12</lastmod>
        <xhtml:link rel="alternate" hreflang="en" href="https://example.com/" />
        <xhtml:link rel="alternate" hreflang="en-US" href="https://example.com/en-US/" />
        <xhtml:link rel="alternate" hreflang="en-CA" href="https://example.com/en-CA/" />
    </url>
    <url>
        <loc>https://example.com/en-US/</loc>
        <lastmod>2021-09-12</lastmod>
        <xhtml:link rel="alternate" hreflang="en" href="https://example.com/" />
        <xhtml:link rel="alternate" hreflang="en-US" href="https://example.com/en-US/" />
        <xhtml:link rel="alternate" hreflang="en-CA" href="https://example.com/en-CA/" />
    </url>
    <url>
        <loc>https://example.com/en-CA/</loc>
        <lastmod>2021-09-12</lastmod>
        <xhtml:link rel="alternate" hreflang="en" href="https://example.com/" />
        <xhtml:link rel="alternate" hreflang="en-US" href="https://example.com/en-US/" />
        <xhtml:link rel="alternate" hreflang="en-CA" href="https://example.com/en-CA/" />
    </url>
    <url>
        <loc>https://example.com/p/learn-nextjs/</loc>
        <lastmod>2021-09-12</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.5</priority>
        <xhtml:link rel="alternate" hreflang="en" href="https://example.com/p/learn-nextjs/" />
        <xhtml:link rel="alternate" hreflang="en-US" href="https://example.com/en-US/p/learn-nextjs/" />
        <xhtml:link rel="alternate" hreflang="en-CA" href="https://example.com/en-CA/p/learn-nextjs/" />
    </url>
    <url>
        <loc>https://example.com/en-US/p/learn-nextjs/</loc>
        <lastmod>2021-09-12</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.5</priority>
        <xhtml:link rel="alternate" hreflang="en" href="https://example.com/p/learn-nextjs/" />
        <xhtml:link rel="alternate" hreflang="en-US" href="https://example.com/en-US/p/learn-nextjs/" />
        <xhtml:link rel="alternate" hreflang="en-CA" href="https://example.com/en-CA/p/learn-nextjs/" />
    </url>
    <url>
        <loc>https://example.com/en-CA/p/learn-nextjs/</loc>
        <lastmod>2021-09-12</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.5</priority>
        <xhtml:link rel="alternate" hreflang="en" href="https://example.com/p/learn-nextjs/" />
        <xhtml:link rel="alternate" hreflang="en-US" href="https://example.com/en-US/p/learn-nextjs/" />
        <xhtml:link rel="alternate" hreflang="en-CA" href="https://example.com/en-CA/p/learn-nextjs/" />
    </url>
</urlset>

With dynamic routes

For dynamic routes, you have to declare them with the include property.

Example src folder:

└── src
    └── pages
        ├── project
        │   └── [id].js
        └── index.js
// import { configureSitemap } from '@sergeymyssak/nextjs-sitemap';
const { configureSitemap } = require('@sergeymyssak/nextjs-sitemap');

async function fetchDynamicPaths() {
  return ['house', 'flower', 'table'];
}

async function getDynamicPaths() {
  const paths = await fetchDynamicPaths();

  return paths.map((item) => `/project/${item}`);
}

getDynamicPaths().then((paths) => {
  const Sitemap = configureSitemap({
    domains: [{ domain: 'example.com', defaultLocale: 'en' }],
    include: paths,
    exclude: ['/project/*'],
    excludeIndex: true,
    pagesConfig: {
      '/project/*': {
        priority: '0.5',
        changefreq: 'daily',
      },
    },
    trailingSlash: true,
    targetDirectory: __dirname + '/public',
    pagesDirectory: __dirname + '/src/pages',
  });

  Sitemap.generateSitemap();
});
Look at the generated sitemap.xml

<?xml version="1.0" encoding="UTF-8" ?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" 
    xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:xhtml="http://www.w3.org/1999/xhtml">
    <url>
        <loc>https://example.com/</loc>
        <lastmod>2021-09-12</lastmod>
        <xhtml:link rel="alternate" hreflang="en" href="https://example.com/" />
    </url>
    <url>
        <loc>https://example.com/project/house/</loc>
        <lastmod>2021-09-12</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.5</priority>
        <xhtml:link rel="alternate" hreflang="en" href="https://example.com/project/house/" />
    </url>
    <url>
        <loc>https://example.com/project/flower/</loc>
        <lastmod>2021-09-12</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.5</priority>
        <xhtml:link rel="alternate" hreflang="en" href="https://example.com/project/flower/" />
    </url>
    <url>
        <loc>https://example.com/project/table/</loc>
        <lastmod>2021-09-12</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.5</priority>
        <xhtml:link rel="alternate" hreflang="en" href="https://example.com/project/table/" />
    </url>
</urlset>

With localization

If you have localization, you can use locales in domains prop.

// import { configureSitemap } from '@sergeymyssak/nextjs-sitemap';
const { configureSitemap } = require('@sergeymyssak/nextjs-sitemap');

const Sitemap = configureSitemap({
  domains: [{ domain: 'example.com', locales: ['en', 'es'] }],
  excludeIndex: true,
  trailingSlash: true,
  targetDirectory: __dirname + '/public',
  pagesDirectory: __dirname + '/src/pages',
});

Sitemap.generateSitemap();
Look at the generated sitemap.xml

<?xml version="1.0" encoding="UTF-8" ?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" 
    xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:xhtml="http://www.w3.org/1999/xhtml">
    <url>
        <loc>https://example.com/en/about/</loc>
        <lastmod>2021-09-10</lastmod>
        <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/about/" />
        <xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/about/" />
    </url>
    <url>
        <loc>https://example.com/es/about/</loc>
        <lastmod>2021-09-10</lastmod>
        <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/about/" />
        <xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/about/" />
    </url>
    <url>
        <loc>https://example.com/en/</loc>
        <lastmod>2021-09-10</lastmod>
        <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/" />
        <xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/" />
    </url>
    <url>
        <loc>https://example.com/es/</loc>
        <lastmod>2021-09-10</lastmod>
        <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/" />
        <xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/" />
    </url>
    <url>
        <loc>https://example.com/en/works/</loc>
        <lastmod>2021-09-10</lastmod>
        <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/works/" />
        <xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/works/" />
    </url>
    <url>
        <loc>https://example.com/es/works/</loc>
        <lastmod>2021-09-10</lastmod>
        <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/works/" />
        <xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/works/" />
    </url>
</urlset>

Multiple sitemaps

If the number of urls is more than 50000, then several sitemaps will be automatically created. You can customize the number of urls using sitemapSize

// import { configureSitemap } from '@sergeymyssak/nextjs-sitemap';
const { configureSitemap } = require('@sergeymyssak/nextjs-sitemap');

const Sitemap = configureSitemap({
  sitemapUrl: 'https://www.example.com',
  sitemapSize: 5000,
  pagesConfig: {
    '/p/*': {
      priority: '0.5',
      changefreq: 'daily',
    },
  },
  nextConfigPath: __dirname + '/next.config.js',
  targetDirectory: __dirname + '/public',
  pagesDirectory: __dirname + '/src/pages',
});

Sitemap.generateSitemap();
Look at public directory

└── src
    └── public
        ├── sitemap.xml
        ├── sitemap1.xml
        ├── sitemap2.xml
        └── sitemap3.xml

Sitemap methods

generateSitemap: () => Promise<ISitemapWriterResultItem[]>;

Generate sitemap

ISitemapWriterResultItem {
  name: string; // sitemap file name
  count: number; // number of urls
}
regenerateSitemapIndex: (sitemapsNames: string[]) => void;

When there are multiple sitemaps, a sitemap index is generated. If we somehow changed our sitemaps externally, then you can use this function to update sitemap index

Sitemap options

domains (optional): IDomain[]

Domain list - same as in next.config.js.

IDomain {
  domain: string; // domain name
  defaultLocale?: string; // non-routing language
  locales?: string[]; // routing languages
  http?: boolean; // http or https
}
exclude (optional): string[]

The exclude parameter is an array of glob patterns to exclude static routes / folders from the generated sitemap.

excludeExtensions (optional): string[]

Ignore files by extension.

Example:

// import { configureSitemap } from '@sergeymyssak/nextjs-sitemap';
const { configureSitemap } = require('@sergeymyssak/nextjs-sitemap');

const Sitemap = configureSitemap({
  // ...
  excludeExtensions: ['.ts'],
  // ...
});

Sitemap.generateSitemap();
excludeIndex (optional): boolean

Remove index from URL, directory will be ending with the slash. Defaults to true.

include (optional): string[]

Array of extra paths to include in the sitemap. If you want to add any route with dynamic parameters, you have to set an array of dynamic routes.

Example:

// import { configureSitemap } from '@sergeymyssak/nextjs-sitemap';
const { configureSitemap } = require('@sergeymyssak/nextjs-sitemap');

const Sitemap = configureSitemap({
  // ...
  include: ['/project/1', '/project/2'],
  exclude: ['/project/[id]'], // or exclude: ['/project/*']
  // ...
});
Sitemap.generateSitemap();
trailingSlash (optional): boolean

Add trailing slashes. Defaults to false.

nextConfigPath (optional): string

Use exportPathMap from next.config.js file.

pagesConfig (optional): IPagesConfig[]

Object configuration of priority and changefreq per route / folder.

IPagesConfig {
  [key: string]: { 
    priority: string,
    changefreq: string 
  }
}

Example:

// import { configureSitemap } from '@sergeymyssak/nextjs-sitemap';
const { configureSitemap } = require('@sergeymyssak/nextjs-sitemap');

const Sitemap = configureSitemap({
  // ...
  pagesConfig: {
    '/about': {
      priority: '0.5',
      changefreq: 'daily',
    },
    '/project/*': {
      priority: '0.9',
      changefreq: 'daily',
    },
  },
  // ...
});

Sitemap.generateSitemap();
pagesDirectory (required): string

The directory where there are Next.js pages.

targetDirectory (required): string

The path to the public folder.

sitemapUrl (optional): string

The url which will be specified in the sitemap index file.

sitemapSize (optional): number

Maximum number of url in one sitemap file. Defaults to 50000.

sitemapStylesheet (optional): ISitemapStylesheet[]

Array of style objects that will be applied to sitemap.

ISitemapStylesheet {
  type: string;
  styleFile: string;
}

Example:

// import { configureSitemap } from '@sergeymyssak/nextjs-sitemap';
const { configureSitemap } = require('@sergeymyssak/nextjs-sitemap');

const Sitemap = configureSitemap({
  // ...
  sitemapStylesheet: [
    {
      type: "text/css",
      styleFile: "styles/styles.css"
    },
    {
      type: "text/xsl",
      styleFile: "styles/styles.xls"
    }
  ],
  // ...
});
Sitemap.generateSitemap();

Useful information

Language localisation

The value of the hreflang attribute identifies the language (in ISO 639-1 format) and optionally a region (in ISO 3166-1 Alpha 2 format) of an alternate URL.

Gzip

You can gzip your sitemap.xml. The .gz extension just means that it's been compressed (using gzip compression), so that it's smaller and served faster. Most search engine bots can read gzip'd compressed content.

Look at code how you can generate sitemap.xml.gz

// import zlib from 'zlib';
// import fs from 'fs';
// import { configureSitemap } from '@sergeymyssak/nextjs-sitemap';

const zlib = require('zlib');
const fs = require('fs');
const { configureSitemap } = require('@sergeymyssak/nextjs-sitemap');

async function getDynamicPaths() {
  const data = ['house', 'flower', 'table'];
  return data.map((item) => `/project/${item}`);
}

getDynamicPaths().then((paths) => {
  const Sitemap = configureSitemap({
    domains: [{ domain: 'example.com', defaultLocale: 'en' }],
    include: paths,
    exclude: ['/project/*'],
    excludeIndex: true,
    pagesConfig: {
      '/project/*': {
        priority: '0.5',
        changefreq: 'daily',
      },
    },
    trailingSlash: true,
    targetDirectory: __dirname + '/public',
    pagesDirectory: __dirname + '/src/pages',
  });

  Sitemap.generateSitemap().then(() => {
    const inp = fs.createReadStream('public/sitemap.xml');
    const out = fs.createWriteStream('public/sitemap.xml.gz');
    const gzip = zlib.createGzip();
    inp.pipe(gzip).pipe(out);
    fs.unlink('public/sitemap.xml', () =>
      console.log('Sitemap.xml has been deleted!'),
    );
    console.log('Sitemap.xml.gz has been created!');
  });
});

nextjs-sitemap's People

Contributors

andreymyssak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nextjs-sitemap's Issues

Add custom hreflang to IDomain locales

Since the targeted hreflang might be different from the nextjs locale, I suggest changing the IDomain type to

export interface IDomain {
domain: string;
defaultLocale?: string;
locales?: { nextLocale: string; hreflang: string }[];
http?: boolean;
}

Sitemap Generation with Dynamic Routes

Hey there,

I am currently running the script prebuild on vercel.

What is the best practice to have the sitemap update for dynamic routes which are generated via getStaticPaths and fallback: 'blocking'? Is there a way to have the script run periodically?

Cheers!

Allow es modules to be imported in sitemap-generator to use fetch or axios inside sitemap-generator.js ?

Hello ,

Your documentation say we can implement dynamic paths in our sitemap https://github.com/SergeyMyssak/nextjs-sitemap#with-dynamic-routes
but i can't manage to do so ,
I need to fetch all my url blog from sanity.io

See your example

const { configureSitemap } = require('@sergeymyssak/nextjs-sitemap');

async function fetchDynamicPaths() {
  return ['house', 'flower', 'table'];
}

async function getDynamicPaths() {
  const paths = await fetchDynamicPaths();

  return paths.map((item) => `/project/${item}`);
}

getDynamicPaths().then((paths) => {
  const Sitemap = configureSitemap({
    domains: [{ domain: 'example.com', defaultLocale: 'en' }],
    include: paths,
    exclude: ['/project/*'],
    excludeIndex: true,
    pagesConfig: {
      '/project/*': {
        priority: '0.5',
        changefreq: 'daily',
      },
    },
    trailingSlash: true,
    targetDirectory: __dirname + '/public',
    pagesDirectory: __dirname + '/src/pages',
  });

  Sitemap.generateSitemap();
});

But if i want to import fetch module i get an error

const fetch = require("node-fetch")

const { configureSitemap } = require("@sergeymyssak/nextjs-sitemap")
const fs = require("fs")

async function fetchDynamicPaths() {
  const query = encodeURIComponent(`{
    "posts": *[_type == "post"]  {
      ...,
      categories[]->
    }}
  `)
  const url = `https://eb29jfco.api.sanity.io/v1/data/query/production?query=${query}`
  const result = await fetch(url).then((res) => res.json())
  const paths = []
  result.result.posts.map((element) => {
    return paths.push({
      slug: `${element.slug.current}`,
    })
  })

  return {
    paths,
  }
}

async function getDynamicPaths() {
  const paths = await fetchDynamicPaths()
  return paths.paths.map((item) => `/blog/${item.slug}`)
}
const paths = getDynamicPaths()
console.log(paths)

async function writeSitemap() {
  // const dynamicPaths = uniquePaths
  const publicDirectory = `${__dirname}/public`
  const domain = "www.myblog.app"
  const Sitemap = configureSitemap({
    domains: [
      {
        domain,
        locales: ["fr"],
        defaultLocale: "en",
      },
    ],
    // include: dynamicPaths,
    exclude: ["/advisor", "/404", "/api/*", "blog/*"],
    targetDirectory: publicDirectory,
    pagesDirectory: `${__dirname}/pages`,
  })
  const result = await Sitemap.generateSitemap()
  let sitemaps = ""
  result.forEach((r) => {
    sitemaps += `Sitemap: https://${domain}/${r.name}\n`
  })
  const robotTxt = `# *
User-agent: *
Allow: /
# Host
Host: https://${domain}
# Sitemaps
${sitemaps}`
  fs.writeFileSync(`${publicDirectory}/robots.txt`, robotTxt)
}
writeSitemap()

error
image

Sitemap doesn't exclude module.scss

When generating sitemap on a default nextjs setup, module.scss files will be included in the sitemap.xml as follow:

<?xml version="1.0" encoding="UTF-8" ?>
<urlset xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 
    http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:xhtml="http://www.w3.org/1999/xhtml">
    <url>
        <loc>https://example.com/404/</loc>
        <lastmod>2021-01-16</lastmod>
    </url>
    <url>
        <loc>https://example.com/404.module/</loc>
        <lastmod>2021-01-16</lastmod>
    </url>
    <url>
        <loc>https://example.com/</loc>
        <lastmod>2021-01-16</lastmod>
    </url>
    <url>
        <loc>https://example.com/index.module/</loc>
        <lastmod>2021-01-16</lastmod>
    </url>
</urlset>

By default, scss modules should be excluded.

A possible workaround would be to add them with a wildcard in exclude prop, but the following doesn't work:

const Sitemap = configureSitemap({
		baseUrl: 'https://example.com',
		exclude: [
			'/*.module',
			'/**/*.module'
		],
		excludeIndex: true,
		isTrailingSlashRequired: true,
		targetDirectory: __dirname + '/public',
		pagesDirectory: __dirname + '/src/pages'
	})
Sitemap.generateSitemap()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.