forked from ethereum/ethereum-org-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext-sitemap.config.js
More file actions
32 lines (28 loc) · 1.02 KB
/
next-sitemap.config.js
File metadata and controls
32 lines (28 loc) · 1.02 KB
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
const i18nConfig = require("./i18n.config.json")
const locales = i18nConfig.map(({ code }) => code)
const defaultLocale = "en"
/** @type {import('next-sitemap').IConfig} */
module.exports = {
siteUrl: process.env.SITE_URL || "https://ethereum.org",
generateRobotsTxt: true,
transform: async (_, path) => {
const rootPath = path.split("/")[1]
if (path.endsWith("/404")) return null
const isDefaultLocale =
!locales.includes(rootPath) || rootPath === defaultLocale
// Strip default-locale (en) prefix from paths; drop the `/en` root entry
let loc = path
if (rootPath === defaultLocale) {
// Drop the `/en` root entry to avoid duplicating `/`
if (path === `/${defaultLocale}` || path === `/${defaultLocale}/`)
return null
const defaultLocalePrefix = new RegExp(`^/${defaultLocale}(/|$)`)
loc = path.replace(defaultLocalePrefix, "/")
}
return {
loc,
changefreq: isDefaultLocale ? "weekly" : "monthly",
priority: isDefaultLocale ? 0.7 : 0.5,
}
},
}