import {readdir,mkdir,writeFile} from 'node:fs/promises'; import path from 'node:path'; const staticPages=[]; const seoByPath={ '/':{changefreq:'daily',priority:1}, '/about-us':{changefreq:'monthly',priority:0.6}, '/contact-us':{changefreq:'monthly',priority:0.5}, '/blog':{changefreq:'weekly',priority:0.7}, }; async function scan(dir,parts=[]){for(const entry of await readdir(dir,{withFileTypes:true})){if(entry.isDirectory()&&!entry.name.startsWith('[')&&!entry.name.startsWith('_')&&!['api','account','admin','login','cart','checkout'].includes(entry.name))await scan(path.join(dir,entry.name),entry.name.startsWith('(')?parts:[...parts,entry.name]);else if(entry.isFile()&&/^page\.(tsx|jsx|js|ts)$/.test(entry.name)){const route='/'+parts.join('/');staticPages.push({path:route,...(seoByPath[route]||{changefreq:'monthly',priority:0.6})})}}} await scan('app');await mkdir('public/meshkee',{recursive:true});await writeFile('public/meshkee/sitemap-config.json',JSON.stringify({baseUrl:'https://sgemed.com',staticPages},null,2)+'\n');