51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
const fs = require("fs");
|
|
const fm = require("front-matter");
|
|
|
|
const siteUrl = process.env.SITE_URL || "https://www.aaronjy.me";
|
|
/** @type {import('next-sitemap').IConfig} */
|
|
module.exports = {
|
|
siteUrl,
|
|
changefreq: "weekly",
|
|
generateRobotsTxt: true,
|
|
autoLastmod: false,
|
|
generateIndexSitemap: false,
|
|
exclude: ["/server-sitemap-index.xml"], // <= exclude here
|
|
robotsTxtOptions: {
|
|
policies: [
|
|
{
|
|
userAgent: "*",
|
|
allow: "/",
|
|
},
|
|
],
|
|
additionalSitemaps: [
|
|
`${siteUrl}/server-sitemap-index.xml`, // <==== Add here
|
|
],
|
|
},
|
|
transform: async (config, path) => {
|
|
const metadata = {
|
|
loc: path,
|
|
};
|
|
|
|
if (isHomepage(path)) {
|
|
metadata.priority = 1;
|
|
} else if (isBasePage(path)) {
|
|
metadata.priority = 0.8;
|
|
} else if (isArticle(path)) {
|
|
metadata.priority = 0.6;
|
|
}
|
|
|
|
return metadata;
|
|
},
|
|
};
|
|
|
|
function isHomepage(path) {
|
|
return path === "/";
|
|
}
|
|
|
|
function isBasePage(path) {
|
|
return path.split("/").length === 2;
|
|
}
|
|
|
|
function isArticle(path) {
|
|
return path.startsWith("/writing/") || path.startsWith("/library/");
|
|
}
|