valaxy-theme-hairy 0.2.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. package/client/index.ts +1 -0
  2. package/components/HairyBody.vue +15 -17
  3. package/components/HairyComment.vue +33 -0
  4. package/components/HairyContainer.vue +13 -0
  5. package/components/{HairyUserPopup.vue → HairyDrawer.vue} +14 -13
  6. package/components/HairyFooter.vue +12 -9
  7. package/components/HairyHeader.vue +10 -9
  8. package/components/HairyImage.vue +2 -1
  9. package/components/HairyImageGroup.vue +12 -16
  10. package/components/HairyNavbar.vue +56 -0
  11. package/components/{HairyPostList.vue → HairyPosts.vue} +3 -3
  12. package/components/{HairyNavSearch.vue → HairySearch.vue} +23 -87
  13. package/components/{HairyUserCard.vue → HairySidebar.vue} +4 -4
  14. package/components/{HairyUserTab.vue → HairyTabbar.vue} +27 -11
  15. package/components/PageTags.vue +48 -0
  16. package/components/ValaxyMain.vue +3 -3
  17. package/components/navbar/HairyNav.vue +16 -0
  18. package/components/navbar/HairyNavExpand.vue +12 -0
  19. package/components/navbar/HairyNavItem.vue +35 -0
  20. package/components/navbar/HairyNavbarBackground.vue +7 -0
  21. package/components/navbar/HairyNavbarSearch.vue +8 -0
  22. package/components/{HairyNavTitle.vue → navbar/HairyNavbarTitle.vue} +5 -3
  23. package/components/navbar/HairyNavbarToggleDark.vue +22 -0
  24. package/components/{HairyBreadcrumb.vue → parts/HairyBreadcrumb.vue} +1 -1
  25. package/components/{HairyBreadcrumbItem.vue → parts/HairyBreadcrumbItem.vue} +1 -4
  26. package/components/{lib/fish.js → parts/HairyFootFish.js} +5 -7
  27. package/components/parts/HairyFootFish.vue +38 -0
  28. package/components/{HairyPostTitle.vue → parts/HairyHeadHero.vue} +6 -5
  29. package/components/{HairyWaves.vue → parts/HairyHeadWaves.vue} +5 -5
  30. package/components/parts/HairyImageGlobal.vue +51 -0
  31. package/components/{HairyImageViewer.vue → parts/HairyImageViewer.vue} +4 -3
  32. package/components/parts/HairyLink.vue +21 -0
  33. package/components/{HairyMenu.vue → parts/HairyMenu.vue} +2 -1
  34. package/components/{HairyMenuItem.vue → parts/HairyMenuItem.vue} +11 -4
  35. package/components/parts/HairyOutline.vue +99 -0
  36. package/components/parts/HairyOutlineItem.vue +48 -0
  37. package/components/{HairySocialLinks.vue → parts/HairySocialLinks.vue} +2 -2
  38. package/components/{HairyTimelinePostItem.vue → parts/HairyTimelineContent.vue} +7 -8
  39. package/components/parts/HairyUserNav.vue +95 -0
  40. package/components/{article-layout → posts}/HairyArticleImage.vue +18 -19
  41. package/components/{article-layout → posts}/HairyArticleSeries.vue +8 -5
  42. package/components/{article-layout → posts}/HairyArticleText.vue +11 -4
  43. package/components/posts/HairyPostFooter.vue +15 -0
  44. package/components/{article-layout → posts}/HairyPostImageList.vue +4 -5
  45. package/components/{article-layout → posts}/HairyPostTextsList.vue +0 -1
  46. package/components/posts/HairyPostToggleLayout.vue +36 -0
  47. package/components/third/HairyAlgoliaSearch.vue +17 -0
  48. package/components/third/HairyFuseSearch.vue +10 -0
  49. package/components/third/HairyFuseSearchDialog.vue +32 -0
  50. package/components/third/HairyFuseSearchDropdown.vue +77 -0
  51. package/components/third/HairyFuseSearchFooter.vue +28 -0
  52. package/components/third/HairyFuseSearchHeader.vue +30 -0
  53. package/components/third/HairyFuseSearchHit.vue +52 -0
  54. package/components/third/HairySearchBtnDisplay.vue +29 -0
  55. package/components/third/HairySearchBtnInput.vue +20 -0
  56. package/components/third/HairySearchBtnKeys.vue +19 -0
  57. package/components/{HairyCarousel.vue → third/HairySwiperCarousel.vue} +6 -6
  58. package/{hooks/useYearArchives.ts → composables/archives.ts} +4 -3
  59. package/composables/category.ts +43 -0
  60. package/composables/config.ts +11 -0
  61. package/composables/dark.ts +13 -0
  62. package/composables/fuse.ts +60 -0
  63. package/composables/index.ts +8 -0
  64. package/composables/layout.ts +16 -0
  65. package/composables/outline.ts +49 -0
  66. package/composables/tags.ts +36 -0
  67. package/layouts/archive-month.vue +13 -0
  68. package/layouts/archive-year.vue +13 -0
  69. package/layouts/archive.vue +11 -0
  70. package/layouts/categories.vue +11 -4
  71. package/layouts/default.vue +8 -7
  72. package/layouts/home.vue +28 -18
  73. package/layouts/post.vue +41 -35
  74. package/layouts/tag.vue +8 -4
  75. package/layouts/tags.vue +11 -4
  76. package/{modules → library}/loading.ts +18 -6
  77. package/{modules → library}/scroll.ts +3 -2
  78. package/locales/zh-CN.yml +0 -2
  79. package/node/images/default.json +139 -0
  80. package/node/images/index.ts +46 -0
  81. package/node/index.ts +2 -0
  82. package/node/theme/index.ts +78 -0
  83. package/package.json +22 -28
  84. package/pages/archives/[year]/[month]/index.vue +15 -16
  85. package/pages/archives/[year]/index.vue +20 -18
  86. package/pages/archives/index.vue +10 -8
  87. package/pages/categories/{[...categories].vue → [...its].vue} +29 -34
  88. package/pages/index.vue +1 -1
  89. package/pages/page/[page].vue +2 -2
  90. package/pages/tags/{[tag].vue → [tag]/index.vue} +12 -12
  91. package/pages/tags/index.vue +12 -5
  92. package/setup/main.ts +1 -1
  93. package/store/index.ts +1 -0
  94. package/store/modules/global.ts +12 -0
  95. package/styles/components/index.scss +4 -0
  96. package/styles/{markdown.scss → components/markdown.scss} +2 -1
  97. package/styles/components/nprogress.scss +16 -0
  98. package/styles/css-vars.scss +11 -0
  99. package/styles/element-plus/tabs.scss +1 -1
  100. package/styles/element-plus/timeline.scss +1 -1
  101. package/styles/global.scss +39 -0
  102. package/styles/index.scss +4 -73
  103. package/tsconfig.json +27 -0
  104. package/types/index.d.ts +163 -0
  105. package/unocss.config.ts +5 -1
  106. package/utils/index.ts +21 -39
  107. package/valaxy.config.ts +21 -24
  108. package/@types/markdown-it.d.ts +0 -1
  109. package/@types/markdown-toc.d.ts +0 -1
  110. package/@types/types.d.ts +0 -1
  111. package/@types/valaxy.d.ts +0 -10
  112. package/components/HairyAlgoliaSearchBox.vue +0 -118
  113. package/components/HairyBackToTop.vue +0 -72
  114. package/components/HairyDivider.vue +0 -0
  115. package/components/HairyFooterFish.vue +0 -29
  116. package/components/HairyLayout.vue +0 -28
  117. package/components/HairyLink.vue +0 -10
  118. package/components/HairyLinks.vue +0 -69
  119. package/components/HairyMeting.vue +0 -19
  120. package/components/HairyNav.vue +0 -42
  121. package/components/HairyNavBackground.vue +0 -7
  122. package/components/HairyNavMenu.vue +0 -11
  123. package/components/HairyNavToggleDark.vue +0 -16
  124. package/components/HairyPostToggleLayout.vue +0 -33
  125. package/components/HairyToc.vue +0 -135
  126. package/components/HairyUserNav.vue +0 -64
  127. package/components/HairyWaline.vue +0 -44
  128. package/hooks/setupDefaultDark.ts +0 -11
  129. package/hooks/useCategory.ts +0 -18
  130. package/hooks/useCategoryPost.ts +0 -21
  131. package/hooks/useContext.ts +0 -13
  132. package/hooks/useHeaderHeight.ts +0 -9
  133. package/hooks/usePostLayout.ts +0 -16
  134. package/images.json +0 -140
  135. package/index.d.ts +0 -100
  136. package/layouts/archives.vue +0 -11
  137. package/layouts/hairy.vue +0 -36
  138. package/layouts/month.vue +0 -6
  139. package/layouts/year.vue +0 -6
  140. package/node/addon-hairy.ts +0 -36
  141. package/node/addon-images.ts +0 -61
  142. package/node/addon-meting.ts +0 -13
  143. package/node/addon-statistics.ts +0 -19
  144. package/node/addon-toc.ts +0 -20
  145. package/node/utils.ts +0 -20
  146. package/utils/createContext.ts +0 -40
  147. package/utils/fonts.ts +0 -15
  148. /package/components/{HairyUserStats.vue → parts/HairyUserStats.vue} +0 -0
  149. /package/components/{article-layout → posts}/HairyArticleTop.vue +0 -0
  150. /package/{modules → library}/loading.scss +0 -0
  151. /package/{shims.d.ts → node/images/shims.d.ts} +0 -0
  152. /package/styles/{aplayer.scss → components/aplayer.scss} +0 -0
  153. /package/styles/{scrollbar.scss → components/scrollbar.scss} +0 -0
