Skip to content

Commit 92d3c72

Browse files
authored
Merge pull request #235 from HytaleModding/fix/lanugages-on-sitemap
fix: add language pages to sitemap
2 parents 7ccd312 + 087e8f0 commit 92d3c72

1 file changed

Lines changed: 23 additions & 19 deletions

File tree

src/app/sitemap.ts

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { source } from "@/lib/source";
2+
import { i18n } from "@/lib/i18n";
23
import { readdir } from "fs/promises";
34
import { join } from "path";
45
import type { MetadataRoute } from "next";
@@ -8,12 +9,15 @@ const baseUrl = "https://hytalemodding.dev";
89
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
910
const sitemap: MetadataRoute.Sitemap = [];
1011

11-
sitemap.push({
12-
url: baseUrl,
13-
lastModified: new Date(),
14-
changeFrequency: "daily",
15-
priority: 1.0,
16-
});
12+
// Add all language home pages
13+
for (const lang of i18n.languages) {
14+
sitemap.push({
15+
url: `${baseUrl}/${lang}`,
16+
lastModified: new Date(),
17+
changeFrequency: "daily",
18+
priority: lang === i18n.defaultLanguage ? 1.0 : 0.95,
19+
});
20+
}
1721

1822
// Get all pages from source
1923
const pages = source.getPages();
@@ -43,22 +47,22 @@ async function addProjectPages(sitemap: MetadataRoute.Sitemap) {
4347
const mdxFiles = files.filter(
4448
(file) => file.endsWith(".mdx") && file !== "example.mdx",
4549
);
46-
47-
sitemap.push({
48-
url: `${baseUrl}/en/projects`,
49-
lastModified: new Date(),
50-
changeFrequency: "weekly",
51-
priority: 0.9,
52-
});
53-
54-
for (const file of mdxFiles) {
55-
const slug = file.replace(/\.mdx$/, "");
50+
for (const lang of i18n.languages) {
5651
sitemap.push({
57-
url: `${baseUrl}/en/projects/${slug}`,
52+
url: `${baseUrl}/${lang}/projects`,
5853
lastModified: new Date(),
59-
changeFrequency: "monthly",
60-
priority: 0.7,
54+
changeFrequency: "weekly",
55+
priority: 0.9,
6156
});
57+
for (const file of mdxFiles) {
58+
const slug = file.replace(/\.mdx$/, "");
59+
sitemap.push({
60+
url: `${baseUrl}/${lang}/projects/${slug}`,
61+
lastModified: new Date(),
62+
changeFrequency: "weekly",
63+
priority: 0.7,
64+
});
65+
}
6266
}
6367
} catch (error) {
6468
console.error("Error reading projects for sitemap:", error);

0 commit comments

Comments
 (0)