@sugarat/theme 0.1.46 → 0.1.48
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.js +11 -43
- package/package.json +5 -3
- package/src/components/BlogApp.vue +3 -3
- package/src/components/BlogFriendLink.vue +17 -3
- package/src/components/BlogHomeOverview.vue +1 -1
- package/src/components/BlogHomeTags.vue +23 -15
- package/src/components/BlogHotArticle.vue +8 -17
- package/src/components/BlogImagePreview.vue +7 -9
- package/src/components/BlogPopover.vue +2 -2
- package/src/components/BlogRecommendArticle.vue +15 -26
- package/src/constants/svg.ts +45 -0
- package/src/styles/index.scss +10 -0
- package/src/utils/node/vitePlugins.ts +15 -5
package/node.js
CHANGED
|
@@ -32,7 +32,7 @@ __export(node_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(node_exports);
|
|
34
34
|
|
|
35
|
-
// ../../node_modules/.pnpm/vitepress-plugin-tabs@0.2.0_vitepress@1.0.0-rc.
|
|
35
|
+
// ../../node_modules/.pnpm/vitepress-plugin-tabs@0.2.0_vitepress@1.0.0-rc.14_vue@3.3.4/node_modules/vitepress-plugin-tabs/dist/index.js
|
|
36
36
|
var tabsMarker = "=tabs";
|
|
37
37
|
var tabsMarkerLen = tabsMarker.length;
|
|
38
38
|
var ruleBlockTabs = (state, startLine, endLine, silent) => {
|
|
@@ -277,11 +277,11 @@ function aliasObjectToArray(obj) {
|
|
|
277
277
|
}));
|
|
278
278
|
}
|
|
279
279
|
var EXTERNAL_URL_RE = /^[a-z]+:/i;
|
|
280
|
-
function joinPath(base,
|
|
281
|
-
return `${base}${
|
|
280
|
+
function joinPath(base, path3) {
|
|
281
|
+
return `${base}${path3}`.replace(/\/+/g, "/");
|
|
282
282
|
}
|
|
283
|
-
function withBase(base,
|
|
284
|
-
return EXTERNAL_URL_RE.test(
|
|
283
|
+
function withBase(base, path3) {
|
|
284
|
+
return EXTERNAL_URL_RE.test(path3) || path3.startsWith(".") ? path3 : joinPath(base, path3);
|
|
285
285
|
}
|
|
286
286
|
|
|
287
287
|
// src/utils/node/mdPlugins.ts
|
|
@@ -450,8 +450,7 @@ function patchVPThemeConfig(cfg, vpThemeConfig = {}) {
|
|
|
450
450
|
}
|
|
451
451
|
|
|
452
452
|
// src/utils/node/vitePlugins.ts
|
|
453
|
-
var
|
|
454
|
-
var import_child_process2 = require("child_process");
|
|
453
|
+
var import_vitepress_plugin_pagefind = require("vitepress-plugin-pagefind");
|
|
455
454
|
|
|
456
455
|
// src/utils/node/genFeed.ts
|
|
457
456
|
var import_path2 = __toESM(require("path"));
|
|
@@ -532,8 +531,11 @@ function getVitePlugins(cfg) {
|
|
|
532
531
|
const plugins = [];
|
|
533
532
|
const buildEndFn = [];
|
|
534
533
|
plugins.push(inlineBuildEndPlugin(buildEndFn));
|
|
535
|
-
if (cfg
|
|
536
|
-
|
|
534
|
+
if (cfg && cfg.search !== false) {
|
|
535
|
+
const ops = cfg.search instanceof Object ? cfg.search : {};
|
|
536
|
+
plugins.push(
|
|
537
|
+
(0, import_vitepress_plugin_pagefind.pagefindPlugin)({ ...ops, customSearchQuery: import_vitepress_plugin_pagefind.chineseSearchOptimize })
|
|
538
|
+
);
|
|
537
539
|
}
|
|
538
540
|
buildEndFn.push(genFeed);
|
|
539
541
|
return plugins;
|
|
@@ -543,40 +545,6 @@ function registerVitePlugins(vpCfg, plugins) {
|
|
|
543
545
|
plugins
|
|
544
546
|
};
|
|
545
547
|
}
|
|
546
|
-
function inlinePagefindPlugin(buildEndFn) {
|
|
547
|
-
buildEndFn.push(() => {
|
|
548
|
-
const ignore = [
|
|
549
|
-
"div.aside",
|
|
550
|
-
"a.header-anchor"
|
|
551
|
-
];
|
|
552
|
-
const { log } = console;
|
|
553
|
-
log();
|
|
554
|
-
log("=== pagefind: https://pagefind.app/ ===");
|
|
555
|
-
const siteDir = import_path3.default.join(
|
|
556
|
-
process.argv.slice(2)?.[1] || ".",
|
|
557
|
-
".vitepress/dist"
|
|
558
|
-
);
|
|
559
|
-
let command = `npx pagefind --site ${siteDir} --output-subdir "_pagefind"`;
|
|
560
|
-
if (ignore.length) {
|
|
561
|
-
command += ` --exclude-selectors "${ignore.join(", ")}"`;
|
|
562
|
-
}
|
|
563
|
-
log(command);
|
|
564
|
-
log();
|
|
565
|
-
(0, import_child_process2.execSync)(command, {
|
|
566
|
-
stdio: "inherit"
|
|
567
|
-
});
|
|
568
|
-
});
|
|
569
|
-
return {
|
|
570
|
-
name: "@sugarar/theme-plugin-pagefind",
|
|
571
|
-
enforce: "pre",
|
|
572
|
-
transform(code, id) {
|
|
573
|
-
if (id.endsWith("theme-default/Layout.vue")) {
|
|
574
|
-
return code.replace("<VPContent>", "<VPContent data-pagefind-body>");
|
|
575
|
-
}
|
|
576
|
-
return code;
|
|
577
|
-
}
|
|
578
|
-
};
|
|
579
|
-
}
|
|
580
548
|
function inlineBuildEndPlugin(buildEndFn) {
|
|
581
549
|
let rewrite = false;
|
|
582
550
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sugarat/theme",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.48",
|
|
4
4
|
"description": "简约风的 Vitepress 博客主题,sugarat vitepress blog theme",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"highlight.js": "^11.7.0",
|
|
44
44
|
"mermaid": "^10.2.4",
|
|
45
45
|
"vitepress-plugin-mermaid": "^2.0.13",
|
|
46
|
+
"vitepress-plugin-pagefind": "0.2.9",
|
|
46
47
|
"vue-command-palette": "^0.1.4"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
@@ -51,9 +52,10 @@
|
|
|
51
52
|
"sass": "^1.56.1",
|
|
52
53
|
"tsup": " ^6.5.0",
|
|
53
54
|
"typescript": "^4.8.2",
|
|
54
|
-
"vitepress": "1.0.0-rc.
|
|
55
|
+
"vitepress": "1.0.0-rc.14",
|
|
55
56
|
"vitepress-plugin-tabs": "^0.2.0",
|
|
56
|
-
"vue": "^3.3.4"
|
|
57
|
+
"vue": "^3.3.4",
|
|
58
|
+
"pagefind": "1.0.3"
|
|
57
59
|
},
|
|
58
60
|
"scripts": {
|
|
59
61
|
"dev": "npm run build:node && npm run dev:docs",
|
|
@@ -4,7 +4,7 @@ import BlogHomeInfo from './BlogHomeInfo.vue'
|
|
|
4
4
|
import BlogHomeBanner from './BlogHomeBanner.vue'
|
|
5
5
|
import BlogList from './BlogList.vue'
|
|
6
6
|
import BlogComment from './BlogComment.vue'
|
|
7
|
-
import BlogSearch from './BlogSearch.vue'
|
|
7
|
+
// import BlogSearch from './BlogSearch.vue'
|
|
8
8
|
import BlogSidebar from './BlogSidebar.vue'
|
|
9
9
|
import BlogImagePreview from './BlogImagePreview.vue'
|
|
10
10
|
import BlogArticleAnalyze from './BlogArticleAnalyze.vue'
|
|
@@ -34,10 +34,10 @@ const { Layout } = Theme
|
|
|
34
34
|
</template>
|
|
35
35
|
|
|
36
36
|
<!-- 自定义搜索,替代Algolia,未来择机移除 -->
|
|
37
|
-
<template #nav-bar-content-before>
|
|
37
|
+
<!-- <template #nav-bar-content-before>
|
|
38
38
|
<slot name="nav-bar-content-before" />
|
|
39
39
|
<BlogSearch />
|
|
40
|
-
</template>
|
|
40
|
+
</template> -->
|
|
41
41
|
<!-- 自定义首页 -->
|
|
42
42
|
<template #home-hero-before v-if="isBlogTheme">
|
|
43
43
|
<slot name="home-hero-before" />
|
|
@@ -2,7 +2,16 @@
|
|
|
2
2
|
<div class="card friend-wrapper" v-if="friendList?.length">
|
|
3
3
|
<!-- 头部 -->
|
|
4
4
|
<div class="card-header">
|
|
5
|
-
<span class="title"
|
|
5
|
+
<span class="title svg-icon"><svg width="512" height="512" viewBox="0 0 36 36" xmlns="http://www.w3.org/2000/svg">
|
|
6
|
+
<path fill="#EF9645"
|
|
7
|
+
d="M16.428 30.331a2.31 2.31 0 0 0 3.217-.568a.798.798 0 0 0-.197-1.114l-1.85-1.949l4.222 2.955a1.497 1.497 0 0 0 2.089-.369a1.5 1.5 0 0 0-.369-2.089l-3.596-3.305l5.375 3.763a1.497 1.497 0 0 0 2.089-.369a1.5 1.5 0 0 0-.369-2.089l-4.766-4.073l5.864 4.105a1.497 1.497 0 0 0 2.089-.369a1.5 1.5 0 0 0-.369-2.089L4.733 11.194l-3.467 5.521c-.389.6-.283 1.413.276 1.891l7.786 6.671c.355.304.724.591 1.107.859l5.993 4.195z" />
|
|
8
|
+
<path fill="#FFDC5D"
|
|
9
|
+
d="M29.802 21.752L18.5 13.601l-.059-.08l.053-.08l.053-.053l.854.469c.958.62 3.147 1.536 4.806 1.536c1.135 0 1.815-.425 2.018-1.257a1.409 1.409 0 0 0-1.152-1.622a6.788 6.788 0 0 1-2.801-1.091l-.555-.373c-.624-.421-1.331-.898-1.853-1.206c-.65-.394-1.357-.585-2.163-.585c-1.196 0-2.411.422-3.585.83l-1.266.436a5.18 5.18 0 0 1-1.696.271c-1.544 0-3.055-.586-4.516-1.152l-.147-.058a1.389 1.389 0 0 0-1.674.56L1.35 15.669a1.357 1.357 0 0 0 .257 1.761l7.785 6.672c.352.301.722.588 1.1.852l6.165 4.316a2 2 0 0 0 2.786-.491a.803.803 0 0 0-.196-1.115l-1.833-1.283a.424.424 0 0 1-.082-.618a.422.422 0 0 1 .567-.075l3.979 2.785a1.4 1.4 0 0 0 1.606-2.294l-3.724-2.606a.424.424 0 0 1-.082-.618a.423.423 0 0 1 .567-.075l5.132 3.593a1.4 1.4 0 0 0 1.606-2.294l-4.868-3.407a.42.42 0 0 1-.081-.618a.377.377 0 0 1 .506-.066l5.656 3.959a1.4 1.4 0 0 0 1.606-2.295z" />
|
|
10
|
+
<path fill="#EF9645"
|
|
11
|
+
d="M16.536 27.929c-.07.267-.207.498-.389.681l-1.004.996a1.494 1.494 0 0 1-1.437.396a1.5 1.5 0 0 1-.683-2.512l1.004-.996a1.494 1.494 0 0 1 1.437-.396a1.502 1.502 0 0 1 1.072 1.831zM5.992 23.008l1.503-1.497a1.5 1.5 0 0 0-.444-2.429a1.495 1.495 0 0 0-1.674.31l-1.503 1.497a1.5 1.5 0 0 0 .445 2.429a1.496 1.496 0 0 0 1.673-.31zm5.204.052a1.5 1.5 0 1 0-2.122-2.118L6.072 23.94a1.5 1.5 0 1 0 2.122 2.118l3.002-2.998zm2.25 3a1.5 1.5 0 0 0-.945-2.555a1.489 1.489 0 0 0-1.173.44L9.323 25.94a1.5 1.5 0 0 0 .945 2.556c.455.036.874-.141 1.173-.44l2.005-1.996zm16.555-4.137l.627-.542l-6.913-10.85l-12.27 1.985a1.507 1.507 0 0 0-1.235 1.737c.658 2.695 6.003.693 8.355-.601l11.436 8.271z" />
|
|
12
|
+
<path fill="#FFCC4D"
|
|
13
|
+
d="M16.536 26.929c-.07.267-.207.498-.389.681l-1.004.996a1.494 1.494 0 0 1-1.437.396a1.5 1.5 0 0 1-.683-2.512l1.004-.996a1.494 1.494 0 0 1 1.437-.396a1.502 1.502 0 0 1 1.072 1.831zM5.992 22.008l1.503-1.497a1.5 1.5 0 0 0-.444-2.429a1.497 1.497 0 0 0-1.674.31l-1.503 1.497a1.5 1.5 0 0 0 .445 2.429a1.496 1.496 0 0 0 1.673-.31zm5.204.052a1.5 1.5 0 1 0-2.122-2.118L6.072 22.94a1.5 1.5 0 1 0 2.122 2.118l3.002-2.998zm2.25 3a1.5 1.5 0 0 0-.945-2.555a1.489 1.489 0 0 0-1.173.44L9.323 24.94a1.5 1.5 0 0 0 .945 2.556c.455.036.874-.141 1.173-.44l2.005-1.996zm21.557-7.456a1.45 1.45 0 0 0 .269-1.885l-.003-.005l-3.467-6.521a1.488 1.488 0 0 0-1.794-.6c-1.992.771-4.174 1.657-6.292.937l-1.098-.377c-1.948-.675-4.066-1.466-6-.294c-.695.409-1.738 1.133-2.411 1.58a6.873 6.873 0 0 1-2.762 1.076a1.502 1.502 0 0 0-1.235 1.737c.613 2.512 5.3.908 7.838-.369a.968.968 0 0 1 1.002.081l11.584 8.416l4.369-3.776z" />
|
|
14
|
+
</svg> 友情链接</span>
|
|
6
15
|
</div>
|
|
7
16
|
<!-- 文章列表 -->
|
|
8
17
|
<ol class="friend-list">
|
|
@@ -76,6 +85,8 @@ const friendList = computed(() => {
|
|
|
76
85
|
|
|
77
86
|
.title {
|
|
78
87
|
font-size: 12px;
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
79
90
|
}
|
|
80
91
|
}
|
|
81
92
|
|
|
@@ -94,15 +105,19 @@ const friendList = computed(() => {
|
|
|
94
105
|
li {
|
|
95
106
|
padding: 6px;
|
|
96
107
|
margin-top: 10px;
|
|
108
|
+
|
|
97
109
|
.el-avatar {
|
|
98
110
|
min-width: 50px;
|
|
99
111
|
}
|
|
112
|
+
|
|
100
113
|
a {
|
|
101
114
|
display: flex;
|
|
102
115
|
}
|
|
116
|
+
|
|
103
117
|
div {
|
|
104
118
|
padding-left: 10px;
|
|
105
119
|
}
|
|
120
|
+
|
|
106
121
|
.nickname {
|
|
107
122
|
font-size: 16px;
|
|
108
123
|
font-weight: 450;
|
|
@@ -113,5 +128,4 @@ const friendList = computed(() => {
|
|
|
113
128
|
font-size: 14px;
|
|
114
129
|
}
|
|
115
130
|
}
|
|
116
|
-
}
|
|
117
|
-
</style>
|
|
131
|
+
}</style>
|
|
@@ -24,7 +24,7 @@ import { useArticles } from '../composables/config/blog'
|
|
|
24
24
|
|
|
25
25
|
const docs = useArticles()
|
|
26
26
|
const notHiddenArticles = computed(() => {
|
|
27
|
-
return docs.value.filter((v) =>
|
|
27
|
+
return docs.value.filter((v) => v.meta?.publish !== false)
|
|
28
28
|
})
|
|
29
29
|
const nowMonth = new Date().getMonth()
|
|
30
30
|
const nowYear = new Date().getFullYear()
|
|
@@ -2,25 +2,30 @@
|
|
|
2
2
|
<div class="card tags" v-if="tags.length" data-pagefind-ignore="all">
|
|
3
3
|
<!-- 头部 -->
|
|
4
4
|
<div class="card-header">
|
|
5
|
-
<span class="title"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
<span class="title svg-icon"><svg t="1695048840129" class="icon" viewBox="0 0 1024 1024" version="1.1"
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg" p-id="4290" width="200" height="200">
|
|
7
|
+
<path
|
|
8
|
+
d="M810.88 245.888a118.432 118.432 0 1 0 0 236.864 118.432 118.432 0 0 0 0-236.864z m-151.008 118.432a151.008 151.008 0 1 1 302.016 0 151.008 151.008 0 0 1-302.016 0z"
|
|
9
|
+
fill="#D3D3D3" p-id="4291"></path>
|
|
10
|
+
<path
|
|
11
|
+
d="M774.08 565.6l61.76-160.64c6.4-16.64 2.56-35.84-10.24-48.64l-151.04-151.04c-12.8-12.8-31.68-16.64-48.64-10.24l-160.64 61.76c-12.16 4.8-23.36 11.84-32.64 21.12l-355.2 355.2c-17.92 17.92-17.92 46.72 0 64.32l256 256c17.92 17.92 46.72 17.92 64.32 0l355.2-355.2c9.28-9.28 16.32-20.16 21.12-32.64z m-159.36-149.12c-22.08-22.08-22.08-57.6 0-79.68 22.08-22.08 57.6-22.08 79.68 0 22.08 22.08 22.08 57.6 0 79.68-22.08 21.76-57.92 21.76-79.68 0z"
|
|
12
|
+
fill="#FCD53F" p-id="4292"></path>
|
|
13
|
+
<path
|
|
14
|
+
d="M654.4 320.48c14.4 0 28.8 5.44 39.68 16.64 22.08 22.08 22.08 57.6 0 79.68-10.88 10.88-25.28 16.64-39.68 16.64-14.4 0-28.8-5.44-39.68-16.64-22.08-22.08-22.08-57.6 0-79.68 10.88-11.2 25.28-16.64 39.68-16.64z m0-30.08c-23.04 0-44.8 8.96-61.12 25.28a86.72 86.72 0 0 0 0 122.24c16.32 16.32 38.08 25.28 61.12 25.28s44.8-8.96 61.12-25.28a86.72 86.72 0 0 0 0-122.24c-16.32-16.32-38.08-25.28-61.12-25.28z"
|
|
15
|
+
fill="#F8312F" p-id="4293"></path>
|
|
16
|
+
<path
|
|
17
|
+
d="M676.16 348.032c8.992 0 16.288 7.296 16.288 16.288a118.144 118.144 0 0 0 64.288 105.44h0.064c22.24 11.296 47.36 15.264 71.68 11.84a16.288 16.288 0 0 1 4.48 32.32 154.24 154.24 0 0 1-90.848-15.04 150.72 150.72 0 0 1-82.24-134.56c0-8.992 7.296-16.288 16.288-16.288z"
|
|
18
|
+
fill="#D3D3D3" p-id="4294"></path>
|
|
19
|
+
</svg> 标签</span>
|
|
20
|
+
<el-tag v-if="activeTag.label" :type="(activeTag.type as any)" :effect="colorMode" closable @close="handleCloseTag">
|
|
13
21
|
{{ activeTag.label }}
|
|
14
22
|
</el-tag>
|
|
15
23
|
</div>
|
|
16
24
|
<!-- 标签列表 -->
|
|
17
25
|
<ul class="tag-list">
|
|
18
26
|
<li v-for="(tag, idx) in tags" :key="tag">
|
|
19
|
-
<el-tag
|
|
20
|
-
:
|
|
21
|
-
@click="handleTagClick(tag, tagType[idx % tagType.length])"
|
|
22
|
-
:effect="colorMode"
|
|
23
|
-
>
|
|
27
|
+
<el-tag :type="tagType[idx % tagType.length]" @click="handleTagClick(tag, tagType[idx % tagType.length])"
|
|
28
|
+
:effect="colorMode">
|
|
24
29
|
{{ tag }}
|
|
25
30
|
</el-tag>
|
|
26
31
|
</li>
|
|
@@ -112,6 +117,7 @@ watch(
|
|
|
112
117
|
box-shadow: var(--box-shadow-hover);
|
|
113
118
|
}
|
|
114
119
|
}
|
|
120
|
+
|
|
115
121
|
.card-header {
|
|
116
122
|
display: flex;
|
|
117
123
|
width: 100%;
|
|
@@ -120,6 +126,8 @@ watch(
|
|
|
120
126
|
|
|
121
127
|
.title {
|
|
122
128
|
font-size: 12px;
|
|
129
|
+
display: flex;
|
|
130
|
+
align-items: center;
|
|
123
131
|
}
|
|
124
132
|
}
|
|
125
133
|
|
|
@@ -131,10 +139,10 @@ watch(
|
|
|
131
139
|
display: flex;
|
|
132
140
|
flex-wrap: wrap;
|
|
133
141
|
margin-top: 10px;
|
|
142
|
+
|
|
134
143
|
li {
|
|
135
144
|
margin-right: 10px;
|
|
136
145
|
margin-bottom: 10px;
|
|
137
146
|
cursor: pointer;
|
|
138
147
|
}
|
|
139
|
-
}
|
|
140
|
-
</style>
|
|
148
|
+
}</style>
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
class="card recommend"
|
|
4
|
-
v-if="recommendList.length || empty"
|
|
5
|
-
data-pagefind-ignore="all"
|
|
6
|
-
>
|
|
2
|
+
<div class="card recommend" v-if="recommendList.length || empty" data-pagefind-ignore="all">
|
|
7
3
|
<!-- 头部 -->
|
|
8
4
|
<div class="card-header">
|
|
9
|
-
<span class="title"
|
|
10
|
-
<el-button
|
|
11
|
-
v-if="showChangeBtn"
|
|
12
|
-
size="small"
|
|
13
|
-
type="primary"
|
|
14
|
-
text
|
|
15
|
-
@click="changePage"
|
|
16
|
-
>{{ nextText }}</el-button
|
|
17
|
-
>
|
|
5
|
+
<span class="title" v-html="title"></span>
|
|
6
|
+
<el-button v-if="showChangeBtn" size="small" type="primary" text @click="changePage">{{ nextText }}</el-button>
|
|
18
7
|
</div>
|
|
19
8
|
<!-- 文章列表 -->
|
|
20
9
|
<ol class="recommend-container" v-if="currentWikiData.length">
|
|
@@ -45,9 +34,9 @@ import { ElButton, ElLink } from 'element-plus'
|
|
|
45
34
|
import { withBase } from 'vitepress'
|
|
46
35
|
import { useArticles, useBlogConfig } from '../composables/config/blog'
|
|
47
36
|
import { formatShowDate } from '../utils/client'
|
|
48
|
-
|
|
37
|
+
import { fireSVG } from '../constants/svg'
|
|
49
38
|
const { hotArticle } = useBlogConfig()
|
|
50
|
-
const title = computed(() => hotArticle?.title || '
|
|
39
|
+
const title = computed(() => hotArticle?.title || (`<span class="svg-icon">${fireSVG}</span>` + ' 精选文章'))
|
|
51
40
|
const nextText = computed(() => hotArticle?.nextText || '换一组')
|
|
52
41
|
const pageSize = computed(() => hotArticle?.pageSize || 9)
|
|
53
42
|
const empty = computed(() => hotArticle?.empty ?? '暂无精选内容')
|
|
@@ -105,6 +94,8 @@ const showChangeBtn = computed(() => {
|
|
|
105
94
|
|
|
106
95
|
.title {
|
|
107
96
|
font-size: 12px;
|
|
97
|
+
display: flex;
|
|
98
|
+
align-items: center;
|
|
108
99
|
}
|
|
109
100
|
}
|
|
110
101
|
|
|
@@ -179,4 +170,4 @@ const showChangeBtn = computed(() => {
|
|
|
179
170
|
font-size: 14px;
|
|
180
171
|
text-align: center;
|
|
181
172
|
}
|
|
182
|
-
</style>
|
|
173
|
+
</style>
|
|
@@ -25,6 +25,11 @@ const previewImage = (e: Event) => {
|
|
|
25
25
|
previewImageInfo.list = urls
|
|
26
26
|
previewImageInfo.idx = idx
|
|
27
27
|
|
|
28
|
+
// 兼容点击main之外的图片
|
|
29
|
+
if (idx === -1 && url) {
|
|
30
|
+
previewImageInfo.list.push(url)
|
|
31
|
+
previewImageInfo.idx = previewImageInfo.list.length - 1
|
|
32
|
+
}
|
|
28
33
|
show.value = true
|
|
29
34
|
}
|
|
30
35
|
}
|
|
@@ -40,13 +45,6 @@ onUnmounted(() => {
|
|
|
40
45
|
</script>
|
|
41
46
|
|
|
42
47
|
<template>
|
|
43
|
-
<ElImageViewer
|
|
44
|
-
:
|
|
45
|
-
hide-on-click-modal
|
|
46
|
-
teleported
|
|
47
|
-
@close="show = false"
|
|
48
|
-
:url-list="previewImageInfo.list"
|
|
49
|
-
:initial-index="previewImageInfo.idx"
|
|
50
|
-
v-if="show"
|
|
51
|
-
/>
|
|
48
|
+
<ElImageViewer :infinite="false" hide-on-click-modal teleported @close="show = false" :url-list="previewImageInfo.list"
|
|
49
|
+
:initial-index="previewImageInfo.idx" v-if="show" />
|
|
52
50
|
</template>
|
|
@@ -136,7 +136,7 @@ const PopoverValue = (
|
|
|
136
136
|
position: fixed;
|
|
137
137
|
top: 80px;
|
|
138
138
|
right: 20px;
|
|
139
|
-
z-index:
|
|
139
|
+
z-index: 22;
|
|
140
140
|
box-sizing: border-box;
|
|
141
141
|
border: 1px solid var(--vp-c-brand-3);
|
|
142
142
|
border-radius: 6px;
|
|
@@ -207,7 +207,7 @@ const PopoverValue = (
|
|
|
207
207
|
cursor: pointer;
|
|
208
208
|
opacity: 0.5;
|
|
209
209
|
position: fixed;
|
|
210
|
-
z-index:
|
|
210
|
+
z-index: 22;
|
|
211
211
|
top: 80px;
|
|
212
212
|
right: 10px;
|
|
213
213
|
position: fixed;
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
|
|
4
|
-
:class="{ card: sidebarStyle === 'card' }"
|
|
5
|
-
v-if="_recommend !== false && (recommendList.length || emptyText)"
|
|
6
|
-
data-pagefind-ignore="all"
|
|
7
|
-
>
|
|
2
|
+
<div class="recommend" :class="{ card: sidebarStyle === 'card' }"
|
|
3
|
+
v-if="_recommend !== false && (recommendList.length || emptyText)" data-pagefind-ignore="all">
|
|
8
4
|
<!-- 头部 -->
|
|
9
5
|
<div class="card-header">
|
|
10
|
-
<span class="title" v-if="title"
|
|
11
|
-
<el-button
|
|
12
|
-
v-if="showChangeBtn"
|
|
13
|
-
size="small"
|
|
14
|
-
type="primary"
|
|
15
|
-
text
|
|
16
|
-
@click="changePage"
|
|
17
|
-
>{{ nextText }}</el-button
|
|
18
|
-
>
|
|
6
|
+
<span class="title" v-if="title" v-html="title"></span>
|
|
7
|
+
<el-button v-if="showChangeBtn" size="small" type="primary" text @click="changePage">{{ nextText }}</el-button>
|
|
19
8
|
</div>
|
|
20
9
|
<!-- 文章列表 -->
|
|
21
10
|
<ol class="recommend-container" v-if="currentWikiData.length">
|
|
@@ -25,15 +14,9 @@
|
|
|
25
14
|
<!-- 简介 -->
|
|
26
15
|
<div class="des">
|
|
27
16
|
<!-- title -->
|
|
28
|
-
<el-link
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
:class="{
|
|
32
|
-
current: isCurrentDoc(v.route)
|
|
33
|
-
}"
|
|
34
|
-
:href="v.route"
|
|
35
|
-
>{{ v.meta.title }}</el-link
|
|
36
|
-
>
|
|
17
|
+
<el-link type="info" class="title" :class="{
|
|
18
|
+
current: isCurrentDoc(v.route)
|
|
19
|
+
}" :href="v.route">{{ v.meta.title }}</el-link>
|
|
37
20
|
<!-- 描述信息 -->
|
|
38
21
|
<div class="suffix">
|
|
39
22
|
<!-- 日期 -->
|
|
@@ -52,6 +35,7 @@ import { useRoute, withBase } from 'vitepress'
|
|
|
52
35
|
import { ElButton, ElLink } from 'element-plus'
|
|
53
36
|
import { formatShowDate } from '../utils/client'
|
|
54
37
|
import { useArticles, useBlogConfig } from '../composables/config/blog'
|
|
38
|
+
import { recommendSVG } from '../constants/svg'
|
|
55
39
|
|
|
56
40
|
const { recommend: _recommend } = useBlogConfig()
|
|
57
41
|
|
|
@@ -65,7 +49,7 @@ const recommendPadding = computed(() =>
|
|
|
65
49
|
const recommend = computed(() =>
|
|
66
50
|
_recommend === false ? undefined : _recommend
|
|
67
51
|
)
|
|
68
|
-
const title = computed(() => recommend.value?.title ?? '
|
|
52
|
+
const title = computed(() => recommend.value?.title ?? (`<span class="svg-icon">${recommendSVG}</span>` + '相关文章'))
|
|
69
53
|
const pageSize = computed(() => recommend.value?.pageSize || 9)
|
|
70
54
|
const nextText = computed(() => recommend.value?.nextText || '换一组')
|
|
71
55
|
const emptyText = computed(() => recommend.value?.empty ?? '暂无相关文章')
|
|
@@ -190,6 +174,7 @@ const showChangeBtn = computed(() => {
|
|
|
190
174
|
color: var(--vp-c-text-1);
|
|
191
175
|
word-break: break-all;
|
|
192
176
|
white-space: break-spaces;
|
|
177
|
+
|
|
193
178
|
&.current {
|
|
194
179
|
color: var(--vp-c-brand-1);
|
|
195
180
|
}
|
|
@@ -208,10 +193,14 @@ const showChangeBtn = computed(() => {
|
|
|
208
193
|
justify-content: space-between;
|
|
209
194
|
align-items: center;
|
|
210
195
|
margin-bottom: 10px;
|
|
196
|
+
|
|
211
197
|
.title {
|
|
212
|
-
font-size:
|
|
198
|
+
font-size: 14px;
|
|
199
|
+
display: flex;
|
|
200
|
+
align-items: center;
|
|
213
201
|
}
|
|
214
202
|
}
|
|
203
|
+
|
|
215
204
|
.empty-text {
|
|
216
205
|
padding: 6px;
|
|
217
206
|
font-size: 14px;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export const fireSVG = `<svg viewBox="0 0 128 128" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<radialGradient id="notoFire0" cx="68.884" cy="124.296" r="70.587" gradientTransform="matrix(-1 -.00434 -.00713 1.6408 131.986 -79.345)" gradientUnits="userSpaceOnUse">
|
|
3
|
+
<stop offset=".314" stop-color="#FF9800"/>
|
|
4
|
+
<stop offset=".662" stop-color="#FF6D00"/>
|
|
5
|
+
<stop offset=".972" stop-color="#F44336"/>
|
|
6
|
+
</radialGradient>
|
|
7
|
+
<path fill="url(#notoFire0)" d="M35.56 40.73c-.57 6.08-.97 16.84 2.62 21.42c0 0-1.69-11.82 13.46-26.65c6.1-5.97 7.51-14.09 5.38-20.18c-1.21-3.45-3.42-6.3-5.34-8.29c-1.12-1.17-.26-3.1 1.37-3.03c9.86.44 25.84 3.18 32.63 20.22c2.98 7.48 3.2 15.21 1.78 23.07c-.9 5.02-4.1 16.18 3.2 17.55c5.21.98 7.73-3.16 8.86-6.14c.47-1.24 2.1-1.55 2.98-.56c8.8 10.01 9.55 21.8 7.73 31.95c-3.52 19.62-23.39 33.9-43.13 33.9c-24.66 0-44.29-14.11-49.38-39.65c-2.05-10.31-1.01-30.71 14.89-45.11c1.18-1.08 3.11-.12 2.95 1.5z"/>
|
|
8
|
+
<radialGradient id="notoFire1" cx="64.921" cy="54.062" r="73.86" gradientTransform="matrix(-.0101 .9999 .7525 .0076 26.154 -11.267)" gradientUnits="userSpaceOnUse">
|
|
9
|
+
<stop offset=".214" stop-color="#FFF176"/>
|
|
10
|
+
<stop offset=".328" stop-color="#FFF27D"/>
|
|
11
|
+
<stop offset=".487" stop-color="#FFF48F"/>
|
|
12
|
+
<stop offset=".672" stop-color="#FFF7AD"/>
|
|
13
|
+
<stop offset=".793" stop-color="#FFF9C4"/>
|
|
14
|
+
<stop offset=".822" stop-color="#FFF8BD" stop-opacity=".804"/>
|
|
15
|
+
<stop offset=".863" stop-color="#FFF6AB" stop-opacity=".529"/>
|
|
16
|
+
<stop offset=".91" stop-color="#FFF38D" stop-opacity=".209"/>
|
|
17
|
+
<stop offset=".941" stop-color="#FFF176" stop-opacity="0"/>
|
|
18
|
+
</radialGradient>
|
|
19
|
+
<path fill="url(#notoFire1)" d="M76.11 77.42c-9.09-11.7-5.02-25.05-2.79-30.37c.3-.7-.5-1.36-1.13-.93c-3.91 2.66-11.92 8.92-15.65 17.73c-5.05 11.91-4.69 17.74-1.7 24.86c1.8 4.29-.29 5.2-1.34 5.36c-1.02.16-1.96-.52-2.71-1.23a16.09 16.09 0 0 1-4.44-7.6c-.16-.62-.97-.79-1.34-.28c-2.8 3.87-4.25 10.08-4.32 14.47C40.47 113 51.68 124 65.24 124c17.09 0 29.54-18.9 19.72-34.7c-2.85-4.6-5.53-7.61-8.85-11.88z"/>
|
|
20
|
+
</svg>`
|
|
21
|
+
|
|
22
|
+
export const recommendSVG =`<svg width="512" height="512" viewBox="0 0 128 128" xmlns="http://www.w3.org/2000/svg">
|
|
23
|
+
<radialGradient id="notoFaceWithMonocle0" cx="63.6" cy="-2088.9" r="56.96" gradientTransform="matrix(1 0 0 -1 0 -2026)" gradientUnits="userSpaceOnUse">
|
|
24
|
+
<stop offset=".5" stop-color="#FDE030"/>
|
|
25
|
+
<stop offset=".919" stop-color="#F7C02B"/>
|
|
26
|
+
<stop offset="1" stop-color="#F4A223"/>
|
|
27
|
+
</radialGradient>
|
|
28
|
+
<path fill="url(#notoFaceWithMonocle0)" d="M63.6 118.8c-27.9 0-58-17.5-58-55.9S35.7 7 63.6 7c15.5 0 29.8 5.1 40.4 14.4c11.5 10.2 17.6 24.6 17.6 41.5s-6.1 31.2-17.6 41.4c-10.6 9.3-25 14.5-40.4 14.5z"/>
|
|
29
|
+
<path fill="#EB8F00" d="M111.49 29.67c5.33 8.6 8.11 18.84 8.11 30.23c0 16.9-6.1 31.2-17.6 41.4c-10.6 9.3-25 14.5-40.4 14.5c-18.06 0-37.04-7.35-48.18-22.94c10.76 17.66 30.99 25.94 50.18 25.94c15.4 0 29.8-5.2 40.4-14.5c11.5-10.2 17.6-24.5 17.6-41.4c0-12.74-3.47-24.06-10.11-33.23z"/>
|
|
30
|
+
<path fill="#422B0D" d="M74.3 24.5c.9-.8 1.8-1.5 2.8-2.2s2.1-1.2 3.1-1.8c2.2-1 4.6-2 7.5-2.1c.7-.1 1.4.1 2.2.1c.7 0 1.5.3 2.2.5c.2.1.4.1.5.2l.5.3l1 .5c.6.4 1.2.9 1.8 1.4c1.1 1 1.8 2.3 2.4 3.5c.3.6.5 1.2.7 1.8c.2.6.3 1.2.4 1.6l.1.3c.2 1.2-.6 2.4-1.8 2.6c-1 .2-1.9-.3-2.4-1.1c-.3-.6-.6-1.1-.8-1.5c-.2-.4-.5-.8-.7-1.2c-.5-.7-1.1-1.3-1.7-1.8c-.1-.1-.3-.2-.5-.3c-.2-.1-.3-.2-.4-.3c-.2-.1-.3-.1-.5-.2l-.2-.1h-.3c-.7-.2-1.4-.3-2.2-.2c-1.6 0-3.5.6-5.4 1.3c-.9.4-1.9.8-2.8 1.2c-.9.5-1.9.9-2.9 1.3l-.2.1c-1.2.5-2.5-.1-2.9-1.2c-.5-1-.2-2.1.5-2.7zm-28.7 14c-.8.2-1.3.3-2 .3c-.6 0-1.3.1-1.9 0c-1.3 0-2.6-.2-3.8-.6c-2-.5-4-.8-5.7-.8c-.8 0-1.6.1-2.2.3s-1.1.5-1.6 1c-1 1-2 2.8-3 4.6c-.6 1.1-2 1.5-3.1.9c-.9-.5-1.3-1.5-1.2-2.4c.2-1.1.5-2.3.9-3.5c.5-1.2 1-2.4 2-3.6c1-1.2 2.3-2.2 3.8-2.7s2.9-.7 4.3-.7c2.7.1 5 .8 7.2 1.6c.9.3 1.8.6 2.7.8c.5.1.9.2 1.4.2c.4 0 1 .1 1.3.1h.4c1.2 0 2.2 1.1 2.1 2.3c.1 1.2-.6 2-1.6 2.2zM44 91.3c1.8-2 6.6-4.3 13.3-4.2c8.9.2 13.7 4.2 13.7 4.2c2.9 2.4 1.6 6.1-1.5 5.8c-5-.6-4.7-1.5-13.7-1.7c-6.5-.1-9.6.9-9.9.9c-1.8.1-2.5-.6-2.8-1.8c-.3-1 0-2.3.9-3.2zm38.3-47.5c4.4 0 8.4 3.7 8.4 9.9s-4 9.9-8.4 9.9s-8.4-3.7-8.4-9.9s4-9.9 8.4-9.9zm-45.1 1.7c-4.2 0-8 3.5-8 9.4s3.8 9.4 8 9.4s8-3.5 8-9.4s-3.8-9.4-8-9.4z"/>
|
|
31
|
+
<path fill="#896024" d="M81.37 48.35c-1.03-.72-2.58-.49-3.58.95c-1 1.45-.67 2.97.36 3.69c1.03.72 2.58.49 3.58-.95c1.01-1.45.67-2.98-.36-3.69z"/>
|
|
32
|
+
<path fill="#404040" d="M106.5 49.9h-5.6v9h5.6c2.7 0 5.4-1.7 5.4-4.3v-.4c0-2.7-2.7-4.3-5.4-4.3zm-.5 7.7c-1.9 0-3.4-1.5-3.4-3.3s1.5-3.3 3.4-3.3s3.4 1.5 3.4 3.3s-1.5 3.3-3.4 3.3zm.1 13.2c-.3 0-.6-.2-.6-.5v-4.6c0-.3.2-.5.5-.5h.1c.3 0 .5.2.5.5v4.6c0 .2-.2.5-.5.5zm0 7.6c-.3 0-.6-.2-.6-.5v-4.6c0-.3.2-.5.5-.5h.1c.3 0 .5.2.5.5v4.6c0 .3-.2.5-.5.5zm0 7.7c-.3 0-.6-.2-.6-.5V81c0-.3.2-.5.5-.5h.1c.3 0 .5.2.5.5v4.6c0 .3-.2.5-.5.5zm0 7.7c-.3 0-.6-.2-.6-.5v-4.6c0-.3.2-.5.5-.5h.1c.3 0 .5.2.5.5v4.6c0 .3-.2.5-.5.5zm0 7.7c-.3 0-.6-.2-.6-.5v-4.6c0-.3.2-.5.5-.5h.1c.3 0 .5.2.5.5v4.6c0 .3-.2.5-.5.5zm0 7.7c-.3 0-.6-.2-.6-.5v-4.6c0-.3.2-.5.5-.5h.1c.3 0 .5.2.5.5v4.6c0 .3-.2.5-.5.5zm0 7.7c-.3 0-.6-.2-.6-.5v-4.6c0-.3.2-.5.5-.5h.1c.3 0 .5.2.5.5v4.6c0 .3-.2.5-.5.5z"/>
|
|
33
|
+
<path fill="#404040" d="M106.1 62.7c-.3 0-.6-.2-.6-.5v-4.6c0-.3.2-.5.5-.5h.1c.3 0 .5.2.5.5v4.6c0 .2-.2.5-.5.5z"/>
|
|
34
|
+
<circle cx="106.1" cy="64.1" r="2.6" fill="none" stroke="#404040" stroke-miterlimit="10"/>
|
|
35
|
+
<circle cx="106.1" cy="71.8" r="2.6" fill="none" stroke="#404040" stroke-miterlimit="10"/>
|
|
36
|
+
<circle cx="106.1" cy="79.4" r="2.6" fill="none" stroke="#404040" stroke-miterlimit="10"/>
|
|
37
|
+
<circle cx="106.1" cy="87.1" r="2.6" fill="none" stroke="#404040" stroke-miterlimit="10"/>
|
|
38
|
+
<circle cx="106.1" cy="94.7" r="2.6" fill="none" stroke="#404040" stroke-miterlimit="10"/>
|
|
39
|
+
<circle cx="106.1" cy="102.4" r="2.6" fill="none" stroke="#404040" stroke-miterlimit="10"/>
|
|
40
|
+
<circle cx="106.1" cy="110" r="2.6" fill="none" stroke="#404040" stroke-miterlimit="10"/>
|
|
41
|
+
<circle cx="106.1" cy="117.7" r="2.6" fill="none" stroke="#404040" stroke-miterlimit="10"/>
|
|
42
|
+
<circle cx="79.6" cy="53.7" r="20.6" fill="#CCC" fill-opacity=".5" stroke="#404040" stroke-miterlimit="10" stroke-width="3.5"/>
|
|
43
|
+
<path fill="#FFF" d="M94.8 52.5c-.4-3.8-2.1-7.3-4.9-9.7s-6.4-3.7-10-3.7c-3.7 0-7.3 1.2-10.1 3.5s-4.6 5.8-4.9 9.6c0 .3-.3.5-.5.4c-.2 0-.4-.2-.4-.5c-.1-2 .3-4.1 1.1-6c.8-1.9 2-3.6 3.5-5.1c3-2.9 7.3-4.3 11.4-4.3c4.2 0 8.3 1.6 11.3 4.5c1.5 1.5 2.7 3.2 3.5 5.1c.8 1.9 1.1 4 1 6c0 .3-.2.5-.5.5c-.3.1-.5-.1-.5-.3z"/>
|
|
44
|
+
<path fill="#896024" d="M37.01 49.35c-1.03-.72-2.58-.49-3.58.95s-.67 2.97.36 3.69c1.03.72 2.58.49 3.58-.95c1.01-1.45.68-2.98-.36-3.69z"/>
|
|
45
|
+
</svg>`
|
package/src/styles/index.scss
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { SiteConfig } from 'vitepress'
|
|
2
2
|
import path from 'path'
|
|
3
3
|
import { execSync } from 'child_process'
|
|
4
|
+
import {
|
|
5
|
+
pagefindPlugin,
|
|
6
|
+
chineseSearchOptimize
|
|
7
|
+
} from 'vitepress-plugin-pagefind'
|
|
4
8
|
import type { Theme } from '../../composables/config/index'
|
|
5
9
|
import { genFeed } from './genFeed'
|
|
6
10
|
|
|
@@ -13,12 +17,18 @@ export function getVitePlugins(cfg?: Partial<Theme.BlogConfig>) {
|
|
|
13
17
|
plugins.push(inlineBuildEndPlugin(buildEndFn))
|
|
14
18
|
|
|
15
19
|
// 内置简化版的pagefind
|
|
16
|
-
if (
|
|
17
|
-
cfg
|
|
18
|
-
(
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
if (cfg && cfg.search !== false) {
|
|
21
|
+
const ops = cfg.search instanceof Object ? cfg.search : {}
|
|
22
|
+
plugins.push(
|
|
23
|
+
pagefindPlugin({ ...ops, customSearchQuery: chineseSearchOptimize })
|
|
24
|
+
)
|
|
21
25
|
}
|
|
26
|
+
// 未来移除使用
|
|
27
|
+
// if (cfg && cfg.search !== undefined) {
|
|
28
|
+
// console.log(
|
|
29
|
+
// '已从内部移除 pagefind 支持,请单独安装 vitepress-plugin-pagefind 插件使用'
|
|
30
|
+
// )
|
|
31
|
+
// }
|
|
22
32
|
|
|
23
33
|
buildEndFn.push(genFeed)
|
|
24
34
|
return plugins
|