-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathnuxt.config.ts
153 lines (135 loc) · 4.5 KB
/
nuxt.config.ts
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import process from 'node:process'
import blogConfig, { routeRules } from './blog.config'
// 此处配置无需修改
export default defineNuxtConfig({
app: {
head: {
htmlAttrs: {
lang: blogConfig.language,
},
link: [
{ rel: 'icon', href: blogConfig.favicon },
{ rel: 'alternate', type: 'application/atom+xml', href: '/atom.xml' },
{ rel: 'preconnect', href: blogConfig.twikoo.preload },
{ rel: 'preconnect', href: 'https://cdn-font.hyperos.mi.com' },
// 浏览器渲染中文 VF 字重有问题
{ rel: 'stylesheet', href: 'https://cdn-font.hyperos.mi.com/font/css?family=MiSans_VF:VF:Chinese_Simplify,Latin&display=swap', media: 'none', onload: 'this.media="all"' },
// https://cdn-font.hyperos.mi.com/font/css?family=MiSans:100,200,300,400,450,500,600,650,700,900:Chinese_Simplify,Latin&display=swap
{ rel: 'preconnect', href: 'https://fonts.googleapis.cn' },
{ rel: 'preconnect', href: 'https://fonts.gstatic.cn' },
{ rel: 'stylesheet', href: 'https://fonts.googleapis.cn/css2?family=Fira+Code:[email protected]&family=Noto+Serif+SC:[email protected]&display=swap', media: 'none', onload: 'this.media="all"' },
// { rel: 'stylesheet', href: 'https://gcore.jsdelivr.net/npm/nerdfonts-web/nf.min.css' },
],
meta: [
{ name: 'author', content: `${blogConfig.author.name} <${blogConfig.author.email}>` },
// 此处为元数据的生成器标识,不建议修改
{ 'name': 'generator', 'content': 'blog-v3', 'data-github-repo': 'https://github.com/L33Z22L11/blog-v3' },
],
templateParams: {
separator: '|',
},
titleTemplate: `%s %separator ${blogConfig.title}`,
script: blogConfig.scripts,
},
rootId: 'z-root',
},
compatibilityDate: '2024-08-03',
components: [
{ path: '~/components/partial', prefix: 'Z' },
{ path: '~/components/zhilu', prefix: 'Zhilu', global: true },
'~/components',
],
css: [
'@/assets/css/animation.scss',
'@/assets/css/article.scss',
'@/assets/css/color.scss',
'@/assets/css/main.scss',
'@/assets/css/reusable.scss',
],
// BUG: 3.14+ Windows 平台内存泄漏
devtools: { enabled: false },
features: {
inlineStyles: false,
},
future: {
compatibilityVersion: 4,
},
routeRules,
runtimeConfig: {
public: {
buildTime: new Date().toISOString(),
},
},
vite: {
css: {
preprocessorOptions: {
scss: {
additionalData: '@use "@/assets/css/_variable.scss" as *;',
api: 'modern-compiler',
},
},
},
server: {
allowedHosts: true,
},
},
modules: [
'@nuxt/content',
'@nuxt/icon',
'@nuxt/image',
'@nuxtjs/color-mode',
'@nuxtjs/seo',
'@pinia/nuxt',
'@vueuse/nuxt',
'@zinkawaii/nuxt-shiki',
],
colorMode: {
preference: 'system',
fallback: 'light',
classSuffix: '',
},
content: {
experimental: {
search: {},
},
highlight: {
langs: blogConfig.shiki.langs,
theme: {
default: blogConfig.shiki.defaultTheme,
dark: blogConfig.shiki.darkTheme,
},
},
markdown: {
remarkPlugins: ['remark-reading-time'],
toc: { depth: 4, searchDepth: 4 },
},
},
icon: {
customCollections: [
{ prefix: 'zi', dir: './assets/icons' },
],
// BUG: 首次加载有概率无图标
},
image: {
// Netlify 需要特殊处理
provider: process.env.NUXT_IMAGE_PROVIDER,
domains: blogConfig.imageDomains,
format: ['avif', 'webp'],
},
robots: {
disallow: blogConfig.robotsNotIndex,
},
shiki: {
bundledLangs: blogConfig.shiki.bundledLangs,
bundledThemes: blogConfig.shiki.themes,
defaultLang: 'log',
defaultTheme: {
light: blogConfig.shiki.defaultTheme,
dark: blogConfig.shiki.darkTheme,
},
},
site: {
name: blogConfig.title,
url: blogConfig.url,
},
})