slim-select
Version:
Slim advanced select dropdown
90 lines (83 loc) • 2.28 kB
JavaScript
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
// Define all routes and their metadata
const routes = [
{
loc: 'https://slimselectjs.com/',
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'weekly',
priority: '1.0'
},
{
loc: 'https://slimselectjs.com/install',
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'monthly',
priority: '0.9'
},
{
loc: 'https://slimselectjs.com/selects',
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'monthly',
priority: '0.9'
},
{
loc: 'https://slimselectjs.com/data',
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'monthly',
priority: '0.8'
},
{
loc: 'https://slimselectjs.com/settings',
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'monthly',
priority: '0.8'
},
{
loc: 'https://slimselectjs.com/events',
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'monthly',
priority: '0.7'
},
{
loc: 'https://slimselectjs.com/methods',
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'monthly',
priority: '0.7'
},
{
loc: 'https://slimselectjs.com/frameworks/react',
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'monthly',
priority: '0.8'
},
{
loc: 'https://slimselectjs.com/frameworks/vue',
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'monthly',
priority: '0.8'
}
]
function generateSitemap() {
const sitemapContent = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${routes
.map(
(route) => ` <url>
<loc>${route.loc}</loc>
<lastmod>${route.lastmod}</lastmod>
<changefreq>${route.changefreq}</changefreq>
<priority>${route.priority}</priority>
</url>`
)
.join('\n')}
</urlset>`
const sitemapPath = path.join(__dirname, 'public', 'sitemap.xml')
fs.writeFileSync(sitemapPath, sitemapContent, 'utf8')
console.log('✅ Sitemap generated successfully at:', sitemapPath)
}
// Run the generator
generateSitemap()