valaxy-theme-hairy 0.2.2 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) 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 +17 -0
  5. package/components/{HairyUserPopup.vue → HairyDrawer.vue} +16 -16
  6. package/components/HairyFooter.vue +12 -9
  7. package/components/HairyHeader.vue +10 -9
  8. package/components/HairyImage.vue +3 -2
  9. package/components/HairyImageGroup.vue +12 -16
  10. package/components/HairyNavbar.vue +56 -0
  11. package/components/HairyPageArchives.vue +59 -0
  12. package/components/HairyPageTags.vue +48 -0
  13. package/components/{HairyPostList.vue → HairyPosts.vue} +3 -3
  14. package/components/{HairyNavSearch.vue → HairySearch.vue} +23 -87
  15. package/components/{HairyUserCard.vue → HairySidebar.vue} +4 -4
  16. package/components/HairyTabbar.vue +56 -0
  17. package/components/PageTags.vue +48 -0
  18. package/components/ValaxyMain.vue +3 -3
  19. package/components/navbar/HairyNav.vue +16 -0
  20. package/components/navbar/HairyNavExpand.vue +12 -0
  21. package/components/navbar/HairyNavItem.vue +35 -0
  22. package/components/navbar/HairyNavbarBackground.vue +7 -0
  23. package/components/navbar/HairyNavbarSearch.vue +8 -0
  24. package/components/{HairyNavTitle.vue → navbar/HairyNavbarTitle.vue} +5 -3
  25. package/components/navbar/HairyNavbarToggleDark.vue +22 -0
  26. package/components/{HairyBreadcrumb.vue → parts/HairyBreadcrumb.vue} +2 -2
  27. package/components/{HairyBreadcrumbItem.vue → parts/HairyBreadcrumbItem.vue} +1 -4
  28. package/components/{lib/fish.js → parts/HairyFootFish.js} +5 -7
  29. package/components/parts/HairyFootFish.vue +38 -0
  30. package/components/{HairyPostTitle.vue → parts/HairyHeadHero.vue} +6 -5
  31. package/components/{HairyWaves.vue → parts/HairyHeadWaves.vue} +5 -5
  32. package/components/parts/HairyImageGlobal.vue +51 -0
  33. package/components/{HairyImageViewer.vue → parts/HairyImageViewer.vue} +5 -4
  34. package/components/parts/HairyLink.vue +21 -0
  35. package/components/{HairyMenu.vue → parts/HairyMenu.vue} +2 -1
  36. package/components/{HairyMenuItem.vue → parts/HairyMenuItem.vue} +11 -4
  37. package/components/parts/HairyOutline.vue +99 -0
  38. package/components/parts/HairyOutlineItem.vue +48 -0
  39. package/components/{HairySocialLinks.vue → parts/HairySocialLinks.vue} +2 -2
  40. package/components/{HairyTimelinePostItem.vue → parts/HairyTimelineContent.vue} +7 -8
  41. package/components/parts/HairyUserNav.vue +95 -0
  42. package/components/{article-layout → posts}/HairyArticleImage.vue +18 -19
  43. package/components/{article-layout → posts}/HairyArticleSeries.vue +8 -5
  44. package/components/{article-layout → posts}/HairyArticleText.vue +11 -4
  45. package/components/posts/HairyPostFooter.vue +15 -0
  46. package/components/{article-layout → posts}/HairyPostImageList.vue +4 -5
  47. package/components/{article-layout → posts}/HairyPostTextsList.vue +0 -1
  48. package/components/posts/HairyPostToggleLayout.vue +36 -0
  49. package/components/third/HairyAlgoliaSearch.vue +17 -0
  50. package/components/third/HairyFuseSearch.vue +10 -0
  51. package/components/third/HairyFuseSearchDialog.vue +32 -0
  52. package/components/third/HairyFuseSearchDropdown.vue +77 -0
  53. package/components/third/HairyFuseSearchFooter.vue +28 -0
  54. package/components/third/HairyFuseSearchHeader.vue +30 -0
  55. package/components/third/HairyFuseSearchHit.vue +52 -0
  56. package/components/third/HairySearchBtnDisplay.vue +29 -0
  57. package/components/third/HairySearchBtnInput.vue +20 -0
  58. package/components/third/HairySearchBtnKeys.vue +19 -0
  59. package/components/{HairyCarousel.vue → third/HairySwiperCarousel.vue} +6 -6
  60. package/{hooks/useYearArchives.ts → composables/archives.ts} +4 -3
  61. package/composables/category.ts +43 -0
  62. package/composables/config.ts +11 -0
  63. package/composables/dark.ts +13 -0
  64. package/composables/fuse.ts +60 -0
  65. package/composables/index.ts +8 -0
  66. package/composables/layout.ts +16 -0
  67. package/composables/outline.ts +49 -0
  68. package/composables/tags.ts +36 -0
  69. package/layouts/archive-month.vue +13 -0
  70. package/layouts/archive-year.vue +13 -0
  71. package/layouts/archives.vue +9 -9
  72. package/layouts/categories.vue +11 -4
  73. package/layouts/default.vue +9 -3
  74. package/layouts/home.vue +28 -18
  75. package/layouts/post.vue +42 -36
  76. package/layouts/tag.vue +8 -4
  77. package/layouts/tags.vue +12 -4
  78. package/{modules → library}/loading.ts +18 -6
  79. package/{modules → library}/scroll.ts +3 -2
  80. package/locales/zh-CN.yml +0 -2
  81. package/node/images/default.json +139 -0
  82. package/node/images/index.ts +46 -0
  83. package/node/index.ts +2 -0
  84. package/node/theme/index.ts +78 -0
  85. package/package.json +22 -28
  86. package/pages/archives/[year]/[month]/index.vue +15 -18
  87. package/pages/archives/[year]/index.vue +20 -20
  88. package/pages/archives/index.vue +1 -54
  89. package/pages/categories/{[...categories].vue → [...its].vue} +29 -36
  90. package/pages/index.vue +1 -1
  91. package/pages/page/[page].vue +2 -2
  92. package/pages/tags/[tag]/index.vue +38 -0
  93. package/pages/tags/index.vue +1 -36
  94. package/setup/main.ts +1 -1
  95. package/store/index.ts +1 -0
  96. package/store/modules/global.ts +12 -0
  97. package/styles/components/index.scss +4 -0
  98. package/styles/{markdown.scss → components/markdown.scss} +2 -1
  99. package/styles/components/nprogress.scss +16 -0
  100. package/styles/css-vars.scss +11 -0
  101. package/styles/element-plus/tabs.scss +1 -1
  102. package/styles/element-plus/timeline.scss +1 -1
  103. package/styles/global.scss +39 -0
  104. package/styles/index.scss +4 -73
  105. package/tsconfig.json +27 -0
  106. package/types/index.d.ts +163 -0
  107. package/unocss.config.ts +5 -1
  108. package/utils/index.ts +21 -39
  109. package/valaxy.config.ts +21 -24
  110. package/@types/markdown-it.d.ts +0 -1
  111. package/@types/markdown-toc.d.ts +0 -1
  112. package/@types/types.d.ts +0 -1
  113. package/@types/valaxy.d.ts +0 -10
  114. package/components/HairyAlgoliaSearchBox.vue +0 -118
  115. package/components/HairyBackToTop.vue +0 -72
  116. package/components/HairyDivider.vue +0 -0
  117. package/components/HairyFooterFish.vue +0 -29
  118. package/components/HairyLayout.vue +0 -28
  119. package/components/HairyLink.vue +0 -10
  120. package/components/HairyLinks.vue +0 -69
  121. package/components/HairyMeting.vue +0 -19
  122. package/components/HairyNav.vue +0 -42
  123. package/components/HairyNavBackground.vue +0 -7
  124. package/components/HairyNavMenu.vue +0 -11
  125. package/components/HairyNavToggleDark.vue +0 -16
  126. package/components/HairyPostToggleLayout.vue +0 -33
  127. package/components/HairyToc.vue +0 -135
  128. package/components/HairyUserNav.vue +0 -64
  129. package/components/HairyUserTab.vue +0 -40
  130. package/components/HairyWaline.vue +0 -44
  131. package/hooks/setupDefaultDark.ts +0 -11
  132. package/hooks/useCategory.ts +0 -18
  133. package/hooks/useCategoryPost.ts +0 -21
  134. package/hooks/useContext.ts +0 -13
  135. package/hooks/useHeaderHeight.ts +0 -9
  136. package/hooks/usePostLayout.ts +0 -16
  137. package/images.json +0 -140
  138. package/index.d.ts +0 -100
  139. package/layouts/hairy.vue +0 -36
  140. package/layouts/month.vue +0 -6
  141. package/layouts/year.vue +0 -6
  142. package/node/addon-hairy.ts +0 -36
  143. package/node/addon-images.ts +0 -61
  144. package/node/addon-meting.ts +0 -13
  145. package/node/addon-statistics.ts +0 -19
  146. package/node/addon-toc.ts +0 -20
  147. package/node/utils.ts +0 -20
  148. package/pages/tags/[tag].vue +0 -40
  149. package/utils/createContext.ts +0 -40
  150. package/utils/fonts.ts +0 -15
  151. /package/components/{HairyUserStats.vue → parts/HairyUserStats.vue} +0 -0
  152. /package/components/{article-layout → posts}/HairyArticleTop.vue +0 -0
  153. /package/{modules → library}/loading.scss +0 -0
  154. /package/{shims.d.ts → node/images/shims.d.ts} +0 -0
  155. /package/styles/{aplayer.scss → components/aplayer.scss} +0 -0
  156. /package/styles/{scrollbar.scss → components/scrollbar.scss} +0 -0
