-
-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathsitemap.js
More file actions
108 lines (102 loc) · 2.7 KB
/
sitemap.js
File metadata and controls
108 lines (102 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env node
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
// Based on routes defined in src/docs/router.ts
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/examples',
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'monthly',
priority: '0.8'
},
{
loc: 'https://slimselectjs.com/privacy',
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'yearly',
priority: '0.3'
},
{
loc: 'https://slimselectjs.com/settings',
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'monthly',
priority: '0.8'
},
{
loc: 'https://slimselectjs.com/style',
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/react',
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'monthly',
priority: '0.8'
},
{
loc: 'https://slimselectjs.com/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()