@sugarat/theme 0.1.32 → 0.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/node.d.ts +5 -1
- package/node.js +26 -1
- package/package.json +4 -1
- package/src/composables/config/index.ts +4 -0
- package/src/node.ts +38 -1
package/README.md
CHANGED
|
@@ -36,4 +36,7 @@ pnpm build
|
|
|
36
36
|
* [vuepress-reco/vuepress-theme-reco-1.x](https://github.com/vuepress-reco/vuepress-theme-reco-1.x)
|
|
37
37
|
* [@vue/theme](https://github.com/vuejs/theme)
|
|
38
38
|
* [vitest](https://vitest.dev/)
|
|
39
|
-
* [element-plus](https://github.com/element-plus/element-plus)
|
|
39
|
+
* [element-plus](https://github.com/element-plus/element-plus)
|
|
40
|
+
* [charles7c.github.io](https://github.com/Charles7c/charles7c.github.io)
|
|
41
|
+
* [vitepress-blog-zaun](https://github.com/clark-cui/vitepress-blog-zaun)
|
|
42
|
+
* [surmon](https://surmon.me/)
|
package/node.d.ts
CHANGED
|
@@ -237,6 +237,10 @@ declare namespace Theme {
|
|
|
237
237
|
*/
|
|
238
238
|
tabs?: boolean;
|
|
239
239
|
works?: UserWorks;
|
|
240
|
+
/**
|
|
241
|
+
* https://mermaid.js.org/config/setup/modules/mermaidAPI.html#mermaidapi-configuration-defaults for options
|
|
242
|
+
*/
|
|
243
|
+
mermaid?: any;
|
|
240
244
|
}
|
|
241
245
|
interface Config extends DefaultTheme.Config {
|
|
242
246
|
blog?: BlogConfig;
|
|
@@ -251,6 +255,6 @@ declare function getDefaultTitle(content: string): string;
|
|
|
251
255
|
declare function clearMatterContent(content: string): string;
|
|
252
256
|
declare function getFileBirthTime(url: string): string;
|
|
253
257
|
declare function getGitTimestamp(file: string): Promise<unknown>;
|
|
254
|
-
declare function defineConfig(config: UserConfig<Theme.Config>): UserConfig<
|
|
258
|
+
declare function defineConfig(config: UserConfig<Theme.Config>): UserConfig<any>;
|
|
255
259
|
|
|
256
260
|
export { clearMatterContent, defineConfig, getDefaultTitle, getFileBirthTime, getGitTimestamp, getThemeConfig };
|
package/node.js
CHANGED
|
@@ -205,6 +205,9 @@ var tabsPlugin = (md) => {
|
|
|
205
205
|
};
|
|
206
206
|
};
|
|
207
207
|
|
|
208
|
+
// src/node.ts
|
|
209
|
+
var import_vitepress_plugin_mermaid = require("vitepress-plugin-mermaid");
|
|
210
|
+
|
|
208
211
|
// src/utils/index.ts
|
|
209
212
|
function formatDate(d, fmt = "yyyy-MM-dd hh:mm:ss") {
|
|
210
213
|
if (!(d instanceof Date)) {
|
|
@@ -350,6 +353,16 @@ function getThemeConfig(cfg) {
|
|
|
350
353
|
}
|
|
351
354
|
};
|
|
352
355
|
}
|
|
356
|
+
if (cfg?.mermaid !== false) {
|
|
357
|
+
extraConfig.vite = {
|
|
358
|
+
...extraConfig.vite,
|
|
359
|
+
resolve: {
|
|
360
|
+
alias: {
|
|
361
|
+
mermaid: "mermaid/dist/mermaid.esm.mjs"
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
}
|
|
353
366
|
return {
|
|
354
367
|
themeConfig: {
|
|
355
368
|
blog: {
|
|
@@ -433,7 +446,19 @@ function defineConfig(config) {
|
|
|
433
446
|
console.warn("https://theme.sugarat.top/config/global.html");
|
|
434
447
|
}, 1200);
|
|
435
448
|
}
|
|
436
|
-
|
|
449
|
+
const extendThemeConfig = config.extends?.themeConfig?.blog;
|
|
450
|
+
const resultConfig = extendThemeConfig.mermaid === false ? config : (0, import_vitepress_plugin_mermaid.withMermaid)({ ...config, mermaid: extendThemeConfig.mermaid });
|
|
451
|
+
if (!resultConfig.markdown)
|
|
452
|
+
resultConfig.markdown = {};
|
|
453
|
+
if (config.extends?.markdown?.config) {
|
|
454
|
+
const markdownExtendsConfigOriginal = config.extends?.markdown?.config;
|
|
455
|
+
const selfMarkdownConfig = resultConfig.markdown?.config;
|
|
456
|
+
resultConfig.markdown.config = (...rest) => {
|
|
457
|
+
selfMarkdownConfig?.(...rest);
|
|
458
|
+
markdownExtendsConfigOriginal?.(...rest);
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
return resultConfig;
|
|
437
462
|
}
|
|
438
463
|
// Annotate the CommonJS export names for ESM import in node:
|
|
439
464
|
0 && (module.exports = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sugarat/theme",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.33",
|
|
4
4
|
"description": "简约风的 Vitepress 博客主题,sugarat vitepress blog theme",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -34,11 +34,14 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@mdit-vue/shared": "^0.12.0",
|
|
37
|
+
"@mermaid-js/mermaid-mindmap": "^9.3.0",
|
|
37
38
|
"@vue/shared": "^3.2.45",
|
|
38
39
|
"@vueuse/core": "^9.6.0",
|
|
39
40
|
"fast-glob": "^3.2.12",
|
|
40
41
|
"gray-matter": "^4.0.3",
|
|
41
42
|
"highlight.js": "^11.7.0",
|
|
43
|
+
"mermaid": "^10.2.4",
|
|
44
|
+
"vitepress-plugin-mermaid": "^2.0.13",
|
|
42
45
|
"vue-command-palette": "^0.1.4"
|
|
43
46
|
},
|
|
44
47
|
"devDependencies": {
|
|
@@ -257,6 +257,10 @@ export namespace Theme {
|
|
|
257
257
|
*/
|
|
258
258
|
tabs?: boolean
|
|
259
259
|
works?: UserWorks
|
|
260
|
+
/**
|
|
261
|
+
* https://mermaid.js.org/config/setup/modules/mermaidAPI.html#mermaidapi-configuration-defaults for options
|
|
262
|
+
*/
|
|
263
|
+
mermaid?: any
|
|
260
264
|
}
|
|
261
265
|
|
|
262
266
|
export interface Config extends DefaultTheme.Config {
|
package/src/node.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { execSync, spawn, spawnSync } from 'child_process'
|
|
|
6
6
|
import path from 'path'
|
|
7
7
|
import type { SiteConfig, UserConfig } from 'vitepress'
|
|
8
8
|
import { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'
|
|
9
|
+
import { withMermaid } from 'vitepress-plugin-mermaid'
|
|
9
10
|
import { formatDate } from './utils/index'
|
|
10
11
|
import type { Theme } from './composables/config/index'
|
|
11
12
|
|
|
@@ -177,6 +178,17 @@ export function getThemeConfig(cfg?: Partial<Theme.BlogConfig>) {
|
|
|
177
178
|
}
|
|
178
179
|
}
|
|
179
180
|
}
|
|
181
|
+
// 流程图支持
|
|
182
|
+
if (cfg?.mermaid !== false) {
|
|
183
|
+
extraConfig.vite = {
|
|
184
|
+
...extraConfig.vite,
|
|
185
|
+
resolve: {
|
|
186
|
+
alias: {
|
|
187
|
+
mermaid: 'mermaid/dist/mermaid.esm.mjs'
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
180
192
|
return {
|
|
181
193
|
themeConfig: {
|
|
182
194
|
blog: {
|
|
@@ -309,7 +321,32 @@ export function defineConfig(config: UserConfig<Theme.Config>) {
|
|
|
309
321
|
console.warn('https://theme.sugarat.top/config/global.html')
|
|
310
322
|
}, 1200)
|
|
311
323
|
}
|
|
312
|
-
|
|
324
|
+
// @ts-ignore
|
|
325
|
+
const extendThemeConfig = config.extends?.themeConfig
|
|
326
|
+
?.blog as Theme.BlogConfig
|
|
327
|
+
|
|
328
|
+
// 开关支持Mermaid
|
|
329
|
+
const resultConfig =
|
|
330
|
+
extendThemeConfig.mermaid === false
|
|
331
|
+
? config
|
|
332
|
+
: withMermaid({ ...config, mermaid: extendThemeConfig.mermaid })
|
|
333
|
+
|
|
334
|
+
// 处理markdown插件
|
|
335
|
+
if (!resultConfig.markdown) resultConfig.markdown = {}
|
|
336
|
+
// @ts-ignore
|
|
337
|
+
if (config.extends?.markdown?.config) {
|
|
338
|
+
const markdownExtendsConfigOriginal =
|
|
339
|
+
// @ts-ignore
|
|
340
|
+
config.extends?.markdown?.config
|
|
341
|
+
const selfMarkdownConfig = resultConfig.markdown?.config
|
|
342
|
+
|
|
343
|
+
resultConfig.markdown.config = (...rest: any[]) => {
|
|
344
|
+
// @ts-ignore
|
|
345
|
+
selfMarkdownConfig?.(...rest)
|
|
346
|
+
markdownExtendsConfigOriginal?.(...rest)
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return resultConfig
|
|
313
350
|
}
|
|
314
351
|
|
|
315
352
|
export { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'
|