@sugarat/theme 0.1.16 → 0.1.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sugarat/theme",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "简约风的 Vitepress 博客主题,sugarat vitepress blog theme",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -4,9 +4,10 @@
4
4
  v-if="show"
5
5
  id="giscus-comment"
6
6
  data-pagefind-ignore="all"
7
+ ref="commentEl"
7
8
  >
8
9
  <el-affix
9
- :class="{ hidden: !showCommnetAffix }"
10
+ :class="{ hidden: commentIsVisible }"
10
11
  class="comment-btn"
11
12
  target="main"
12
13
  position="bottom"
@@ -43,7 +44,7 @@
43
44
  </div>
44
45
  </template>
45
46
  <script setup lang="ts">
46
- import { useDark } from '@vueuse/core'
47
+ import { useDark, useElementVisibility } from '@vueuse/core'
47
48
  import { useData, useRoute } from 'vitepress'
48
49
  import { computed, ref, watch } from 'vue'
49
50
  import { ElAffix, ElButton } from 'element-plus'
@@ -52,10 +53,9 @@ import { useGiscusConfig } from '../composables/config/blog'
52
53
  import { Theme } from '../composables/config/index'
53
54
 
54
55
  const { frontmatter } = useData()
55
- const showCommnetAffix = ref(true)
56
- const handleVisibleChange = (v: boolean) => {
57
- showCommnetAffix.value = v
58
- }
56
+ const commentEl = ref(null)
57
+ const commentIsVisible = useElementVisibility(commentEl)
58
+
59
59
  const handleScrollToComment = () => {
60
60
  document.querySelector('#giscus-comment')?.scrollIntoView({
61
61
  behavior: 'smooth',
@@ -154,7 +154,7 @@ const headingText = computed(() => {
154
154
  const openSearch = computed(() =>
155
155
  searchConfig instanceof Object
156
156
  ? searchConfig.mode ?? true
157
- : searchConfig || true
157
+ : searchConfig ?? true
158
158
  )
159
159
 
160
160
  const addInlineScript = () => {
@@ -1,4 +1,4 @@
1
- import { useData, useRoute } from 'vitepress'
1
+ import { useData, useRoute, withBase } from 'vitepress'
2
2
  import {
3
3
  Component,
4
4
  computed,
@@ -85,7 +85,7 @@ export function useCurrentArticle() {
85
85
  const currentPath = route.path.replace(/.html$/, '')
86
86
  return docs.value?.find((v) =>
87
87
  // 兼容中文路径
88
- [currentPath, decodeURIComponent(currentPath)].includes(v.route)
88
+ [currentPath, decodeURIComponent(currentPath)].includes(withBase(v.route))
89
89
  )
90
90
  })
91
91