@sugarat/theme 0.1.34 → 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 +18 -7
- package/node.d.ts +1 -0
- package/node.js +1 -1
- package/package.json +1 -1
- package/src/components/BlogItem.vue +24 -2
- package/src/components/BlogList.vue +1 -0
- package/src/composables/config/index.ts +1 -0
- package/src/node.ts +2 -3
package/README.md
CHANGED
|
@@ -5,11 +5,21 @@
|
|
|
5
5
|

|
|
6
6
|
|
|
7
7
|
## Quick Start
|
|
8
|
-
①
|
|
9
|
-
|
|
10
|
-
|
|
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
|
+

|
|
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
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
|
|
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;
|
package/package.json
CHANGED
|
@@ -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">
|
|
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);
|
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) {
|