@@ -1,19 +0,0 @@
1
- <script lang="ts" setup>
2
- import { useAplayer, useThemeConfig } from 'valaxy'
3
-
4
- import type { HairyTheme } from 'valaxy-theme-hairy'
5
-
6
- const config = useThemeConfig<HairyTheme>()
7
-
8
- if (config.value.meting)
9
- useAplayer()
10
- </script>
11
-
12
- <template>
13
- <meting-js
14
- v-if="config.meting && config.meting.fixed !== false"
15
- v-bind="config.meting"
16
- :fixed="true"
17
- >
18
- </meting-js>
19
- </template>
@@ -1,42 +0,0 @@
1
- <script lang="ts" setup>
2
- import { useScroll, whenever } from '@vueuse/core'
3
- import { computed, ref } from 'vue'
4
- import { useHeaderHeight } from '../hooks/useHeaderHeight'
5
-
6
- const headerHeight = useHeaderHeight()
7
- const cache = ref<'top' | 'bottom'>('top')
8
- const scroll = useScroll(document)
9
-
10
- whenever(() => scroll.directions.top, () => {
11
- cache.value = 'top'
12
- })
13
- whenever(() => scroll.directions.bottom, () => {
14
- cache.value = 'bottom'
15
- })
16
-
17
- const show = computed(() => {
18
- return scroll.y.value < (headerHeight.value / 2) || cache.value === 'top'
19
- })
20
- </script>
21
-
22
- <template>
23
- <div class="HairyNav fixed w-full h-3.125rem lt-sm:h-3.5rem top-0 z-20 opacity-0 transition-opacity duration-200" :class="[show && 'opacity-100']">
24
- <div class="mx-auto breakpoint flex relative z-1 h-full">
25
- <div class="flex items-center lt-sm:order-1 lt-sm:flex-1 justify-center">
26
- <HairyNavTitle />
27
- </div>
28
- <div class="flex items-center sm:flex-1">
29
- <HairyNavMenu class="sm:hidden pl-2 pr-13" />
30
- <HairyMenu class="lt-sm:hidden" />
31
- </div>
32
- <div class="flex-center order-1">
33
- <HairyNavToggleDark />
34
- <HairyNavSearch />
35
- </div>
36
- </div>
37
- <HairyNavBackground />
38
- </div>
39
- </template>
40
-
41
- <style>
42
- </style>
@@ -1,7 +0,0 @@
1
- <template>
2
- <div class="HairyNavBackground transition-colors absolute inset-0 bg-white bg-opacity-85 dark:bg-black dark:bg-opacity-80 blur-5" />
3
- </template>
4
-
5
- <style>
6
-
7
- </style>
@@ -1,11 +0,0 @@
1
- <script lang="ts" setup>
2
- import { useContext } from '../hooks/useContext'
3
-
4
- const { drawerShow } = useContext()
5
- </script>
6
-
7
- <template>
8
- <button class="yun-icon-btn lt-sm:text-size-xl" @click="drawerShow = true">
9
- <div i="ri-menu-fill" />
10
- </button>
11
- </template>
@@ -1,16 +0,0 @@
1
- <script lang="ts" setup>
2
- import { useI18n } from 'vue-i18n'
3
- import { computed } from 'vue'
4
- import { isDark, toggleDark } from 'valaxy'
5
-
6
- const { t } = useI18n()
7
- const themeTitle = computed(() => {
8
- return isDark.value ? t('button.toggle_light') : t('button.toggle_dark')
9
- })
10
- </script>
11
-
12
- <template>
13
- <button class="yun-icon-btn bg-light-1 p-1 dark:bg-transparent rounded-5 lt-sm:text-size-xl" :title="themeTitle" :style="{ color: isDark ? '' : '#f1cb64' }" @click="toggleDark()">
14
- <div i="ri-sun-line dark:ri-moon-line" />
15
- </button>
16
- </template>
@@ -1,33 +0,0 @@
1
- <script lang="ts" setup>
2
- import { useScroll } from '@vueuse/core'
3
- import { computed } from 'vue'
4
- import { usePostLayout } from '../hooks/usePostLayout'
5
- import { useHeaderHeight } from '../hooks/useHeaderHeight'
6
- import type { HairyPostLayout } from '..'
7
-
8
- const layout = usePostLayout()
9
- const layouts = [
10
- { layout: 'image:slice:reverse' as HairyPostLayout, icon: 'i-fluent-text-align-distributed-24-filled' },
11
- { layout: 'image:slice' as HairyPostLayout, icon: 'i-fluent-text-align-left-16-filled' },
12
- { layout: 'image' as HairyPostLayout, icon: 'i-fluent-text-align-justify-20-filled' },
13
- { layout: 'markdown' as HairyPostLayout, icon: 'i-fluent-markdown-20-filled' },
14
- { layout: 'text' as HairyPostLayout, icon: 'i-fluent-code-text-16-filled' },
15
- ]
16
-
17
- const headerHeight = useHeaderHeight()
18
- const scroll = useScroll(document)
19
-
20
- const show = computed(() => {
21
- return scroll.y.value > headerHeight.value
22
- })
23
- </script>
24
-
25
- <template>
26
- <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']">
27
- <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">
28
- <div class="text-size-xl" :class="item.icon" />
29
- </div>
30
- </div>
31
- </template>
32
-
33
- <style lang="scss" scoped></style>
@@ -1,135 +0,0 @@
1
- <script setup lang="ts">
2
- import { computed, ref } from 'vue'
3
- import { useI18n } from 'vue-i18n'
4
- import type { Header } from 'valaxy'
5
- import {
6
- resolveHeaders,
7
- useActiveAnchor,
8
- useFrontmatter,
9
- useThemeConfig,
10
- } from 'valaxy'
11
-
12
- const props = defineProps<{ headers?: Header[] }>()
13
-
14
- const frontmatter = useFrontmatter()
15
- const themeConfig = useThemeConfig()
16
-
17
- const { locale } = useI18n()
18
- const container = ref()
19
- const marker = ref()
20
-
21
- useActiveAnchor(container, marker)
22
-
23
- const resolvedHeaders = computed(() => {
24
- return resolveHeaders(props.headers || frontmatter.value['it-toc'])
25
- })
26
-
27
- function handleClick({ target: el }: Event) {
28
- const id = `#${(el as HTMLAnchorElement).href!.split('#')[1]}`
29
- const heading = document.querySelector(decodeURIComponent(id)) as HTMLAnchorElement
30
- heading?.focus()
31
- }
32
- </script>
33
-
34
- <template>
35
- <div v-show="resolvedHeaders.length" ref="container" class="animate__animated animate__fadeIn">
36
- <div class="content">
37
- <div class="outline-title">
38
- {{ themeConfig.outlineTitle || 'On this page' }}
39
- </div>
40
-
41
- <div ref="marker" class="outline-marker" />
42
-
43
- <nav aria-labelledby="doc-outline-aria-label">
44
- <span id="doc-outline-aria-label" class="visually-hidden">
45
- Table of Contents for current page
46
- </span>
47
-
48
- <ul class="va-toc relative z-1">
49
- <li
50
- v-for="{ text, link, children, hidden, lang } in resolvedHeaders"
51
- v-show="!hidden"
52
- :key="link"
53
- class="va-toc-item"
54
- :lang="lang || locale"
55
- >
56
- <a class="outline-link" :href="link" @click="handleClick">
57
- {{ text }}
58
- </a>
59
- <ul v-if="children && frontmatter.outline === 'deep'">
60
- <li v-for="item in children" v-show="!item.hidden" :key="item.link" :lang="lang || locale">
61
- <a class="outline-link" p="l-3" :href="link" @click="handleClick">
62
- {{ item.text }}
63
- </a>
64
- </li>
65
- </ul>
66
- </li>
67
- </ul>
68
- </nav>
69
- </div>
70
- </div>
71
- </template>
72
-
73
- <style lang="scss" scoped>
74
- .va-toc {
75
- text-align: left;
76
-
77
- .va-toc-item {
78
- color: var(--va-c-text-light);
79
- }
80
- }
81
-
82
- .content {
83
- position: relative;
84
- padding-left: 16px;
85
- font-size: 14px;
86
- text-align: left;
87
- }
88
-
89
- .outline-marker {
90
- position: absolute;
91
- top: 32px;
92
- left: -2px;
93
- z-index: 0;
94
- opacity: 0;
95
- width: 4px;
96
- height: 18px;
97
- background-color: var(--va-c-brand);
98
- transition: top 0.25s cubic-bezier(0, 1, 0.5, 1), background-color 0.5s, opacity 0.25s;
99
- border-top-right-radius: 2px;
100
- border-bottom-right-radius: 2px;
101
- }
102
-
103
- .outline-title {
104
- letter-spacing: 0.4px;
105
- line-height: 28px;
106
- font-size: 14px;
107
- font-weight: 600;
108
- }
109
-
110
- .outline-link {
111
- display: block;
112
- line-height: 28px;
113
- color: var(--va-c-text-light);
114
- white-space: nowrap;
115
- overflow: hidden;
116
- text-overflow: ellipsis;
117
- transition: color 0.5s;
118
- }
119
-
120
- .outline-link:hover,
121
- .outline-link.active {
122
- color: var(--va-c-brand);
123
- transition: color 0.25s;
124
- }
125
-
126
- .visually-hidden {
127
- position: absolute;
128
- width: 1px;
129
- height: 1px;
130
- white-space: nowrap;
131
- clip: rect(0 0 0 0);
132
- clip-path: inset(50%);
133
- overflow: hidden;
134
- }
135
- </style>
@@ -1,64 +0,0 @@
1
- <script lang="ts" setup>
2
- import { usePostList, useTag } from 'valaxy'
3
- import { computed } from 'vue'
4
- import { toArr } from '../utils'
5
- const posts = usePostList()
6
- const tags = useTag()
7
-
8
- const total = computed(() => {
9
- const categories = posts.value.map(v => toArr(v.categories || [])).filter(v => v.length)
10
- const maps: string[] = []
11
- for (const category of categories) {
12
- let caches: string[] = []
13
- for (const iterator of category) {
14
- caches.push(iterator)
15
- maps.push(caches.join('-'))
16
- }
17
- caches = []
18
- }
19
- return new Set(maps).size
20
- })
21
- </script>
22
-
23
- <template>
24
- <div class="flex justify-center mt-2">
25
- <HairyUserStats :count="posts.length" @click="$router.push('/archives/')">
26
- 文章
27
- </HairyUserStats>
28
- <div class="w-1px bg-gray bg-opacity-50" />
29
- <HairyUserStats :count="total" @click="$router.push('/categories/')">
30
- 分类
31
- </HairyUserStats>
32
- <div class="w-1px bg-gray bg-opacity-50" />
33
- <HairyUserStats :count="tags.size" @click="$router.push('/tags/')">
34
- 标签
35
- </HairyUserStats>
36
- </div>
37
- <HairySocialLinks class="mt-5" />
38
- <HairyMenu class="HairyUserMenu mt-5 flex-col h-auto" />
39
- </template>
40
-
41
- <style lang="scss">
42
- .HairyUserMenu {
43
- .HairyMenuItem {
44
- padding: 2px;
45
- width: 100%;
46
- border: 1px solid transparent;
47
- > div {
48
- justify-content: center;
49
- }
50
- }
51
-
52
- .HairyMenuItem:hover,
53
- .HairyMenuItem.active {
54
- border-top: 1px solid var(--hy-c-primary);
55
- border-bottom: 1px solid var(--hy-c-primary);
56
- }
57
- .HairyMenuItem.active + .HairyMenuItem {
58
- border-top-color: transparent;
59
- }
60
- .HairyMenuItem:hover + .HairyMenuItem {
61
- border-top-color: transparent;
62
- }
63
- }
64
- </style>
@@ -1,40 +0,0 @@
1
- <script lang="ts" setup>
2
- import { ElTabPane, ElTabs } from 'element-plus/es/components/tabs/index'
3
- import 'element-plus/es/components/tabs/style/index'
4
- import 'element-plus/es/components/tab-pane/style/index'
5
- import { provide, ref } from 'vue'
6
- const active = ref('aside')
7
- provide('HairyUserTab:active', active)
8
- </script>
9
-
10
- <template>
11
- <el-tabs v-model="active" class="pt-3">
12
- <el-tab-pane name="aside">
13
- <template #label>
14
- <div class="flex items-center">
15
- <div class="i-ri-list-check-2" />
16
- <span class="ml-1">Aside</span>
17
- </div>
18
- </template>
19
- <HairyToc />
20
- </el-tab-pane>
21
- <el-tab-pane label="Series" name="series">
22
- <template #label>
23
- <div class="flex items-center gap-1">
24
- <div class="i-ri-flow-chart" />
25
- <span class="ml-1">Series</span>
26
- </div>
27
- </template>
28
- <HairyArticleSeries />
29
- </el-tab-pane>
30
- <el-tab-pane label="User" name="user">
31
- <template #label>
32
- <div class="flex items-center gap-1">
33
- <div class="i-ri-user-line" />
34
- <span class="ml-1">User</span>
35
- </div>
36
- </template>
37
- <HairyUserCard />
38
- </el-tab-pane>
39
- </el-tabs>
40
- </template>
@@ -1,44 +0,0 @@
1
- <script lang="ts" setup>
2
- import { useConfig } from 'valaxy'
3
- import { useWaline } from 'valaxy/client/composables/comments/waline'
4
- // 读取用户配置
5
- const config = useConfig()
6
- // 挂载 Waline
7
- useWaline({
8
- el: '#waline',
9
- emoji: [
10
- '//unpkg.com/@waline/emojis@1.0.1/weibo',
11
- '//unpkg.com/@waline/emojis@1.0.1/bilibili',
12
- ],
13
- ...config.value.comment.waline,
14
- })
15
- </script>
16
-
17
- <!-- Also, the documentation doesn't state that we need to install @waline/client, which I think is also an issue -->
18
- <template>
19
- <!-- waline html 挂载点,将其写入布局中 -->
20
- <div id="waline" w="full" />
21
- </template>
22
-
23
- <style lang="scss">
24
- // 可以在此处覆盖 waline 样式
25
- #waline {
26
- --waline-theme-color: var(--hy-c-primary);
27
- --waline-active-color: var(--hy-c-primary-dark)
28
- }
29
- .wl-editor {
30
- padding: 4px;
31
- width: calc(100% - 1rem - 8px);
32
- }
33
- .wl-emoji-popup {
34
- border-bottom: none !important;
35
- z-index: 1000;
36
- }
37
- .wl-emoji-popup .wl-tabs {
38
- height: auto !important;
39
- overflow-x: auto !important;
40
- padding: 0 !important;
41
- margin-left: -1px;
42
- margin-right: -1px;
43
- }
44
- </style>
@@ -1,11 +0,0 @@
1
- import { toggleDark, useThemeConfig } from 'valaxy'
2
- import { useLocalStorage } from '@vueuse/core'
3
-
4
- export function setupDefaultDark() {
5
- const theme = useThemeConfig()
6
- const local = useLocalStorage('--hairy-mode', '')
7
- if (theme.value.mode && !local.value) {
8
- local.value = theme.value.mode
9
- toggleDark()
10
- }
11
- }
@@ -1,18 +0,0 @@
1
- import type { ParentCategory, PostCategory } from 'valaxy'
2
- import { useCategory } from 'valaxy'
3
- import type { MaybeRef } from '@vueuse/core'
4
- import { computed, unref } from 'vue'
5
-
6
- export function useCurrentCategory(categories: MaybeRef<string[]>) {
7
- const all = useCategory()
8
- return computed(() => {
9
- let parent: ParentCategory & Partial<PostCategory> = all
10
- for (const category of unref(categories)) {
11
- for (const [key, value] of parent.children) {
12
- if (key === category)
13
- parent = (value as ParentCategory)
14
- }
15
- }
16
- return parent
17
- })
18
- }
@@ -1,21 +0,0 @@
1
- import type { MaybeRef } from '@vueuse/shared'
2
- import { usePostList } from 'valaxy'
3
- import { isEqual } from 'lodash-es'
4
- import { computed, unref } from 'vue'
5
-
6
- export function useCategoryPost(categories: MaybeRef<string[]>) {
7
- const postList = usePostList()
8
- return computed(() => {
9
- if (!unref(categories).length)
10
- return postList.value
11
- return postList.value.filter((item) => {
12
- let target = Array.isArray(item.categories)
13
- ? item.categories
14
- : [item.categories || '']
15
- target = target.filter(Boolean)
16
- if (unref(categories)[0] === 'Uncategorized')
17
- return !target.length
18
- return isEqual(target.sort(), unref(categories).sort())
19
- }) as any
20
- })
21
- }
@@ -1,13 +0,0 @@
1
- import { ref } from 'vue'
2
- import { createSharedComposable } from '@vueuse/core'
3
-
4
- const _useContext = () => {
5
- const headerRef = ref<HTMLDivElement>()
6
- const drawerShow = ref(false)
7
- return {
8
- headerRef,
9
- drawerShow,
10
- }
11
- }
12
-
13
- export const useContext = createSharedComposable(_useContext)
@@ -1,9 +0,0 @@
1
- import { useElementSize } from '@vueuse/core'
2
- import { computed } from 'vue'
3
- import { useContext } from './useContext'
4
-
5
- export function useHeaderHeight() {
6
- const { headerRef } = useContext()
7
- const size = useElementSize(headerRef)
8
- return computed(() => size.height.value)
9
- }
@@ -1,16 +0,0 @@
1
- import { useThemeConfig } from 'valaxy'
2
- import { createSharedComposable, useStorage } from '@vueuse/core'
3
- import { computed } from 'vue'
4
- import type { HairyPostLayout, HairyTheme } from '..'
5
-
6
- const useSharedStorage = createSharedComposable(useStorage)
7
-
8
- export function usePostLayout() {
9
- const themeConfig = useThemeConfig<HairyTheme>()
10
- const cache = useSharedStorage<HairyPostLayout>('--hairy-theme:post-layout', null)
11
- const layout = computed({
12
- get: () => cache.value || themeConfig.value.post?.layout || 'image',
13
- set: value => cache.value = value,
14
- })
15
- return layout
16
- }