-
Notifications
You must be signed in to change notification settings - Fork 2
/
next-sitemap.config.js
43 lines (39 loc) · 1.31 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
/** @type {import('next-sitemap').IConfig} */
const path = require('path');
const { translateUrl } = require('next-translate-routes');
const { createNtrData } = require('next-translate-routes/plugin');
const nextConfig = require('./next.config');
const data = createNtrData(
nextConfig,
path.resolve(process.cwd(), './pages')
);
global.__NEXT_TRANSLATE_ROUTES_DATA = data;
module.exports = {
siteUrl: process.env.NEXT_PUBLIC_BASE_URL || 'https://example.com',
exclude: ['/api', '/404', '/fr/404'],
generateIndexSitemap: false,
generateRobotsTxt: true,
changefreq: 'monthly',
robotsTxtOptions: {
policies: [
{
userAgent: '*',
allow: '/'
},
{
userAgent: '*',
disallow: ['/api', '/404', '/fr/404']
}
]
},
transform: async (config, path) => {
const locale = nextConfig.i18n.locales.find((locale) => path.indexOf(`/${locale}`) > -1) || nextConfig.i18n.defaultLocale;
return {
loc: translateUrl(path, locale),
changefreq: config.changefreq,
priority: config.priority,
lastmod: config.autoLastmod ? new Date().toISOString() : undefined,
alternateRefs: config.alternateRefs ?? []
};
},
}