11import { source } from "@/lib/source" ;
2+ import { i18n } from "@/lib/i18n" ;
23import { readdir } from "fs/promises" ;
34import { join } from "path" ;
45import type { MetadataRoute } from "next" ;
@@ -8,12 +9,15 @@ const baseUrl = "https://hytalemodding.dev";
89export 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 ( / \. m d x $ / , "" ) ;
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 ( / \. m d x $ / , "" ) ;
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