@sugarat/theme 0.1.31 → 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 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
@@ -68,6 +68,7 @@ declare namespace Theme {
68
68
  * 专栏&合集
69
69
  */
70
70
  album: string;
71
+ publish?: boolean;
71
72
  }
72
73
  interface PageData {
73
74
  route: string;
@@ -236,6 +237,10 @@ declare namespace Theme {
236
237
  */
237
238
  tabs?: boolean;
238
239
  works?: UserWorks;
240
+ /**
241
+ * https://mermaid.js.org/config/setup/modules/mermaidAPI.html#mermaidapi-configuration-defaults for options
242
+ */
243
+ mermaid?: any;
239
244
  }
240
245
  interface Config extends DefaultTheme.Config {
241
246
  blog?: BlogConfig;
@@ -250,6 +255,6 @@ declare function getDefaultTitle(content: string): string;
250
255
  declare function clearMatterContent(content: string): string;
251
256
  declare function getFileBirthTime(url: string): string;
252
257
  declare function getGitTimestamp(file: string): Promise<unknown>;
253
- declare function defineConfig(config: UserConfig<Theme.Config>): UserConfig<Theme.Config>;
258
+ declare function defineConfig(config: UserConfig<Theme.Config>): UserConfig<any>;
254
259
 
255
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)) {
@@ -279,6 +282,10 @@ function getThemeConfig(cfg) {
279
282
  const wordCount = 100;
280
283
  meta.description = meta.description || getTextSummary(fileContent, wordCount);
281
284
  meta.cover = meta.cover || fileContent.match(/[!]\[.*?\]\((https:\/\/.+)\)/)?.[1] || "";
285
+ if (meta.publish === false) {
286
+ meta.hidden = true;
287
+ meta.recommend = false;
288
+ }
282
289
  return {
283
290
  route: `/${route}`,
284
291
  meta
@@ -346,6 +353,16 @@ function getThemeConfig(cfg) {
346
353
  }
347
354
  };
348
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
+ }
349
366
  return {
350
367
  themeConfig: {
351
368
  blog: {
@@ -429,7 +446,19 @@ function defineConfig(config) {
429
446
  console.warn("https://theme.sugarat.top/config/global.html");
430
447
  }, 1200);
431
448
  }
432
- return config;
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;
433
462
  }
434
463
  // Annotate the CommonJS export names for ESM import in node:
435
464
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sugarat/theme",
3
- "version": "0.1.31",
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": {
@@ -51,7 +51,7 @@ const activeTag = useActiveTag()
51
51
  const activeTagLabel = computed(() => activeTag.value.label)
52
52
 
53
53
  const wikiList = computed(() => {
54
- const topList = docs.value.filter((v) => !!v.meta.top)
54
+ const topList = docs.value.filter((v) => !v.meta.hidden && !!v.meta.top)
55
55
  topList.sort((a, b) => {
56
56
  const aTop = a?.meta?.top
57
57
  const bTop = b?.meta.top
@@ -70,6 +70,8 @@ export namespace Theme {
70
70
  * 专栏&合集
71
71
  */
72
72
  album: string
73
+ // 是否发布
74
+ publish?: boolean
73
75
  }
74
76
  export interface PageData {
75
77
  route: string
@@ -255,6 +257,10 @@ export namespace Theme {
255
257
  */
256
258
  tabs?: boolean
257
259
  works?: UserWorks
260
+ /**
261
+ * https://mermaid.js.org/config/setup/modules/mermaidAPI.html#mermaidapi-configuration-defaults for options
262
+ */
263
+ mermaid?: any
258
264
  }
259
265
 
260
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
 
@@ -48,6 +49,7 @@ export function getThemeConfig(cfg?: Partial<Theme.BlogConfig>) {
48
49
  const meta: Partial<Theme.PageMeta> = {
49
50
  ...matter(fileContent).data
50
51
  }
52
+
51
53
  if (!meta.title) {
52
54
  meta.title = getDefaultTitle(fileContent)
53
55
  }
@@ -85,6 +87,13 @@ export function getThemeConfig(cfg?: Partial<Theme.BlogConfig>) {
85
87
  meta.cover ||
86
88
  fileContent.match(/[!]\[.*?\]\((https:\/\/.+)\)/)?.[1] ||
87
89
  ''
90
+
91
+ // 是否发布 默认发布
92
+ if (meta.publish === false) {
93
+ meta.hidden = true
94
+ meta.recommend = false
95
+ }
96
+
88
97
  return {
89
98
  route: `/${route}`,
90
99
  meta
@@ -169,6 +178,17 @@ export function getThemeConfig(cfg?: Partial<Theme.BlogConfig>) {
169
178
  }
170
179
  }
171
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
+ }
172
192
  return {
173
193
  themeConfig: {
174
194
  blog: {
@@ -301,7 +321,32 @@ export function defineConfig(config: UserConfig<Theme.Config>) {
301
321
  console.warn('https://theme.sugarat.top/config/global.html')
302
322
  }, 1200)
303
323
  }
304
- return config
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
305
350
  }
306
351
 
307
352
  export { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'
@@ -103,3 +103,24 @@ html[class='dark'] {
103
103
  word-break: break-all;
104
104
  }
105
105
  }
106
+
107
+ ::-webkit-scrollbar {
108
+ width: 5px;
109
+ height: 5px;
110
+ }
111
+
112
+ ::-webkit-scrollbar-track-piece {
113
+ background-color: rgba(0, 0, 0, 0);
114
+ }
115
+
116
+ ::-webkit-scrollbar-thumb:vertical {
117
+ height: 5px;
118
+ border-radius: 4px;
119
+ background-color: var(--el-color-primary);
120
+ }
121
+
122
+ ::-webkit-scrollbar-thumb:horizontal {
123
+ width: 5px;
124
+ border-radius: 4px;
125
+ background-color: var(--el-color-primary);
126
+ }