-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnext-sitemap.config.js
61 lines (57 loc) · 1.57 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
/** @type {import('next-sitemap').IConfig} */
// next-sitemap.js
module.exports = {
siteUrl: 'https://yesjob.be',
generateRobotsTxt: true,
exclude: ['/server-sitemap.xml'], // Exclude any paths not intended for public indexing
changefreq: 'daily',
priority: 0.7,
sitemapSize: 5000,
alternateRefs: [
{
href: 'https://yesjob.be/en',
hreflang: 'en-US',
},
{
href: 'https://yesjob.be/fr',
hreflang: 'fr-BE',
},
{
href: 'https://yesjob.be/nl',
hreflang: 'nl-BE',
},
],
// Default transformation function
transform: async (config, url) => {
return {
loc: url,
changefreq: config.changefreq,
priority: config.priority,
lastmod: new Date().toISOString(),
alternateRefs: config.alternateRefs,
};
},
additionalPaths: async (config) => {
const additionalPaths = ['/annonce', '/annonce/publier', '/contact'];
// Fetch the IDs of all ads from your backend
// This is a placeholder function, replace it with your actual implementation
const fetchAdIds = async () => {
// Placeholder array of ad IDs. Replace this with a fetch request to your backend.
return ['id-1', 'id-2', 'id-3'];
};
const adIds = await fetchAdIds();
// Add the paths for each ad to the array of additional paths
adIds.forEach((id) => {
additionalPaths.push(`/annonce/${id}`);
});
return additionalPaths.map((path) => config.transform(config, path));
},
robotsTxtOptions: {
policies: [
{
userAgent: '*',
allow: '/',
},
],
},
};