-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext-sitemap.config.js
37 lines (35 loc) · 1014 Bytes
/
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
const axios = require("axios");
/** @type {import('next-sitemap').IConfig} */
module.exports = {
siteUrl: "https://theme-ai.vercel.app",
generateRobotsTxt: true,
exclude: ["/themes/generated", "/settings"],
additionalPaths: async () => {
const urls = await axios
.get(`${process.env.NEXTAUTH_URL}/api/sitemap-details`)
.then((res) => res.data);
const fields = urls
? urls.map((sitemap) => ({
loc: `/${sitemap.type}/${sitemap.id}`,
lastmod: new Date().toISOString(),
changefreq: "daily",
priority: 0.7,
}))
: [];
return fields;
},
transform: async (config, path) => {
return {
loc: path,
priority:
path === "/" || path === "/themes"
? 1
: path === "/themes/create"
? 0.9
: 0.5,
changefreq: config.changefreq,
lastmod: config.autoLastmod ? new Date().toISOString() : undefined,
alternateRefs: config.alternateRefs ?? [],
};
},
};