@sugarat/theme 0.2.17 → 0.2.18

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/node.d.ts CHANGED
@@ -365,8 +365,19 @@ declare namespace Theme {
365
365
  /**
366
366
  * 配置内置的 markdown-it-task-checkbox 插件,设置 false 则关闭
367
367
  * 详见 https://github.com/linsir/markdown-it-task-checkbox
368
+ * @default true
368
369
  */
369
370
  taskCheckbox?: TaskCheckbox | boolean;
371
+ /**
372
+ * 支持 markdown 时间线语法,在 vitepress 中使用 markdown 渲染时间线(时间轴)样式。
373
+ * 详见 https://github.com/HanochMa/vitepress-markdown-timeline
374
+ * @default true
375
+ */
376
+ timeline?: boolean;
377
+ /**
378
+ * 回到顶部
379
+ * @default true
380
+ */
370
381
  backToTop?: boolean | BackToTop;
371
382
  }
372
383
  interface BackToTop {
package/node.js CHANGED
@@ -203,6 +203,9 @@ var tabsPlugin = (md) => {
203
203
  };
204
204
  };
205
205
 
206
+ // src/utils/node/mdPlugins.ts
207
+ var import_vitepress_markdown_timeline = __toESM(require("vitepress-markdown-timeline"));
208
+
206
209
  // src/utils/node/index.ts
207
210
  var import_node_child_process = require("child_process");
208
211
  var import_node_path = __toESM(require("path"));
