-
Notifications
You must be signed in to change notification settings - Fork 2
/
next-sitemap.config.js
69 lines (65 loc) · 2.28 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
64
65
66
67
68
69
const path = require("node:path/posix");
// SITEMAP_BASE_URL is written to the .env file during next.config.js execution.
const sitemapBaseUrl = process.env.SITEMAP_BASE_URL;
if (!sitemapBaseUrl || sitemapBaseUrl === "undefined") {
throw new TypeError(
"process.env.SITEMAP_BASE_URL not defined. See code in next.config.js",
);
}
// Can't read the Oak config here, so process switch manually.
// As long as ISR isn't disabled we should add the dynamic
// sitemaps to the sitemap list.
const shouldSkipInitialBuild = process.env.DISABLE_ISR !== "on";
// List of dynamically generated sitemaps for pages using `fallback: "blocking"`
const serversideSitemapPaths = [
"/blog/sitemap.xml",
"/blog/categories/sitemap.xml",
"/webinars/sitemap.xml",
"/webinars/categories/sitemap.xml",
"/teachers/curriculum/sitemap.xml",
"/teachers/key-stages/sitemap.xml",
"/teachers/sitemap.xml",
"/teachers/sitemap-1.xml",
"/pupils/sitemap.xml",
"/pupils/sitemap-1.xml",
];
const serversideSitemapUrls = serversideSitemapPaths.map(
(sitemapPath) => new URL(path.join(sitemapBaseUrl, sitemapPath)).href,
);
// https://github.com/iamvishnusankar/next-sitemap#readme
/** @type {import('next-sitemap').IConfig} */
module.exports = {
siteUrl: sitemapBaseUrl,
// Generate a robots.txt that instructs no crawling (individual pages also have no index set).
generateRobotsTxt: true,
robotsTxtOptions: {
// List the dynamically generated sitemaps here, exclude below.
additionalSitemaps: shouldSkipInitialBuild
? serversideSitemapUrls
: undefined,
policies: [
{
userAgent: "*",
// Note, there is a Cloudflare rule redirecting all /beta paths to a 404 page.
},
],
},
exclude: [
// Exclude WIP webinar pages
"/webinars",
"/webinars/*",
// Pointer exclusions
"/webinars/using-oak-to-support-during-covid-disruption-and-setting-cover-2",
"/webinars/boosting-motivation-in-the-classroom",
"/blog/what-impact-did-oak-have-in-2020-21",
"/blog/using-our-new-curriculum-maps-to-support-your-classroom-planning",
"/webinars",
"/news-and-views",
"/about-oak",
"/people-and-partners",
"/contact",
].concat(
// Exclude dynamically created sitemaps
shouldSkipInitialBuild ? serversideSitemapPaths : [],
),
};