@@ -5,11 +5,12 @@ import { withDefaults } from 'vue'
5
5
  import { last } from 'lodash-es'
6
6
  import { useRouter } from 'vue-router'
7
7
  import { useI18n } from 'vue-i18n'
8
- import { toArr } from '../utils'
8
+ import { toArray } from '../../utils'
9
+
9
10
  withDefaults(
10
11
  defineProps<{
11
12
  post: Post
12
- format: string
13
+ format?: string
13
14
  }>(),
14
15
  {
15
16
  format: 'YYYY-MM-DD',
@@ -20,8 +21,8 @@ const i18n = useI18n()
20
21
 
21
22
  const router = useRouter()
22
23
 
23
- const displayCategory = (keys: string | string[] = []) => {
24
- router.push({ path: `/categories/${toArr(keys).join('/')}` })
24
+ function displayCategory(keys: string | string[] = []) {
25
+ router.push({ path: `/categories/${toArray(keys).join('/')}` })
25
26
  }
26
27
  </script>
27
28
 
@@ -30,11 +31,9 @@ const displayCategory = (keys: string | string[] = []) => {
30
31
  <div class="mr-2.2 dark:text-gray-500 text-gray-400">
31
32
  {{ dayjs(post.date).format(format) }}
32
33
  </div>
33
- <HairyLink v-if="post.categories?.length" @click="displayCategory(post.categories)">
34
- {{ i18n.t(last(toArr(post.categories)) || '') }}
34
+ <HairyLink v-if="post.categories?.length" bordered type="white" @click="displayCategory(post.categories)">
35
+ {{ i18n.t(last(toArray(post.categories)) || '') }}
35
36
  </HairyLink>
36
37
  </div>
37
38
  <a class="cursor-pointer text-size-4" @click="$router.push(post.path || '')">{{ post.title }}</a>
38
39
  </template>
39
-
40
- <style lang="scss" scoped></style>
@@ -0,0 +1,95 @@
1
+ <script lang="ts" setup>
2
+ import { usePostList, useTags } from 'valaxy'
3
+ import { computed, nextTick } from 'vue'
4
+ import { useRouter } from 'vue-router'
5
+ import { storeToRefs } from 'pinia'
6
+ import { toArray } from '../../utils'
7
+ import { useGlobalStore } from '../../store'
8
+
9
+ const posts = usePostList()
10
+ const tags = useTags()
11
+ const router = useRouter()
12
+ const { showDrawer } = storeToRefs(useGlobalStore())
13
+
14
+ const total = computed(() => {
15
+ const categories = posts.value.map(v => toArray(v.categories || [])).filter(v => v.length)
16
+ const maps: string[] = []
17
+ for (const category of categories) {
18
+ let caches: string[] = []
19
+ for (const iterator of category) {
20
+ caches.push(iterator)
21
+ maps.push(caches.join('-'))
22
+ }
23
+ caches = []
24
+ }
25
+ return new Set(maps).size
26
+ })
27
+
28
+ async function navigation(path: string) {
29
+ await router.push(path)
30
+ await nextTick()
31
+ showDrawer.value = false
32
+ }
33
+ </script>
34
+
35
+ <template>
36
+ <div class="flex justify-center mt-2">
37
+ <HairyUserStats :count="posts.length" @click="navigation('/archives/')">
38
+ 文章
39
+ </HairyUserStats>
40
+ <div class="w-1px bg-gray bg-opacity-50" />
41
+ <HairyUserStats :count="total" @click="navigation('/categories/')">
42
+ 分类
43
+ </HairyUserStats>
44
+ <div class="w-1px bg-gray bg-opacity-50" />
45
+ <HairyUserStats :count="tags.size" @click="navigation('/tags/')">
46
+ 标签
47
+ </HairyUserStats>
48
+ </div>
49
+ <HairySocialLinks class="mt-5" />
50
+ <HairyMenu class="HairyUserMenu mt-5 flex-col h-auto" />
51
+ </template>
52
+
53
+ <style lang="scss">
54
+ .HairyUserMenu {
55
+ display: flex;
56
+ flex-direction: column;
57
+ gap: 6px;
58
+ .HairyMenuItem {
59
+ padding: 2px;
60
+ width: 100%;
61
+ border: 1px solid transparent;
62
+ > div {
63
+ justify-content: center;
64
+ }
65
+ border-radius: 10px;
66
+ transition: all 0.2s;
67
+ background-color: transparent;
68
+ user-select: none;
69
+ }
70
+
71
+ .HairyMenuItem:hover,
72
+ .HairyMenuItem.active {
73
+ background-color: #f4f4f5;
74
+ }
75
+ .HairyMenuItem:active {
76
+ background-color: #efefef;
77
+ }
78
+
79
+ .HairyMenuItem.active + .HairyMenuItem {
80
+ border-top-color: transparent;
81
+ }
82
+ .HairyMenuItem:hover + .HairyMenuItem {
83
+ border-top-color: transparent;
84
+ }
85
+ }
86
+ .dark .HairyUserMenu {
87
+ .HairyMenuItem:hover,
88
+ .HairyMenuItem.active {
89
+ background-color: #f4f4f50a;
90
+ }
91
+ .HairyMenuItem:active {
92
+ background-color: #f4f4f521;
93
+ }
94
+ }
95
+ </style>
@@ -4,28 +4,27 @@ import { computed, defineProps } from 'vue'
4
4
  import dayjs from 'dayjs'
5
5
  import { useRouter } from 'vue-router'
6
6
  import { useI18n } from 'vue-i18n'
7
- import { last } from 'lodash-es'
8
- import { usePostLayout } from '../../hooks/usePostLayout'
9
- import { toArr } from '../../utils'
7
+ import { removeTags, toArray } from '../../utils'
8
+ import { useLayoutPost } from '../../composables'
10
9
 
11
10
  const props = defineProps<{
12
11
  post: Post
13
12
  reverse?: boolean
14
13
  }>()
14
+
15
15
  const router = useRouter()
16
- const layout = usePostLayout()
16
+ const layout = useLayoutPost()
17
17
  const slice = computed(() => layout.value.includes('slice'))
18
- const image = computed(() => props.post.image)
19
-
18
+ const image = computed(() => props.post.image?.toString())
19
+ const text = computed(() => removeTags(props.post.excerpt))
20
20
  const i18n = useI18n()
21
-
22
- const onReadMore = () => {
21
+ function onReadMore() {
23
22
  if (props.post.path)
24
23
  router.push(props.post.path)
25
24
  }
26
25
 
27
- const displayCategory = (keys: string | string[] = []) => {
28
- router.push({ path: `/categories/${toArr(keys).join('/')}` })
26
+ function displayCategory(keys: string | string[] = []) {
27
+ router.push({ path: `/categories/${toArray(keys).join('/')}` })
29
28
  }
30
29
  </script>
31
30
 
@@ -36,33 +35,33 @@ const displayCategory = (keys: string | string[] = []) => {
36
35
  <a class="text-size-2xl font-bold truncate cursor-pointer lt-sm:text-size-lg" :class="[reverse ? 'order-last' : 'order-first']" @click="onReadMore">{{ post.title }}</a>
37
36
  <div class="flex justify-end gap-2 text-size-sm lt-sm:text-size-xs">
38
37
  <span>{{ dayjs(post.date).format('YYYY-MM-DD') }}</span>
39
- <span>{{ (post.length / 1000).toFixed(1) }}k字</span>
40
- <span class="lt-sm:hidden">{{ post.durations.minutes.toFixed(2) }}分钟</span>
38
+ <span>{{ post.wordCount }}字</span>
39
+ <span class="lt-sm:hidden">{{ post.readingTime }}分钟</span>
41
40
  </div>
42
41
  </div>
43
- <div class="h-200px lt-sm:h-150px flex bg-light-2 dark:bg-transparent rounded-5 duration-200" :class="[reverse ? 'pl-4' : 'pr-4']">
42
+ <div class="h-200px lt-sm:h-150px flex bg-light-2 dark:bg-transparent rounded-5" :class="[reverse ? 'pl-4' : 'pr-4']">
44
43
  <div class="flex-1 post-image-content" :class="[reverse ? 'order-last' : 'order-first']">
45
44
  <img
46
45
  class="post-image rounded-1 w-full h-full object-cover cursor-pointer" :src="image"
47
46
  @click="onReadMore"
48
- />
47
+ >
49
48
  </div>
50
49
  <div class="flex-1 flex flex-col justify-between py-2 dark:py-0">
51
50
  <div class="flex-1 text-size-sm">
52
51
  <div class="line-clamp-text">
53
- {{ post.text }}
52
+ {{ text }}
54
53
  </div>
55
54
  </div>
56
55
  <div class="flex justify-between items-center">
57
56
  <a class="cursor-pointer" :class="[reverse && 'order-1']">
58
57
  <span v-if="post.categories?.length" @click="displayCategory(post.categories)">
59
- {{ i18n.t(last(toArr(post.categories)) || '') }}
58
+ {{ i18n.t(toArray(post.categories).at(-1) || '') }}
60
59
  </span>
61
60
  </a>
62
61
  <div class="text-base leading-6 font-medium">
63
62
  <a class="link cursor-pointer" aria-label="read more" @click="onReadMore">
64
63
  <span v-if="reverse">←</span>
65
- Read more
64
+ <span class="hidden md:block">Read more</span>
66
65
  <span v-if="!reverse">→</span>
67
66
  </a>
68
67
  </div>
@@ -86,7 +85,7 @@ const displayCategory = (keys: string | string[] = []) => {
86
85
 
87
86
  .dark {
88
87
  .post-image {
89
- @apply opacity-75 hover: opacity-90 duration-200;
88
+ @apply opacity-75 hover:opacity-90 ;
90
89
  }
91
90
  }
92
91
 
@@ -115,7 +114,7 @@ const displayCategory = (keys: string | string[] = []) => {
115
114
 
116
115
  .HairyArticleImage.slice {
117
116
  .post-image {
118
- @apply transition-all;
117
+ // @apply transition-all;
119
118
  }
120
119
 
121
120
  &:hover {
@@ -1,17 +1,20 @@
1
1
  <script lang="ts" setup>
2
+ import type { PostFrontMatter } from 'valaxy'
2
3
  import { useFrontmatter } from 'valaxy'
3
4
  import { computed, inject, nextTick, ref } from 'vue'
4
5
  import { useRouter } from 'vue-router'
5
- import { toArr } from '../../utils'
6
- import { useCurrentCategory } from '../../hooks/useCategory'
6
+ import { toArray } from '../../utils'
7
+ import { useCategory } from '../../composables'
7
8
 
8
9
  const frontmatter = useFrontmatter()
9
- const paths = computed(() => toArr(frontmatter.value.categories).filter(Boolean) as string[])
10
- const category = useCurrentCategory(paths)
10
+ const paths = computed(() => toArray(frontmatter.value.categories).filter(Boolean) as string[])
11
+ const category = useCategory(paths)
12
+
11
13
  const posts = computed(() => {
12
- const result = category.value.posts || []
14
+ const result = [...(category.value.children?.values() || [])] as PostFrontMatter[]
13
15
  return result.sort((a, b) => (a.date || 1) > (b.date || 1) ? 1 : -1)
14
16
  })
17
+
15
18
  const router = useRouter()
16
19
 
17
20
  const active = inject('HairyUserTab:active', ref(''))
@@ -1,14 +1,18 @@
1
1
  <script lang="ts" setup>
2
2
  import type { Post } from 'valaxy'
3
3
  import { computed, defineProps } from 'vue'
4
- import { usePostLayout } from '../../hooks/usePostLayout'
4
+ import { removeTags } from '../../utils'
5
+ import { useLayoutPost } from '../../composables'
6
+
5
7
  const props = defineProps<{
6
8
  post: Post
7
9
  }>()
8
- const layout = usePostLayout()
10
+
11
+ const layout = useLayoutPost()
12
+
9
13
  const text = computed(() => {
10
14
  if (layout.value === 'text')
11
- return props.post.text
15
+ return removeTags(props.post.excerpt)
12
16
  return props.post.excerpt
13
17
  })
14
18
  </script>
@@ -28,7 +32,10 @@ const text = computed(() => {
28
32
  />
29
33
  </div>
30
34
  <div class="text-base leading-6 font-medium">
31
- <a class="link" aria-label="read more" :href="post.path">Read more →</a>
35
+ <a class="link" aria-label="read more" :href="post.path">
36
+ <span class="hidden md:block">Read more</span>
37
+ <span> →</span>
38
+ </a>
32
39
  </div>
33
40
  </div>
34
41
  </article>
@@ -0,0 +1,15 @@
1
+ <script lang="ts" setup>
2
+ import { useRoute } from 'vue-router'
3
+
4
+ const route = useRoute()
5
+ </script>
6
+
7
+ <template>
8
+ <div class="mb-15">
9
+ <div class="border-t border-gray-200 dark:border-gray-600" />
10
+ <div class="flex items-center justify-end mt-2">
11
+ <div class="i-ri-eye-fill mr-2" />
12
+ 阅读次数 <span class="waline-pageview-count mx-2" :data-path="route.path"> - </span> 次
13
+ </div>
14
+ </div>
15
+ </template>
@@ -3,8 +3,7 @@ import type { Ref } from 'vue'
3
3
  import { computed } from 'vue'
4
4
  import type { Post } from 'valaxy'
5
5
  import { usePostList } from 'valaxy'
6
-
7
- import { usePostLayout } from '../../hooks/usePostLayout'
6
+ import { useLayoutPost } from '../../composables'
8
7
 
9
8
  const props = withDefaults(defineProps<{
10
9
  type?: string
@@ -12,10 +11,11 @@ const props = withDefaults(defineProps<{
12
11
  }>(), {
13
12
  })
14
13
 
14
+ const layout = useLayoutPost()
15
+ const reverse = computed(() => layout.value.includes('reverse'))
16
+
15
17
  const routes = usePostList() as any as Ref<Post[]>
16
18
  const posts = computed(() => props.posts || routes.value)
17
- const layout = usePostLayout()
18
- const reverse = computed(() => layout.value.includes('reverse'))
19
19
  </script>
20
20
 
21
21
  <template>
@@ -25,4 +25,3 @@ const reverse = computed(() => layout.value.includes('reverse'))
25
25
  </Transition>
26
26
  </ul>
27
27
  </template>
28
-
@@ -20,4 +20,3 @@ const posts = computed(() => props.posts || routes.value)
20
20
  </Transition>
21
21
  </ul>
22
22
  </template>
23
-
@@ -0,0 +1,36 @@
1
+ <script lang="ts" setup>
2
+ import { useElementSize, useScroll } from '@vueuse/core'
3
+ import { computed } from 'vue'
4
+ import { storeToRefs } from 'pinia'
5
+ import { useGlobalStore } from '../../store'
6
+ import { useLayoutPost } from '../../composables'
7
+
8
+ const layout = useLayoutPost()
9
+
10
+ const layouts = [
11
+ { layout: 'image:slice:reverse' as const, icon: 'i-fluent-text-align-distributed-24-filled' },
12
+ { layout: 'image:slice' as const, icon: 'i-fluent-text-align-left-16-filled' },
13
+ { layout: 'image' as const, icon: 'i-fluent-text-align-justify-20-filled' },
14
+ { layout: 'markdown' as const, icon: 'i-fluent-markdown-20-filled' },
15
+ { layout: 'text' as const, icon: 'i-fluent-code-text-16-filled' },
16
+ ]
17
+
18
+ const globalStore = useGlobalStore()
19
+ const { headerRef } = storeToRefs(globalStore)
20
+ const { height: headerHeight } = useElementSize(headerRef)
21
+ const scroll = useScroll(document)
22
+
23
+ const show = computed(() => {
24
+ return scroll.y.value > headerHeight.value
25
+ })
26
+ </script>
27
+
28
+ <template>
29
+ <div class="inline-flex gap-2 sticky top-15 inset-0 rounded-2" :class="[show && 'bg-white bg-opacity-85 dark:bg-black dark:bg-opacity-80 z-100']">
30
+ <div v-for="(item) in layouts" :key="item.layout" class="p-2 rounded-full cursor-pointer" :class="[layout === item.layout && 'text-primary']" @click="layout = item.layout">
31
+ <div class="text-size-xl" :class="item.icon" />
32
+ </div>
33
+ </div>
34
+ </template>
35
+
36
+ <style lang="scss" scoped></style>
@@ -0,0 +1,17 @@
1
+ <script lang="ts" setup>
2
+ import * as addonAlgolia from 'valaxy-addon-algolia'
3
+ import { isEmptyAddon } from 'valaxy'
4
+ import { whenever } from '@vueuse/core'
5
+
6
+ if (isEmptyAddon(addonAlgolia))
7
+ throw new Error('Algolia addon is not installed')
8
+
9
+ const { loaded, load, dispatchEvent } = addonAlgolia.useAddonAlgolia()
10
+
11
+ whenever(loaded, dispatchEvent)
12
+ </script>
13
+
14
+ <template>
15
+ <AlgoliaSearchBox v-if="loaded" class="VPNavBarSearch" />
16
+ <HairySearchBtnDisplay v-else @click="load()" />
17
+ </template>
@@ -0,0 +1,10 @@
1
+ <script lang="ts" setup>
2
+ import { ref } from 'vue'
3
+
4
+ const visible = ref(false)
5
+ </script>
6
+
7
+ <template>
8
+ <HairySearchBtnDisplay @click="visible = true" />
9
+ <HairyFuseSearchDialog v-model:visible="visible" />
10
+ </template>
@@ -0,0 +1,32 @@
1
+ <script lang="ts" setup>
2
+ import { ref, useModel } from 'vue'
3
+ import { onKeyDown, whenever } from '@vueuse/core'
4
+
5
+ const props = defineProps<{
6
+ visible: boolean
7
+ }>()
8
+ const visible = useModel(props, 'visible')
9
+
10
+ const text = ref('')
11
+
12
+ onKeyDown('Escape', () => {
13
+ if (!visible.value)
14
+ return
15
+ visible.value = false
16
+ })
17
+ whenever(() => !visible.value, () => {
18
+ text.value = ''
19
+ })
20
+ </script>
21
+
22
+ <template>
23
+ <div v-if="visible" role="button" class="DocSearch DocSearch-Container " @click="visible = false">
24
+ <div class="DocSearch-Modal" style="--docsearch-vh: 5.5200000000000005px;" @click.stop>
25
+ <HairyFuseSearchHeader v-model:text="text" v-model:visible="visible" />
26
+ <HairyFuseSearchDropdown v-model:visible="visible" :text="text" />
27
+ <HairyFuseSearchFooter />
28
+ </div>
29
+ </div>
30
+ </template>
31
+
32
+ <style lang="scss" scoped></style>
@@ -0,0 +1,77 @@
1
+ <script lang="ts" setup>
2
+ import { ref, toRef, useModel, watch } from 'vue'
3
+ import { useRouter } from 'vue-router'
4
+ import { onKeyDown } from '@vueuse/core'
5
+ import { useFuseParsed } from '../../composables'
6
+
7
+ const props = defineProps<{
8
+ text: string
9
+ visible: boolean
10
+ }>()
11
+ const visible = useModel(props, 'visible')
12
+
13
+ const router = useRouter()
14
+
15
+ const input = toRef(props, 'text')
16
+
17
+ const { results } = useFuseParsed(input)
18
+
19
+ function navigation(link: string) {
20
+ router.push(link)
21
+ visible.value = false
22
+ }
23
+ const selected = ref(0)
24
+
25
+ onKeyDown('ArrowDown', () => {
26
+ if (!results.value.length || selected.value === results.value.length - 1)
27
+ return
28
+ selected.value++
29
+ })
30
+ onKeyDown('ArrowUp', () => {
31
+ if (!results.value.length || selected.value === 0)
32
+ return
33
+ selected.value--
34
+ })
35
+ onKeyDown('Enter', () => {
36
+ if (!results.value.length)
37
+ return
38
+ navigation(results.value[selected.value].item.link)
39
+ visible.value = false
40
+ })
41
+ watch(results, () => selected.value = 0)
42
+ </script>
43
+
44
+ <template>
45
+ <div class="DocSearch-Dropdown">
46
+ <div class="DocSearch-Dropdown-Container">
47
+ <section v-if="results.length" class="DocSearch-Hits">
48
+ <div class="DocSearch-Hit-source">
49
+ Recent
50
+ </div>
51
+ <ul id="docsearch-list" role="listbox" aria-labelledby="docsearch-label">
52
+ <HairyFuseSearchHit
53
+ v-for="({ item }, index) of results" :key="index"
54
+ :title="item.title"
55
+ :selected="selected === index"
56
+ :excerpt="item.excerpt"
57
+ :path="item.link"
58
+ @click="navigation(item.link)"
59
+ @hover="selected = index"
60
+ />
61
+ </ul>
62
+ </section>
63
+ <div v-else-if="!text" class="DocSearch-StartScreen">
64
+ <p class="DocSearch-Help">
65
+ No recent searches
66
+ </p>
67
+ </div>
68
+ <div v-else class="DocSearch-NoResults">
69
+ <div class="DocSearch-Screen-Icon">
70
+ <svg width="40" height="40" viewBox="0 0 20 20" fill="none" fill-rule="evenodd" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><path d="M15.5 4.8c2 3 1.7 7-1 9.7h0l4.3 4.3-4.3-4.3a7.8 7.8 0 01-9.8 1m-2.2-2.2A7.8 7.8 0 0113.2 2.4M2 18L18 2" /></svg>
71
+ </div><p class="DocSearch-Title">
72
+ No results for "<strong>{{ text }}</strong>"
73
+ </p>
74
+ </div>
75
+ </div>
76
+ </div>
77
+ </template>
@@ -0,0 +1,28 @@
1
+ <script lang="ts" setup>
2
+ </script>
3
+
4
+ <template>
5
+ <footer class="DocSearch-Footer">
6
+ <div class="DocSearch-Logo">
7
+ <a class="flex items-center text-black dark:text-white" target="_blank" href="https://www.fusejs.io/">
8
+ <span mr-2 class="DocSearch-Label">Search by</span>
9
+ <img mr-1 w-6 h-6 src="https://www.fusejs.io/assets/img/logo.png">
10
+ <span>Fuse.js</span>
11
+ </a>
12
+ </div>
13
+ <ul class="DocSearch-Commands">
14
+ <li><kbd class="DocSearch-Commands-Key"><svg width="15" height="15" aria-label="Enter key" role="img"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.2"><path d="M12 3.53088v3c0 1-1 2-2 2H4M7 11.53088l-3-3 3-3" /></g></svg></kbd><span class="DocSearch-Label">to select</span></li><li><kbd class="DocSearch-Commands-Key"><svg width="15" height="15" aria-label="Arrow down" role="img"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.2"><path d="M7.5 3.5v8M10.5 8.5l-3 3-3-3" /></g></svg></kbd><kbd class="DocSearch-Commands-Key"><svg width="15" height="15" aria-label="Arrow up" role="img"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.2"><path d="M7.5 11.5v-8M10.5 6.5l-3-3-3 3" /></g></svg></kbd><span class="DocSearch-Label">to navigate</span></li><li><kbd class="DocSearch-Commands-Key"><svg width="15" height="15" aria-label="Escape key" role="img"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.2"><path d="M13.6167 8.936c-.1065.3583-.6883.962-1.4875.962-.7993 0-1.653-.9165-1.653-2.1258v-.5678c0-1.2548.7896-2.1016 1.653-2.1016.8634 0 1.3601.4778 1.4875 1.0724M9 6c-.1352-.4735-.7506-.9219-1.46-.8972-.7092.0246-1.344.57-1.344 1.2166s.4198.8812 1.3445.9805C8.465 7.3992 8.968 7.9337 9 8.5c.032.5663-.454 1.398-1.4595 1.398C6.6593 9.898 6 9 5.963 8.4851m-1.4748.5368c-.2635.5941-.8099.876-1.5443.876s-1.7073-.6248-1.7073-2.204v-.4603c0-1.0416.721-2.131 1.7073-2.131.9864 0 1.6425 1.031 1.5443 2.2492h-2.956" /></g></svg></kbd><span class="DocSearch-Label">to close</span></li>
15
+ </ul>
16
+ </footer>
17
+ </template>
18
+
19
+ <style>
20
+ .cls-1,
21
+ .cls-2 {
22
+ fill: #003dff;
23
+ }
24
+
25
+ .cls-2 {
26
+ fill-rule: evenodd;
27
+ }
28
+ </style>
@@ -0,0 +1,30 @@
1
+ <script lang="ts" setup>
2
+ import { useModel } from 'vue'
3
+
4
+ const props = defineProps<{
5
+ text: string
6
+ visible: boolean
7
+ }>()
8
+
9
+ const text = useModel(props, 'text')
10
+ const visible = useModel(props, 'visible')
11
+ </script>
12
+
13
+ <template>
14
+ <header class="DocSearch-SearchBar">
15
+ <div class="DocSearch-Form">
16
+ <label id="docsearch-label" class="DocSearch-MagnifierLabel" for="docsearch-input">
17
+ <svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round" /></svg>
18
+ </label>
19
+ <input id="docsearch-input" v-model="text" class="DocSearch-Input" aria-autocomplete="both" aria-labelledby="docsearch-label" autocomplete="off" autocorrect="off" autocapitalize="off" enterkeyhint="go" spellcheck="false" autofocus="true" placeholder="Search docs" maxlength="64" type="search" aria-activedescendant="docsearch-item-0" aria-controls="docsearch-list">
20
+ <button type="reset" title="Clear the query" class="DocSearch-Reset" aria-label="Clear the query" :hidden="!text" @click="text = ''">
21
+ <svg width="20" height="20" viewBox="0 0 20 20"><path d="M10 10l5.09-5.09L10 10l5.09 5.09L10 10zm0 0L4.91 4.91 10 10l-5.09 5.09L10 10z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round" /></svg>
22
+ </button>
23
+ </div>
24
+ <button class="DocSearch-Cancel" type="reset" aria-label="Cancel" @click="visible = false">
25
+ Cancel
26
+ </button>
27
+ </header>
28
+ </template>
29
+
30
+ <style lang="scss" scoped></style>
@@ -0,0 +1,52 @@
1
+ <script lang="ts" setup>
2
+ import { defineEmits, ref } from 'vue'
3
+ import { useElementHover, whenever } from '@vueuse/core'
4
+
5
+ withDefaults(
6
+ defineProps<{
7
+ selected: boolean
8
+ title: string
9
+ excerpt: string
10
+ path: string
11
+ history?: boolean
12
+ }>(),
13
+ {
14
+ selected: false,
15
+ },
16
+ )
17
+
18
+ const emit = defineEmits(['hover'])
19
+
20
+ const itemRef = ref()
21
+
22
+ whenever(useElementHover(itemRef), () => emit('hover'))
23
+ </script>
24
+
25
+ <template>
26
+ <li id="docsearch-item-0" ref="itemRef" class="DocSearch-Hit" role="option" :aria-selected="selected">
27
+ <a :href="path" onclick="return false">
28
+ <div class="DocSearch-Hit-Container">
29
+ <div class="DocSearch-Hit-icon">
30
+ <svg v-if="history" width="20" height="20" viewBox="0 0 20 20"><g stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"><path d="M3.18 6.6a8.23 8.23 0 1112.93 9.94h0a8.23 8.23 0 01-11.63 0" /><path d="M6.44 7.25H2.55V3.36M10.45 6v5.6M10.45 11.6L13 13" /></g></svg>
31
+ <svg v-else width="20" height="20" viewBox="0 0 20 20"><path d="M17 5H3h14zm0 5H3h14zm0 5H3h14z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linejoin="round" /></svg>
32
+ </div>
33
+ <div class="DocSearch-Hit-content-wrapper">
34
+ <span class="DocSearch-Hit-title">{{ title }}</span>
35
+ <span class="DocSearch-Hit-path">{{ excerpt }}</span>
36
+ </div>
37
+ <div v-if="history" class="DocSearch-Hit-action">
38
+ <button class="DocSearch-Hit-action-button" title="Save this search" type="submit">
39
+ <svg width="20" height="20" viewBox="0 0 20 20"><path d="M10 14.2L5 17l1-5.6-4-4 5.5-.7 2.5-5 2.5 5 5.6.8-4 4 .9 5.5z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linejoin="round" /></svg>
40
+ </button>
41
+ </div>
42
+ <div v-if="history" class="DocSearch-Hit-action">
43
+ <button class="DocSearch-Hit-action-button" title="Remove this search from history" type="submit"><svg width="20" height="20" viewBox="0 0 20 20"><path d="M10 10l5.09-5.09L10 10l5.09 5.09L10 10zm0 0L4.91 4.91 10 10l-5.09 5.09L10 10z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round" /></svg>
44
+ </button>
45
+ </div>
46
+ <div class="DocSearch-Hit-action">
47
+ <svg class="DocSearch-Hit-Select-Icon" width="20" height="20" viewBox="0 0 20 20"><g stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"><path d="M18 3v4c0 2-2 4-4 4H2" /><path d="M8 17l-6-6 6-6" /></g></svg>
48
+ </div>
49
+ </div>
50
+ </a>
51
+ </li>
52
+ </template>