Skip to content

Commit 1b71381

Browse files
author
Sergey Myssak
authored
Update README.md
1 parent e1edfde commit 1b71381

File tree

1 file changed

+55
-49
lines changed

1 file changed

+55
-49
lines changed

README.md

+55-49
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Checkout the [examples](https://github.com/SergeyMyssak/nextjs-sitemap/tree/mast
2323
- [Sitemap methods](#sitemap-methods)
2424
- [Sitemap options](#sitemap-options)
2525
- [Useful information](#useful-information)
26+
- [Language localisation](#language-localisation)
27+
- [Gzip](#gzip)
28+
2629

2730
## Installation
2831

@@ -591,58 +594,61 @@ Sitemap.generateSitemap();
591594

592595
## Useful information
593596

594-
- The value of the hreflang attribute identifies the language (in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format) and optionally a region (in [ISO 3166-1 Alpha 2](https://en.wikipedia.org/wiki/ISO_3166-1) format) of an alternate URL.
595-
- 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.
597+
#### Language localisation
598+
The value of the hreflang attribute identifies the language (in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format) and optionally a region (in [ISO 3166-1 Alpha 2](https://en.wikipedia.org/wiki/ISO_3166-1) format) of an alternate URL.
599+
600+
#### Gzip
601+
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.
596602

597-
<details><summary>Look at code how you can generate sitemap.xml.gz</summary>
598-
<p>
603+
<details><summary>Look at code how you can generate <code>sitemap.xml.gz</code></summary>
604+
<p>
599605

600-
```js
601-
// import zlib from 'zlib';
602-
// import fs from 'fs';
603-
// import { configureSitemap } from '@sergeymyssak/nextjs-sitemap';
604-
605-
const zlib = require('zlib');
606-
const fs = require('fs');
607-
const { configureSitemap } = require('@sergeymyssak/nextjs-sitemap');
608-
609-
async function getDynamicPaths() {
610-
const data = ['house', 'flower', 'table'];
611-
return data.map((item) => `/project/${item}`);
612-
}
606+
```js
607+
// import zlib from 'zlib';
608+
// import fs from 'fs';
609+
// import { configureSitemap } from '@sergeymyssak/nextjs-sitemap';
610+
611+
const zlib = require('zlib');
612+
const fs = require('fs');
613+
const { configureSitemap } = require('@sergeymyssak/nextjs-sitemap');
614+
615+
async function getDynamicPaths() {
616+
const data = ['house', 'flower', 'table'];
617+
return data.map((item) => `/project/${item}`);
618+
}
619+
620+
getDynamicPaths().then((paths) => {
621+
const Sitemap = configureSitemap({
622+
domains: [{ domain: 'example.com', defaultLocale: 'en' }],
623+
include: paths,
624+
exclude: ['/project/*'],
625+
excludeIndex: true,
626+
pagesConfig: {
627+
'/project/*': {
628+
priority: '0.5',
629+
changefreq: 'daily',
630+
},
631+
},
632+
trailingSlash: true,
633+
targetDirectory: __dirname + '/public',
634+
pagesDirectory: __dirname + '/src/pages',
635+
});
636+
637+
Sitemap.generateSitemap().then(() => {
638+
const inp = fs.createReadStream('public/sitemap.xml');
639+
const out = fs.createWriteStream('public/sitemap.xml.gz');
640+
const gzip = zlib.createGzip();
641+
inp.pipe(gzip).pipe(out);
642+
fs.unlink('public/sitemap.xml', () =>
643+
console.log('Sitemap.xml has been deleted!'),
644+
);
645+
console.log('Sitemap.xml.gz has been created!');
646+
});
647+
});
648+
```
613649

614-
getDynamicPaths().then((paths) => {
615-
const Sitemap = configureSitemap({
616-
domains: [{ domain: 'example.com', defaultLocale: 'en' }],
617-
include: paths,
618-
exclude: ['/project/*'],
619-
excludeIndex: true,
620-
pagesConfig: {
621-
'/project/*': {
622-
priority: '0.5',
623-
changefreq: 'daily',
624-
},
625-
},
626-
trailingSlash: true,
627-
targetDirectory: __dirname + '/public',
628-
pagesDirectory: __dirname + '/src/pages',
629-
});
630-
631-
Sitemap.generateSitemap().then(() => {
632-
const inp = fs.createReadStream('public/sitemap.xml');
633-
const out = fs.createWriteStream('public/sitemap.xml.gz');
634-
const gzip = zlib.createGzip();
635-
inp.pipe(gzip).pipe(out);
636-
fs.unlink('public/sitemap.xml', () =>
637-
console.log('Sitemap.xml has been deleted!'),
638-
);
639-
console.log('Sitemap.xml.gz has been created!');
640-
});
641-
});
642-
```
643-
644-
</p>
645-
</details>
650+
</p>
651+
</details>
646652

647653
<!-- badges -->
648654
[version-badge]: https://img.shields.io/npm/v/@sergeymyssak/nextjs-sitemap.svg?style=flat-square

0 commit comments

Comments
 (0)