@sugarat/theme 0.1.33 → 0.1.35

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
@@ -5,11 +5,21 @@
5
5
  ![图片](https://img.cdn.sugarat.top/mdImg/MTY3MzE3MDUxOTMwMw==673170519303)
6
6
 
7
7
  ## Quick Start
8
- 初始化项目模板
9
- ```sh
10
- npx degit ATQQ/sugar-blog/packages/template my-blog-demo
8
+ 创建项目
9
+
10
+ ```bash
11
+ # With PNPM:
12
+ pnpm create @sugarat/theme
13
+
14
+ # With NPM:
15
+ npm create @sugarat/theme@latest
16
+
17
+ # With Yarn:
18
+ yarn create @sugarat/theme
11
19
  ```
12
20
 
21
+ ![](https://img.cdn.sugarat.top/mdImg/MTY4OTQyMDE1NTcxMA==689420155710)
22
+
13
23
  ② 安装依赖
14
24
  ```sh
15
25
  pnpm install
@@ -24,13 +34,14 @@ pnpm dev
24
34
  ```sh
25
35
  pnpm build
26
36
  ```
37
+
38
+ ⑤ 预览构建产物
39
+ ```sh
40
+ pnpm serve
41
+ ```
27
42
  ## Advanced Ssage
28
43
  详细配置见文档 https://theme.sugarat.top
29
44
 
30
- ## Known bugs and workarounds
31
- * `zlib: unexpected end of file:` clearing the cache folder (rm -rf ~/.degit)
32
-
33
-
34
45
  ## Thanks
35
46
  从以下项目中获得了灵感&经验
36
47
  * [vuepress-reco/vuepress-theme-reco-1.x](https://github.com/vuepress-reco/vuepress-theme-reco-1.x)
package/node.d.ts CHANGED
@@ -41,6 +41,7 @@ declare namespace Theme {
41
41
  date: string;
42
42
  tag?: string[];
43
43
  description?: string;
44
+ descriptionHTML?: string;
44
45
  cover?: string;
45
46
  hiddenCover?: boolean;
46
47
  readingTime?: boolean;
@@ -239,6 +240,7 @@ declare namespace Theme {
239
240
  works?: UserWorks;
240
241
  /**
241
242
  * https://mermaid.js.org/config/setup/modules/mermaidAPI.html#mermaidapi-configuration-defaults for options
243
+ * @default false
242
244
  */
243
245
  mermaid?: any;
244
246
  }
package/node.js CHANGED
@@ -281,7 +281,7 @@ function getThemeConfig(cfg) {
281
281
  ]);
282
282
  const wordCount = 100;
283
283
  meta.description = meta.description || getTextSummary(fileContent, wordCount);
284
- meta.cover = meta.cover || fileContent.match(/[!]\[.*?\]\((https:\/\/.+)\)/)?.[1] || "";
284
+ meta.cover = meta.cover ?? (fileContent.match(/[!]\[.*?\]\((https:\/\/.+)\)/)?.[1] || "");
285
285
  if (meta.publish === false) {
286
286
  meta.hidden = true;
287
287
  meta.recommend = false;
@@ -353,6 +353,9 @@ function getThemeConfig(cfg) {
353
353
  }
354
354
  };
355
355
  }
356
+ if (cfg) {
357
+ cfg.mermaid = cfg?.mermaid ?? false;
358
+ }
356
359
  if (cfg?.mermaid !== false) {
357
360
  extraConfig.vite = {
358
361
  ...extraConfig.vite,
@@ -447,7 +450,10 @@ function defineConfig(config) {
447
450
  }, 1200);
448
451
  }
449
452
  const extendThemeConfig = config.extends?.themeConfig?.blog;
450
- const resultConfig = extendThemeConfig.mermaid === false ? config : (0, import_vitepress_plugin_mermaid.withMermaid)({ ...config, mermaid: extendThemeConfig.mermaid });
453
+ const resultConfig = extendThemeConfig.mermaid === false ? config : (0, import_vitepress_plugin_mermaid.withMermaid)({
454
+ ...config,
455
+ mermaid: extendThemeConfig.mermaid === true ? {} : extendThemeConfig.mermaid
456
+ });
451
457
  if (!resultConfig.markdown)
452
458
  resultConfig.markdown = {};
453
459
  if (config.extends?.markdown?.config) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sugarat/theme",
3
- "version": "0.1.33",
3
+ "version": "0.1.35",
4
4
  "description": "简约风的 Vitepress 博客主题,sugarat vitepress blog theme",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -9,7 +9,12 @@
9
9
  <!-- 标题 -->
10
10
  <p class="title" v-if="!inMobile">{{ title }}</p>
11
11
  <!-- 简短描述 -->
12
- <p class="description" v-if="!!description">{{ description }}</p>
12
+ <p class="description" v-if="!descriptionHTML && !!description">
13
+ {{ description }}
14
+ </p>
15
+ <template v-if="descriptionHTML">
16
+ <div class="description-html" v-html="descriptionHTML"></div>
17
+ </template>
13
18
  <!-- 底部补充描述 -->
14
19
  <div class="badge-list" v-if="!inMobile">
15
20
  <span class="split" v-if="author">{{ author }}</span>
@@ -47,15 +52,29 @@ const props = defineProps<{
47
52
  date: string | Date
48
53
  sticky?: number
49
54
  description?: string
55
+ descriptionHTML?: string
50
56
  tag?: string[]
51
57
  author?: string
52
- cover?: string
58
+ cover?: string | boolean
53
59
  pin?: number
54
60
  }>()
55
61
 
56
62
  const showTime = computed(() => {
57
63
  return formatShowDate(props.date)
58
64
  })
65
+
66
+ // function isWrappedWithPreventDefault(element: HTMLElement) {
67
+ // let parent = element.parentElement
68
+
69
+ // while (parent) {
70
+ // if (parent.hasAttribute('preventDefault')) {
71
+ // return true
72
+ // }
73
+ // parent = parent.parentElement
74
+ // }
75
+
76
+ // return false
77
+ // }
59
78
  </script>
60
79
 
61
80
  <style lang="scss" scoped>
@@ -131,6 +150,9 @@ const showTime = computed(() => {
131
150
  -webkit-line-clamp: 2;
132
151
  -webkit-box-orient: vertical;
133
152
  }
153
+ .description-html {
154
+ font-size: 14px;
155
+ }
134
156
  .badge-list {
135
157
  font-size: 13px;
136
158
  color: var(--badge-font-color);
@@ -5,6 +5,7 @@
5
5
  :route="v.route"
6
6
  :title="v.meta.title"
7
7
  :description="v.meta.description"
8
+ :description-h-t-m-l="v.meta.descriptionHTML"
8
9
  :date="v.meta.date"
9
10
  :tag="v.meta.tag"
10
11
  :cover="v.meta.cover"
@@ -42,6 +42,7 @@ export namespace Theme {
42
42
  date: string
43
43
  tag?: string[]
44
44
  description?: string
45
+ descriptionHTML?: string
45
46
  cover?: string
46
47
  hiddenCover?: boolean
47
48
  readingTime?: boolean
@@ -259,6 +260,7 @@ export namespace Theme {
259
260
  works?: UserWorks
260
261
  /**
261
262
  * https://mermaid.js.org/config/setup/modules/mermaidAPI.html#mermaidapi-configuration-defaults for options
263
+ * @default false
262
264
  */
263
265
  mermaid?: any
264
266
  }
package/src/node.ts CHANGED
@@ -84,9 +84,8 @@ export function getThemeConfig(cfg?: Partial<Theme.BlogConfig>) {
84
84
 
85
85
  // 获取封面图
86
86
  meta.cover =
87
- meta.cover ||
88
- fileContent.match(/[!]\[.*?\]\((https:\/\/.+)\)/)?.[1] ||
89
- ''
87
+ meta.cover ??
88
+ (fileContent.match(/[!]\[.*?\]\((https:\/\/.+)\)/)?.[1] || '')
90
89
 
91
90
  // 是否发布 默认发布
92
91
  if (meta.publish === false) {
@@ -178,6 +177,10 @@ export function getThemeConfig(cfg?: Partial<Theme.BlogConfig>) {
178
177
  }
179
178
  }
180
179
  }
180
+ if (cfg) {
181
+ cfg.mermaid = cfg?.mermaid ?? false
182
+ }
183
+
181
184
  // 流程图支持
182
185
  if (cfg?.mermaid !== false) {
183
186
  extraConfig.vite = {
@@ -329,7 +332,11 @@ export function defineConfig(config: UserConfig<Theme.Config>) {
329
332
  const resultConfig =
330
333
  extendThemeConfig.mermaid === false
331
334
  ? config
332
- : withMermaid({ ...config, mermaid: extendThemeConfig.mermaid })
335
+ : withMermaid({
336
+ ...config,
337
+ mermaid:
338
+ extendThemeConfig.mermaid === true ? {} : extendThemeConfig.mermaid
339
+ })
333
340
 
334
341
  // 处理markdown插件
335
342
  if (!resultConfig.markdown) resultConfig.markdown = {}