@sugarat/theme 0.1.32 → 0.1.34
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 +6 -1
- package/node.js +32 -1
- package/package.json +4 -1
- package/src/composables/config/index.ts +5 -0
- package/src/node.ts +46 -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,11 @@ 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
|
+
* @default false
|
|
243
|
+
*/
|
|
244
|
+
mermaid?: any;
|
|
240
245
|
}
|
|
241
246
|
interface Config extends DefaultTheme.Config {
|
|
242
247
|
blog?: BlogConfig;
|
|
@@ -251,6 +256,6 @@ declare function getDefaultTitle(content: string): string;
|
|
|
251
256
|
declare function clearMatterContent(content: string): string;
|
|
252
257
|
declare function getFileBirthTime(url: string): string;
|
|
253
258
|
declare function getGitTimestamp(file: string): Promise<unknown>;
|
|
254
|
-
declare function defineConfig(config: UserConfig<Theme.Config>): UserConfig<
|
|
259
|
+
declare function defineConfig(config: UserConfig<Theme.Config>): UserConfig<any>;
|
|
255
260
|
|
|
256
261
|
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,19 @@ function getThemeConfig(cfg) {
|
|
|
350
353
|
}
|
|
351
354
|
};
|
|
352
355
|
}
|
|
356
|
+
if (cfg) {
|
|
357
|
+
cfg.mermaid = cfg?.mermaid ?? false;
|
|
358
|
+
}
|
|
359
|
+
if (cfg?.mermaid !== false) {
|
|
360
|
+
extraConfig.vite = {
|
|
361
|
+
...extraConfig.vite,
|
|
362
|
+
resolve: {
|
|
363
|
+
alias: {
|
|
364
|
+
mermaid: "mermaid/dist/mermaid.esm.mjs"
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
}
|
|
353
369
|
return {
|
|
354
370
|
themeConfig: {
|
|
355
371
|
blog: {
|
|
@@ -433,7 +449,22 @@ function defineConfig(config) {
|
|
|
433
449
|
console.warn("https://theme.sugarat.top/config/global.html");
|
|
434
450
|
}, 1200);
|
|
435
451
|
}
|
|
436
|
-
|
|
452
|
+
const extendThemeConfig = config.extends?.themeConfig?.blog;
|
|
453
|
+
const resultConfig = extendThemeConfig.mermaid === false ? config : (0, import_vitepress_plugin_mermaid.withMermaid)({
|
|
454
|
+
...config,
|
|
455
|
+
mermaid: extendThemeConfig.mermaid === true ? {} : extendThemeConfig.mermaid
|
|
456
|
+
});
|
|
457
|
+
if (!resultConfig.markdown)
|
|
458
|
+
resultConfig.markdown = {};
|
|
459
|
+
if (config.extends?.markdown?.config) {
|
|
460
|
+
const markdownExtendsConfigOriginal = config.extends?.markdown?.config;
|
|
461
|
+
const selfMarkdownConfig = resultConfig.markdown?.config;
|
|
462
|
+
resultConfig.markdown.config = (...rest) => {
|
|
463
|
+
selfMarkdownConfig?.(...rest);
|
|
464
|
+
markdownExtendsConfigOriginal?.(...rest);
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
return resultConfig;
|
|
437
468
|
}
|
|
438
469
|
// Annotate the CommonJS export names for ESM import in node:
|
|
439
470
|
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.34",
|
|
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,11 @@ 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
|
+
* @default false
|
|
263
|
+
*/
|
|
264
|
+
mermaid?: any
|
|
260
265
|
}
|
|
261
266
|
|
|
262
267
|
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,21 @@ export function getThemeConfig(cfg?: Partial<Theme.BlogConfig>) {
|
|
|
177
178
|
}
|
|
178
179
|
}
|
|
179
180
|
}
|
|
181
|
+
if (cfg) {
|
|
182
|
+
cfg.mermaid = cfg?.mermaid ?? false
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// 流程图支持
|
|
186
|
+
if (cfg?.mermaid !== false) {
|
|
187
|
+
extraConfig.vite = {
|
|
188
|
+
...extraConfig.vite,
|
|
189
|
+
resolve: {
|
|
190
|
+
alias: {
|
|
191
|
+
mermaid: 'mermaid/dist/mermaid.esm.mjs'
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
180
196
|
return {
|
|
181
197
|
themeConfig: {
|
|
182
198
|
blog: {
|
|
@@ -309,7 +325,36 @@ export function defineConfig(config: UserConfig<Theme.Config>) {
|
|
|
309
325
|
console.warn('https://theme.sugarat.top/config/global.html')
|
|
310
326
|
}, 1200)
|
|
311
327
|
}
|
|
312
|
-
|
|
328
|
+
// @ts-ignore
|
|
329
|
+
const extendThemeConfig = config.extends?.themeConfig
|
|
330
|
+
?.blog as Theme.BlogConfig
|
|
331
|
+
|
|
332
|
+
// 开关支持Mermaid
|
|
333
|
+
const resultConfig =
|
|
334
|
+
extendThemeConfig.mermaid === false
|
|
335
|
+
? config
|
|
336
|
+
: withMermaid({
|
|
337
|
+
...config,
|
|
338
|
+
mermaid:
|
|
339
|
+
extendThemeConfig.mermaid === true ? {} : extendThemeConfig.mermaid
|
|
340
|
+
})
|
|
341
|
+
|
|
342
|
+
// 处理markdown插件
|
|
343
|
+
if (!resultConfig.markdown) resultConfig.markdown = {}
|
|
344
|
+
// @ts-ignore
|
|
345
|
+
if (config.extends?.markdown?.config) {
|
|
346
|
+
const markdownExtendsConfigOriginal =
|
|
347
|
+
// @ts-ignore
|
|
348
|
+
config.extends?.markdown?.config
|
|
349
|
+
const selfMarkdownConfig = resultConfig.markdown?.config
|
|
350
|
+
|
|
351
|
+
resultConfig.markdown.config = (...rest: any[]) => {
|
|
352
|
+
// @ts-ignore
|
|
353
|
+
selfMarkdownConfig?.(...rest)
|
|
354
|
+
markdownExtendsConfigOriginal?.(...rest)
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return resultConfig
|
|
313
358
|
}
|
|
314
359
|
|
|
315
360
|
export { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'
|