@sugarat/theme 0.3.2 → 0.3.3
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 +28 -1
- package/node.js +1 -1
- package/package.json +23 -20
- package/src/components/BlogHomeTags.vue +2 -2
- package/src/components/BlogItem.vue +37 -3
- package/src/composables/config/blog.ts +4 -0
- package/src/composables/config/index.ts +29 -1
- package/src/index.ts +13 -1
- package/src/styles/index.scss +5 -0
package/node.d.ts
CHANGED
|
@@ -91,7 +91,10 @@ declare namespace Theme {
|
|
|
91
91
|
}
|
|
92
92
|
interface activeTag {
|
|
93
93
|
label: string;
|
|
94
|
-
|
|
94
|
+
/**
|
|
95
|
+
* @type {string}
|
|
96
|
+
*/
|
|
97
|
+
type: any;
|
|
95
98
|
}
|
|
96
99
|
type CommentConfig = ((GiscusOption & CommentCommonConfig) | GiscusConfig | ArtalkConfig);
|
|
97
100
|
interface CommentCommonConfig {
|
|
@@ -412,6 +415,10 @@ declare namespace Theme {
|
|
|
412
415
|
* @default true
|
|
413
416
|
*/
|
|
414
417
|
darkTransition?: boolean;
|
|
418
|
+
/**
|
|
419
|
+
* 渲染时替换图片地址
|
|
420
|
+
*/
|
|
421
|
+
imageStyle?: ImageStyleConfig;
|
|
415
422
|
}
|
|
416
423
|
interface BackToTop {
|
|
417
424
|
/**
|
|
@@ -507,6 +514,26 @@ declare namespace Theme {
|
|
|
507
514
|
*/
|
|
508
515
|
expand?: boolean;
|
|
509
516
|
}
|
|
517
|
+
interface ReplaceRule {
|
|
518
|
+
/**
|
|
519
|
+
* 匹配规则
|
|
520
|
+
*/
|
|
521
|
+
rule: string | RegExp;
|
|
522
|
+
/**
|
|
523
|
+
* 直接追加后缀
|
|
524
|
+
*/
|
|
525
|
+
suffix?: string;
|
|
526
|
+
/**
|
|
527
|
+
* 替换函数或字符串(优先级高于 suffix)
|
|
528
|
+
*/
|
|
529
|
+
replace?: string | ((match: string) => string);
|
|
530
|
+
}
|
|
531
|
+
interface ImageStyleConfig {
|
|
532
|
+
/**
|
|
533
|
+
* 首页封面预览图
|
|
534
|
+
*/
|
|
535
|
+
coverPreview?: ReplaceRule | ReplaceRule[];
|
|
536
|
+
}
|
|
510
537
|
}
|
|
511
538
|
|
|
512
539
|
/**
|
package/node.js
CHANGED
|
@@ -40,7 +40,7 @@ module.exports = __toCommonJS(node_exports);
|
|
|
40
40
|
// src/utils/node/mdPlugins.ts
|
|
41
41
|
var import_module = require("module");
|
|
42
42
|
|
|
43
|
-
// ../../node_modules/.pnpm/vitepress-plugin-tabs@0.2.0_vitepress@1.1.4_@algolia+client-search@4.19.1_@types+node@20.6.
|
|
43
|
+
// ../../node_modules/.pnpm/vitepress-plugin-tabs@0.2.0_vitepress@1.1.4_@algolia+client-search@4.19.1_@types+node@20.6.3__scid7oqqpyg2qxcz73ypk7jzz4/node_modules/vitepress-plugin-tabs/dist/index.js
|
|
44
44
|
var tabsMarker = "=tabs";
|
|
45
45
|
var tabsMarkerLen = tabsMarker.length;
|
|
46
46
|
var ruleBlockTabs = (state, startLine, endLine, silent) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sugarat/theme",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "简约风的 Vitepress 博客主题,sugarat vitepress blog theme",
|
|
5
5
|
"author": "sugar",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,35 +32,38 @@
|
|
|
32
32
|
"src",
|
|
33
33
|
"types"
|
|
34
34
|
],
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@element-plus/icons-vue": "^2.3.1",
|
|
37
|
+
"element-plus": "^2.7"
|
|
38
|
+
},
|
|
35
39
|
"dependencies": {
|
|
36
|
-
"@giscus/vue": "^2.
|
|
37
|
-
"@mdit-vue/shared": "^0.12.
|
|
40
|
+
"@giscus/vue": "^2.4.0",
|
|
41
|
+
"@mdit-vue/shared": "^0.12.1",
|
|
38
42
|
"@mermaid-js/mermaid-mindmap": "^9.3.0",
|
|
39
|
-
"@vue/shared": "^3.
|
|
40
|
-
"@vueuse/core": "^9.
|
|
41
|
-
"fast-glob": "^3.2
|
|
43
|
+
"@vue/shared": "^3.4.26",
|
|
44
|
+
"@vueuse/core": "^9.13.0",
|
|
45
|
+
"fast-glob": "^3.3.2",
|
|
42
46
|
"gray-matter": "^4.0.3",
|
|
43
47
|
"markdown-it-task-checkbox": "^1.0.6",
|
|
44
|
-
"mermaid": "^10.
|
|
45
|
-
"oh-my-live2d": "^0.
|
|
46
|
-
"swiper": "^11.
|
|
48
|
+
"mermaid": "^10.9.0",
|
|
49
|
+
"oh-my-live2d": "^0.17.0",
|
|
50
|
+
"swiper": "^11.1.1",
|
|
47
51
|
"vitepress-markdown-timeline": "^1.2.1",
|
|
48
52
|
"vitepress-plugin-mermaid": "2.0.13",
|
|
53
|
+
"vitepress-plugin-tabs": "0.2.0",
|
|
49
54
|
"vitepress-plugin-pagefind": "0.2.14",
|
|
50
|
-
"vitepress-plugin-rss": "0.2.
|
|
51
|
-
"vitepress-plugin-tabs": "0.2.0"
|
|
55
|
+
"vitepress-plugin-rss": "0.2.3"
|
|
52
56
|
},
|
|
53
57
|
"devDependencies": {
|
|
54
|
-
"@element-plus/icons-vue": "^2.1
|
|
55
|
-
"artalk": "^2.8.
|
|
56
|
-
"element-plus": "^2.
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"vite": "^5",
|
|
58
|
+
"@element-plus/icons-vue": "^2.3.1",
|
|
59
|
+
"artalk": "^2.8.5",
|
|
60
|
+
"element-plus": "^2.7.2",
|
|
61
|
+
"pagefind": "1.1.0",
|
|
62
|
+
"sass": "^1.76.0",
|
|
63
|
+
"typescript": "^5.4.5",
|
|
64
|
+
"vite": "^5.2.11",
|
|
62
65
|
"vitepress": "1.1.4",
|
|
63
|
-
"vue": "^3.4.
|
|
66
|
+
"vue": "^3.4.26"
|
|
64
67
|
},
|
|
65
68
|
"scripts": {
|
|
66
69
|
"dev": "npm run build:node && npm run dev:docs",
|
|
@@ -102,7 +102,7 @@ watch(
|
|
|
102
102
|
fill="#D3D3D3" p-id="4294"
|
|
103
103
|
/>
|
|
104
104
|
</svg> 标签</span>
|
|
105
|
-
<ElTag v-if="activeTag.label" :type="activeTag.type
|
|
105
|
+
<ElTag v-if="activeTag.label" :type="activeTag.type || 'primary'" :effect="colorMode" closable @close="handleCloseTag">
|
|
106
106
|
{{ activeTag.label }}
|
|
107
107
|
</ElTag>
|
|
108
108
|
</div>
|
|
@@ -110,7 +110,7 @@ watch(
|
|
|
110
110
|
<ul class="tag-list">
|
|
111
111
|
<li v-for="(tag, idx) in tags" :key="tag">
|
|
112
112
|
<ElTag
|
|
113
|
-
:type="tagType[idx % tagType.length]" :effect="colorMode"
|
|
113
|
+
:type="tagType[idx % tagType.length] || 'primary'" :effect="colorMode"
|
|
114
114
|
@click="handleTagClick(tag, tagType[idx % tagType.length])"
|
|
115
115
|
>
|
|
116
116
|
{{ tag }}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { useRouter, withBase } from 'vitepress'
|
|
3
3
|
import { computed } from 'vue'
|
|
4
4
|
import { formatShowDate, wrapperCleanUrls } from '../utils/client'
|
|
5
|
-
import { useCleanUrls } from '../composables/config/blog'
|
|
5
|
+
import { useCleanUrls, useImageStyle } from '../composables/config/blog'
|
|
6
6
|
|
|
7
7
|
const props = defineProps<{
|
|
8
8
|
route: string
|
|
@@ -13,7 +13,7 @@ const props = defineProps<{
|
|
|
13
13
|
descriptionHTML?: string
|
|
14
14
|
tag?: string[]
|
|
15
15
|
author?: string
|
|
16
|
-
cover?: string |
|
|
16
|
+
cover?: string | false
|
|
17
17
|
pin?: number
|
|
18
18
|
}>()
|
|
19
19
|
const showTime = computed(() => {
|
|
@@ -26,6 +26,40 @@ const router = useRouter()
|
|
|
26
26
|
function handleSkipDoc() {
|
|
27
27
|
router.go(link.value)
|
|
28
28
|
}
|
|
29
|
+
|
|
30
|
+
const { coverPreview } = useImageStyle()
|
|
31
|
+
|
|
32
|
+
const resultCover = computed(() => {
|
|
33
|
+
if (!props.cover) {
|
|
34
|
+
return ''
|
|
35
|
+
}
|
|
36
|
+
const baseCover = withBase(props.cover)
|
|
37
|
+
const coverRule = [coverPreview]
|
|
38
|
+
.flat()
|
|
39
|
+
.filter(v => !!v)
|
|
40
|
+
.find((coverRule) => {
|
|
41
|
+
if (!coverRule) {
|
|
42
|
+
return false
|
|
43
|
+
}
|
|
44
|
+
return coverRule.rule instanceof RegExp ? coverRule.rule.test(baseCover) : baseCover.includes(coverRule.rule)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
if (!coverRule) {
|
|
48
|
+
return baseCover
|
|
49
|
+
}
|
|
50
|
+
const { suffix, replace, rule } = coverRule
|
|
51
|
+
if (!replace && suffix) {
|
|
52
|
+
return `${baseCover}${suffix}`
|
|
53
|
+
}
|
|
54
|
+
if (typeof replace === 'function') {
|
|
55
|
+
return replace(baseCover)
|
|
56
|
+
}
|
|
57
|
+
if (typeof replace === 'string') {
|
|
58
|
+
return baseCover.replace(rule, replace)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return baseCover
|
|
62
|
+
})
|
|
29
63
|
</script>
|
|
30
64
|
|
|
31
65
|
<template>
|
|
@@ -62,7 +96,7 @@ function handleSkipDoc() {
|
|
|
62
96
|
</div>
|
|
63
97
|
</div>
|
|
64
98
|
<!-- 右侧封面图 -->
|
|
65
|
-
<div v-show="cover" class="cover-img" :style="`background-image: url(${
|
|
99
|
+
<div v-show="cover" class="cover-img" :style="`background-image: url(${resultCover});`" />
|
|
66
100
|
</div>
|
|
67
101
|
<!-- 底部补充描述 -->
|
|
68
102
|
<div class="badge-list mobile-visible">
|
|
@@ -97,7 +97,10 @@ export namespace Theme {
|
|
|
97
97
|
}
|
|
98
98
|
export interface activeTag {
|
|
99
99
|
label: string
|
|
100
|
-
|
|
100
|
+
/**
|
|
101
|
+
* @type {string}
|
|
102
|
+
*/
|
|
103
|
+
type: any
|
|
101
104
|
}
|
|
102
105
|
|
|
103
106
|
export type CommentConfig = ((GiscusOption & CommentCommonConfig) | GiscusConfig | ArtalkConfig)
|
|
@@ -446,6 +449,10 @@ export namespace Theme {
|
|
|
446
449
|
* @default true
|
|
447
450
|
*/
|
|
448
451
|
darkTransition?: boolean
|
|
452
|
+
/**
|
|
453
|
+
* 渲染时替换图片地址
|
|
454
|
+
*/
|
|
455
|
+
imageStyle?: ImageStyleConfig
|
|
449
456
|
}
|
|
450
457
|
|
|
451
458
|
export interface BackToTop {
|
|
@@ -547,4 +554,25 @@ export namespace Theme {
|
|
|
547
554
|
*/
|
|
548
555
|
expand?: boolean
|
|
549
556
|
}
|
|
557
|
+
|
|
558
|
+
export interface ReplaceRule {
|
|
559
|
+
/**
|
|
560
|
+
* 匹配规则
|
|
561
|
+
*/
|
|
562
|
+
rule: string | RegExp
|
|
563
|
+
/**
|
|
564
|
+
* 直接追加后缀
|
|
565
|
+
*/
|
|
566
|
+
suffix?: string
|
|
567
|
+
/**
|
|
568
|
+
* 替换函数或字符串(优先级高于 suffix)
|
|
569
|
+
*/
|
|
570
|
+
replace?: string | ((match: string) => string)
|
|
571
|
+
}
|
|
572
|
+
export interface ImageStyleConfig {
|
|
573
|
+
/**
|
|
574
|
+
* 首页封面预览图
|
|
575
|
+
*/
|
|
576
|
+
coverPreview?: ReplaceRule | ReplaceRule[]
|
|
577
|
+
}
|
|
550
578
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,18 @@
|
|
|
2
2
|
import './styles/index.scss'
|
|
3
3
|
|
|
4
4
|
// element-ui
|
|
5
|
-
import 'element-plus/dist/index.css'
|
|
5
|
+
// import 'element-plus/dist/index.css'
|
|
6
|
+
import 'element-plus/theme-chalk/base.css'
|
|
7
|
+
import 'element-plus/theme-chalk/el-button.css'
|
|
8
|
+
import 'element-plus/theme-chalk/el-tag.css'
|
|
9
|
+
import 'element-plus/theme-chalk/el-icon.css'
|
|
10
|
+
import 'element-plus/theme-chalk/el-avatar.css'
|
|
11
|
+
import 'element-plus/theme-chalk/el-image.css'
|
|
12
|
+
import 'element-plus/theme-chalk/el-image-viewer.css'
|
|
13
|
+
import 'element-plus/theme-chalk/el-pagination.css'
|
|
14
|
+
import 'element-plus/theme-chalk/el-carousel.css'
|
|
15
|
+
import 'element-plus/theme-chalk/el-carousel-item.css'
|
|
16
|
+
import 'element-plus/theme-chalk/el-alert.css'
|
|
6
17
|
import 'element-plus/theme-chalk/dark/css-vars.css'
|
|
7
18
|
|
|
8
19
|
// 引入时间线组件样式
|
|
@@ -12,6 +23,7 @@ import DefaultTheme from 'vitepress/theme'
|
|
|
12
23
|
import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client'
|
|
13
24
|
|
|
14
25
|
// 图表渲染组件
|
|
26
|
+
// @ts-expect-error
|
|
15
27
|
import Mermaid from 'vitepress-plugin-mermaid/Mermaid.vue'
|
|
16
28
|
import BlogApp from './components/BlogApp.vue'
|
|
17
29
|
import { withConfigProvider } from './composables/config/blog'
|