-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext-sitemap.config.js
46 lines (39 loc) · 1.19 KB
/
next-sitemap.config.js
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
const { createClient } = require('@supabase/supabase-js');
// 初始化 Supabase 客户端
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY
);
module.exports = {
siteUrl: 'https://thebowvee.com/',
generateRobotsTxt: true,
// Optional configurations
changefreq: 'weekly',
outDir: 'public',
priority: 0.7,
sitemapSize: 5000,
exclude: ['/admin/*', '/private/*'],
// 添加自定义路径生成函数
additionalPaths: async (config) => {
const result = [];
try {
// 从 Supabase 获取所有文章 ID
const { data: articles, error } = await supabase
.from('articles')
.select('id');
if (error) throw error;
// 为每篇文章创建 URL
for (const article of articles) {
result.push({
loc: `/article/${article.id}`,
changefreq: 'weekly',
priority: 0.8,
lastmod: new Date().toISOString(),
});
}
} catch (error) {
console.error('Error fetching article IDs for sitemap:', error);
}
return result;
},
}