-
Notifications
You must be signed in to change notification settings - Fork 20
/
next-sitemap.config.js
63 lines (53 loc) · 1.8 KB
/
next-sitemap.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-require-imports */
const fs = require('fs');
const path = require('path');
// @ts-check
/** @type {import('next-sitemap').IConfig} */
/** @type {string} */
const countryVariant = process.env.NEXT_PUBLIC_COUNTRY_VARIANT ?? 'cs';
/** @type {Object<string,string>} */
const SITE_URLS = {
cs: 'https://www.movapp.cz',
sk: 'https://sk.movapp.eu',
pl: 'https://pl.movapp.eu',
};
/** @type {Array<string>} */
const PDF_LINKS = [
'/dictionary/pdf/*',
'/uk/dictionary/pdf/*',
'/kids/pdf/*',
'/uk/kids/pdf/*',
'/kids/stories/pdf/*',
'/uk/kids/stories/pdf/*',
'/alphabet/pdf/*',
'/uk/alphabet/pdf/*',
];
/** @type {Object<string,Array<string>>}} */
const EXCLUSIONS = {
cs: ['/exercise/re*', '/uk/exercise/re*', '/kiosk*', '/uk/kiosk*', ...PDF_LINKS],
sk: ['/wiki*', '/uk/wiki*', '/exercise/re*', '/uk/exercise/re*', '/kiosk*', '/uk/kiosk*', ...PDF_LINKS],
pl: ['/wiki*', '/uk/wiki*', '/exercise/re*', '/uk/exercise/re*', '/kiosk*', '/uk/kiosk*', ...PDF_LINKS],
};
/** @type {import('next-sitemap').IConfig} */
module.exports = {
siteUrl: SITE_URLS[countryVariant],
generateRobotsTxt: true,
exclude: ['/404', '/uk/404', '', ...EXCLUSIONS[countryVariant]],
priority: null,
changefreq: null,
generateIndexSitemap: false,
additionalPaths: async (config) => {
const result = [];
// get list of files from folder public/pdf
const pdfPath = path.join(process.cwd(), 'public', 'pdf');
const pdfFiles = await fs.promises.readdir(pdfPath);
// add pdf files to sitemap
pdfFiles.forEach(async (file) => {
if (file !== '.gitkeep') {
result.push(await config.transform(config, `${SITE_URLS[countryVariant]}/pdf/${encodeURIComponent(file)}`));
}
});
return result;
},
};