@sugarat/theme 0.2.21 → 0.2.23

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 CHANGED
@@ -473,7 +473,13 @@ function getVitePlugins(cfg) {
473
473
  if (cfg && cfg.search !== false) {
474
474
  const ops = cfg.search instanceof Object ? cfg.search : {};
475
475
  plugins.push(
476
- (0, import_vitepress_plugin_pagefind.pagefindPlugin)({ ...ops, customSearchQuery: import_vitepress_plugin_pagefind.chineseSearchOptimize })
476
+ (0, import_vitepress_plugin_pagefind.pagefindPlugin)({
477
+ ...ops,
478
+ customSearchQuery: import_vitepress_plugin_pagefind.chineseSearchOptimize,
479
+ filter(searchItem) {
480
+ return searchItem.meta.publish !== false;
481
+ }
482
+ })
477
483
  );
478
484
  }
479
485
  if (cfg?.mermaid !== false) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sugarat/theme",
3
- "version": "0.2.21",
3
+ "version": "0.2.23",
4
4
  "description": "简约风的 Vitepress 博客主题,sugarat vitepress blog theme",
5
5
  "author": "sugar",
6
6
  "license": "MIT",
@@ -45,8 +45,8 @@
45
45
  "swiper": "^11.0.5",
46
46
  "vitepress-markdown-timeline": "^1.2.1",
47
47
  "vitepress-plugin-mermaid": "2.0.13",
48
- "vitepress-plugin-pagefind": "0.2.11",
49
- "vitepress-plugin-rss": "0.2.1",
48
+ "vitepress-plugin-pagefind": "0.2.12",
49
+ "vitepress-plugin-rss": "0.2.2",
50
50
  "vitepress-plugin-tabs": "0.2.0"
51
51
  },
52
52
  "devDependencies": {
@@ -1,10 +1,14 @@
1
1
  <script lang="ts" setup>
2
2
  import { useData } from 'vitepress'
3
3
  import { computed } from 'vue'
4
- import { useBlogConfig } from '../composables/config/blog'
4
+ import { useBlogConfig, useCurrentArticle } from '../composables/config/blog'
5
5
 
6
6
  const { frontmatter } = useData()
7
7
  const cover = computed(() => frontmatter.value.cover)
8
+
9
+ const currentArticle = useCurrentArticle()
10
+ const realCover = computed<string>(() => import.meta.env.DEV ? cover.value : currentArticle.value?.meta?.cover)
11
+
8
12
  const { article } = useBlogConfig()
9
13
  const hiddenCover = computed(
10
14
  () => frontmatter.value?.hiddenCover ?? article?.hiddenCover ?? false
@@ -12,7 +16,7 @@ const hiddenCover = computed(
12
16
  </script>
13
17
 
14
18
  <template>
15
- <img v-if="cover && !hiddenCover" class="blog-doc-cover" :src="cover">
19
+ <img v-if="cover && !hiddenCover" class="blog-doc-cover" :src="realCover">
16
20
  </template>
17
21
 
18
22
  <style lang="scss" scoped>
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { computed, ref } from 'vue'
2
+ import { computed, onMounted, ref } from 'vue'
3
3
  import { useRoute, withBase } from 'vitepress'
4
4
  import { ElButton, ElLink } from 'element-plus'
5
5
  import { formatShowDate } from '../utils/client'
@@ -88,6 +88,7 @@ function changePage() {
88
88
  const newIdx
89
89
  = currentPage.value % Math.ceil(recommendList.value.length / pageSize.value)
90
90
  currentPage.value = newIdx + 1
91
+ return newIdx + 1
91
92
  }
92
93
  // 当前页开始的序号
93
94
  const startIdx = computed(() => (currentPage.value - 1) * pageSize.value)
@@ -101,6 +102,22 @@ const currentWikiData = computed(() => {
101
102
  const showChangeBtn = computed(() => {
102
103
  return recommendList.value.length > pageSize.value
103
104
  })
105
+
106
+ onMounted(() => {
107
+ const checkHaveActive = () => {
108
+ const have = currentWikiData.value.some(v => isCurrentDoc(v.route))
109
+ if (have) {
110
+ return
111
+ }
112
+ if (currentPage.value >= changePage()) {
113
+ return
114
+ }
115
+
116
+ // TODO:存在理论闪烁情况,未来优化
117
+ setTimeout(checkHaveActive)
118
+ }
119
+ checkHaveActive()
120
+ })
104
121
  </script>
105
122
 
106
123
  <template>
@@ -27,7 +27,13 @@ export function getVitePlugins(cfg?: Partial<Theme.BlogConfig>) {
27
27
  if (cfg && cfg.search !== false) {
28
28
  const ops = cfg.search instanceof Object ? cfg.search : {}
29
29
  plugins.push(
30
- pagefindPlugin({ ...ops, customSearchQuery: chineseSearchOptimize })
30
+ pagefindPlugin({
31
+ ...ops,
32
+ customSearchQuery: chineseSearchOptimize,
33
+ filter(searchItem) {
34
+ return searchItem.meta.publish !== false
35
+ }
36
+ })
31
37
  )
32
38
  }
33
39