-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnuxt.config.ts
More file actions
105 lines (100 loc) · 3.05 KB
/
Copy pathnuxt.config.ts
File metadata and controls
105 lines (100 loc) · 3.05 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
/// <reference types="./shared/types/type.d.ts" />
/// <reference types="./shared/types/Article.d.ts" />
import { defineNuxtConfig } from 'nuxt/config'
import { ofetch } from 'ofetch'
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
compatibilityDate: '2025-11-07',
devtools: { enabled: true },
modules: [
'@nuxt/eslint',
'@nuxt/ui',
'@pinia/nuxt',
'@vueuse/nuxt',
'@nuxthub/core',
'@nuxtjs/sitemap'
],
css: ['~/assets/css/main.css', 'md-editor-v3/lib/style.css'],
ui: { fonts: false },
icon: {
customCollections: [
{
prefix: 'app-icons',
dir: './app/assets/icons'
}
]
},
// 开发服务器配置
devServer: {
host: '0.0.0.0'
},
// 运行时配置
runtimeConfig: {
public: {
/** API 基础路径 */
apiBase: '',
/** 浏览器客户端 API 基础路径(优先级高于 apiBase) */
apiBaseClient: '',
/** SSR 服务端 API 基础路径(优先级高于 apiBase) */
apiBaseServer: '',
/** 网站 URL */
siteUrl: process.env.NUXT_PUBLIC_SITE_URL || 'https://wolfblog.cn',
/** 阿里云验证码前缀 */
aliyunCaptchaPrefix: process.env.NUXT_PUBLIC_ALIYUN_CAPTCHA_PREFIX,
/** 阿里云验证码场景 ID - 用户注册邮箱验证码 */
aliyunCaptchaSceneIdEmailCode: process.env.NUXT_PUBLIC_ALIYUN_CAPTCHA_SCENE_ID_EMAIL_CODE
}
},
// 应用配置
app: {
head: {
meta: [
{
name: 'google-site-verification',
content: 'NXfgjEswn0tQ1ObEiwXr5TvJkSLoLoORnRqs0d1yzzo'
},
{ name: 'msvalidate.01', content: 'C946A40DA6A8822BEDC0C5463EEDB211' }
],
script: [
// 阿里云验证码配置
{
type: 'text/javascript',
textContent: `window.AliyunCaptchaConfig = { region: 'cn', prefix: '${process.env.NUXT_PUBLIC_ALIYUN_CAPTCHA_PREFIX || ''}' };`
},
// 阿里云验证码脚本
{
type: 'text/javascript',
src: 'https://o.alicdn.com/captcha-frontend/aliyunCaptcha/AliyunCaptcha.js'
}
]
}
},
// Sitemap 配置
sitemap: {
exclude: ['/user/settings', '/user/login', '/user/register', '/articles/edit/**'],
defaults: {
changefreq: 'daily',
priority: 1,
lastmod: new Date().toISOString()
},
urls: async () => {
const articleList = await ofetch<ApiResponse<ApiPageData<Article.ArticleInfo>>>(
`${process.env.NUXT_PUBLIC_API_BASE_SERVER || process.env.NUXT_PUBLIC_API_BASE}/article/query`,
{
method: 'POST',
headers: { 'Content-Type': 'application/nullable+json' },
body: {
pageSize: 1000, // 获取全量数据
visibility: 0 // 仅公开文章
}
}
)
const urls =
articleList?.data?.records?.map((article: Article.ArticleInfo) => ({
loc: `/articles/${article.id}`,
lastmod: new Date(article.editTime || article.postTime).toISOString()
})) || []
return urls
}
}
})