@@ -324,18 +327,15 @@ function getMarkdownPlugins(cfg) {
324
327
  if (cfg?.tabs !== false) {
325
328
  markdownPlugin.push(tabsPlugin);
326
329
  }
327
- if (cfg) {
328
- cfg.mermaid = cfg?.mermaid ?? true;
329
- if (cfg?.mermaid !== false) {
330
- const { MermaidMarkdown } = _require("vitepress-plugin-mermaid");
331
- markdownPlugin.push(MermaidMarkdown);
332
- }
330
+ if (cfg?.mermaid !== false) {
331
+ const { MermaidMarkdown } = _require("vitepress-plugin-mermaid");
332
+ markdownPlugin.push(MermaidMarkdown);
333
333
  }
334
- if (cfg) {
335
- cfg.taskCheckbox = cfg?.taskCheckbox ?? true;
336
- if (cfg.taskCheckbox !== false) {
337
- markdownPlugin.push(taskCheckboxPlugin(cfg.taskCheckbox));
338
- }
334
+ if (cfg.taskCheckbox !== false) {
335
+ markdownPlugin.push(taskCheckboxPlugin(typeof cfg?.taskCheckbox === "boolean" ? {} : cfg?.taskCheckbox));
336
+ }
337
+ if (cfg?.timeline !== false) {
338
+ markdownPlugin.push(import_vitepress_markdown_timeline.default);
339
339
  }
340
340
  return markdownPlugin;
341
341
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sugarat/theme",
3
- "version": "0.2.17",
3
+ "version": "0.2.18",
4
4
  "description": "简约风的 Vitepress 博客主题,sugarat vitepress blog theme",
5
5
  "author": "sugar",
6
6
  "license": "MIT",
@@ -42,6 +42,7 @@
42
42
  "gray-matter": "^4.0.3",
43
43
  "markdown-it-task-checkbox": "^1.0.6",
44
44
  "mermaid": "^10.2.4",
45
+ "vitepress-markdown-timeline": "^1.2.1",
45
46
  "vitepress-plugin-mermaid": "2.0.13",
46
47
  "vitepress-plugin-pagefind": "0.2.10",
47
48
  "vitepress-plugin-rss": "0.2.1",
@@ -37,9 +37,9 @@ const { Layout } = Theme
37
37
  <!-- 阅读时间分析 -->
38
38
  <ClientOnly>
39
39
  <BlogArticleAnalyze />
40
+ <!-- 图片预览 -->
41
+ <BlogImagePreview />
40
42
  </ClientOnly>
41
- <!-- 图片预览 -->
42
- <BlogImagePreview />
43
43
  </template>
44
44
 
45
45
  <template #nav-bar-content-before>
@@ -28,8 +28,8 @@ const iconSVGStr = computed(() => typeof backToTopConfig === 'boolean' ? '' : ba
28
28
 
29
29
  <template>
30
30
  <div v-if="open" v-show="show" class="back-to-top">
31
- <span class="icon-wrapper">
32
- <ElIcon @click="handleBackRoTop">
31
+ <span class="icon-wrapper" @click="handleBackRoTop">
32
+ <ElIcon :size="20">
33
33
  <i v-if="iconSVGStr" v-outer-html="iconSVGStr" />
34
34
  <svg v-else width="512" height="512" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
35
35
  <path
@@ -94,15 +94,15 @@ const labelText = computed(() => {
94
94
 
95
95
  <div v-show="!commentIsVisible" class="comment-btn-wrapper">
96
96
  <span v-if="!mobileMinify && labelText" class="icon-wrapper-text" @click="handleScrollToComment">
97
- <ElIcon>
97
+ <ElIcon :size="20">
98
98
  <CommentIcon />
99
99
  </ElIcon>
100
100
  <span class="text">
101
101
  {{ labelText }}
102
102
  </span>
103
103
  </span>
104
- <span v-else class="icon-wrapper">
105
- <ElIcon @click="handleScrollToComment">
104
+ <span v-else class="icon-wrapper" @click="handleScrollToComment">
105
+ <ElIcon :size="20">
106
106
  <CommentIcon />
107
107
  </ElIcon>
108
108
  </span>
@@ -397,9 +397,19 @@ export namespace Theme {
397
397
  /**
398
398
  * 配置内置的 markdown-it-task-checkbox 插件,设置 false 则关闭
399
399
  * 详见 https://github.com/linsir/markdown-it-task-checkbox
400
+ * @default true
400
401
  */
401
402
  taskCheckbox?: TaskCheckbox | boolean
402
-
403
+ /**
404
+ * 支持 markdown 时间线语法,在 vitepress 中使用 markdown 渲染时间线(时间轴)样式。
405
+ * 详见 https://github.com/HanochMa/vitepress-markdown-timeline
406
+ * @default true
407
+ */
408
+ timeline?: boolean
409
+ /**
410
+ * 回到顶部
411
+ * @default true
412
+ */
403
413
  backToTop?: boolean | BackToTop
404
414
  }
405
415
 
package/src/index.ts CHANGED
@@ -5,9 +5,13 @@ import './styles/index.scss'
5
5
  import 'element-plus/dist/index.css'
6
6
  import 'element-plus/theme-chalk/dark/css-vars.css'
7
7
 
8
+ // 引入时间线组件样式
9
+ import 'vitepress-markdown-timeline/dist/theme/index.css'
8
10
  import type { Theme } from 'vitepress'
9
11
  import DefaultTheme from 'vitepress/theme'
10
12
  import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client'
13
+
14
+ // 图表渲染组件
11
15
  import Mermaid from 'vitepress-plugin-mermaid/Mermaid.vue'
12
16
  import BlogApp from './components/BlogApp.vue'
13
17
  import { withConfigProvider } from './composables/config/blog'
@@ -27,7 +31,7 @@ export const BlogTheme: Theme = {
27
31
  DefaultTheme.enhanceApp(ctx)
28
32
  ctx.app.component('TimelinePage', TimelinePage)
29
33
  ctx.app.component('UserWorksPage', UserWorksPage)
30
- ctx.app.component('Mermaid', Mermaid)
34
+ ctx.app.component('Mermaid', Mermaid as any)
31
35
  }
32
36
  }
33
37
 
@@ -2,6 +2,7 @@
2
2
  import { createRequire } from 'module'
3
3
  import { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'
4
4
  import type { UserConfig } from 'vitepress'
5
+ import timeline from 'vitepress-markdown-timeline'
5
6
  import type { Theme } from '../../composables/config/index'
6
7
  import { aliasObjectToArray } from './index'
7
8
 
@@ -17,25 +18,22 @@ export function getMarkdownPlugins(cfg?: Partial<Theme.BlogConfig>) {
17
18
  }
18
19
 
19
20
  // 添加mermaid markdown 插件
20
- if (cfg) {
21
- cfg.mermaid = cfg?.mermaid ?? true
22
- if (cfg?.mermaid !== false) {
23
- const { MermaidMarkdown } = _require('vitepress-plugin-mermaid')
24
- markdownPlugin.push(MermaidMarkdown)
25
- }
21
+ if (cfg?.mermaid !== false) {
22
+ const { MermaidMarkdown } = _require('vitepress-plugin-mermaid')
23
+ markdownPlugin.push(MermaidMarkdown)
26
24
  }
27
25
 
28
- if (cfg) {
29
- cfg.taskCheckbox = cfg?.taskCheckbox ?? true
30
- if (cfg.taskCheckbox !== false) {
31
- markdownPlugin.push(taskCheckboxPlugin(cfg.taskCheckbox))
32
- }
26
+ if (cfg.taskCheckbox !== false) {
27
+ markdownPlugin.push(taskCheckboxPlugin(typeof cfg?.taskCheckbox === 'boolean' ? {} : cfg?.taskCheckbox))
33
28
  }
34
29
 
30
+ if (cfg?.timeline !== false) {
31
+ markdownPlugin.push(timeline)
32
+ }
35
33
  return markdownPlugin
36
34
  }
37
35
 
38
- export function taskCheckboxPlugin(ops: Theme.TaskCheckbox | boolean) {
36
+ export function taskCheckboxPlugin(ops?: Theme.TaskCheckbox) {
39
37
  return (md: any) => {
40
38
  md.use(_require('markdown-it-task-checkbox'), ops)
41
39
  }