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
@@ -1,36 +0,0 @@
1
- import type { ResolvedValaxyOptions, ValaxyExtendConfig } from 'valaxy'
2
- import type { HairyTheme } from 'valaxy-theme-hairy'
3
-
4
- function addonHairy(options: ResolvedValaxyOptions<HairyTheme>): ValaxyExtendConfig {
5
- const safelist = options.config.themeConfig?.nav?.filter(v => v.icon)?.map(v => v.icon || '') || []
6
- return {
7
- extendMd(ctx) {
8
- if (ctx.route.meta.excerpt)
9
- ctx.route.meta.frontmatter.text = removeTags(ctx.route.meta.excerpt)
10
- },
11
- pages: {
12
- extendRoute(route) {
13
- // 改用 type, 由 theme 决定使用布局
14
- if (!route.meta.type && route.meta.layout)
15
- route.meta.type = route.meta.layout
16
-
17
- if (!route.meta.type)
18
- route.meta.type = 'default'
19
-
20
- // 清除所有 layout, 使用统一入口 hairy.vue
21
- route.meta.layout = 'hairy'
22
- },
23
- },
24
- unocss: {
25
- safelist,
26
- },
27
- }
28
- }
29
-
30
- export default addonHairy
31
-
32
- function removeTags(str = '') {
33
- let content = str.replace(/<\/?[^>]*>/g, '')// 去除标签
34
- content = content.replace(/[|]*\n/, '')// 去除行尾空格
35
- return content
36
- }
@@ -1,61 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
2
- import type { ResolvedValaxyOptions, ValaxyExtendConfig } from 'valaxy'
3
- import type { HairyTheme } from '..'
4
- import defaultImages from '../images.json'
5
-
6
- let count = 0
7
-
8
- function addonImages(options: ResolvedValaxyOptions<HairyTheme>): ValaxyExtendConfig {
9
- const hairyPrefix = '@hairy'
10
- const postConfig = options.config.themeConfig?.post
11
- const homeConfig = options.config.themeConfig?.home
12
-
13
- const isEnough = (postConfig?.images?.length || 0) > 6
14
-
15
- const inImages = isEnough ? postConfig?.images! : defaultImages
16
-
17
- const filterInImages = (type: 'large' | 'mw690') => {
18
- const inType = type === 'large' ? 'mw690' : 'large'
19
- return inImages.filter((image) => {
20
- if (image.includes('sinaimg.cn/'))
21
- return image.replace(inType, type)
22
- return image
23
- })
24
- }
25
-
26
- const postImages = isEnough ? postConfig?.images! : filterInImages('mw690')
27
- const homeImages = homeConfig?.images?.length ? homeConfig?.images : filterInImages('large')
28
-
29
- return {
30
- vite: {
31
- plugins: [
32
- {
33
- name: 'vite-plugin-hairy:image',
34
- resolveId(id) {
35
- if (id.startsWith(hairyPrefix))
36
- return id
37
- return null
38
- },
39
- load(id) {
40
- if (id === '@hairy:images:post')
41
- return `export default ${JSON.stringify(postImages)}`
42
- if (id === '@hairy:images:home')
43
- return `export default ${JSON.stringify(homeImages)}`
44
- },
45
- },
46
- ],
47
- },
48
- extendMd(ctx) {
49
- if (postImages.length >= 6) {
50
- if (!ctx.route.meta.frontmatter.image)
51
- ctx.route.meta.frontmatter.image = postImages[count]
52
- if (count <= postImages.length)
53
- count++
54
- if (count >= postImages.length)
55
- count = 0
56
- }
57
- },
58
- }
59
- }
60
-
61
- export default addonImages
@@ -1,13 +0,0 @@
1
- import type { ResolvedValaxyOptions, ValaxyExtendConfig } from 'valaxy'
2
- import type { HairyTheme } from 'valaxy-theme-hairy'
3
-
4
- function addonMeting(options: ResolvedValaxyOptions<HairyTheme>): ValaxyExtendConfig {
5
- return {
6
- extendMd(ctx) {
7
- if (options.config.themeConfig?.meting)
8
- ctx.route.meta.frontmatter.aplayer = true
9
- },
10
- }
11
- }
12
-
13
- export default addonMeting
@@ -1,19 +0,0 @@
1
- /* eslint-disable @typescript-eslint/ban-ts-comment */
2
- import fs from 'fs'
3
- import readingTime from 'reading-time'
4
- import type { ValaxyExtendConfig } from 'valaxy'
5
-
6
- function addonStatistics(): ValaxyExtendConfig {
7
- return {
8
- extendMd(ctx) {
9
- const file = fs.readFileSync(ctx.path, 'utf-8')
10
- const duration = readingTime(file)
11
- // @ts-expect-error
12
- delete duration.text
13
- ctx.route.meta.frontmatter.durations = duration
14
- ctx.route.meta.frontmatter.length = file.length
15
- },
16
- }
17
- }
18
-
19
- export default addonStatistics
package/node/addon-toc.ts DELETED
@@ -1,20 +0,0 @@
1
- import fs from 'fs'
2
- import type { ValaxyExtendConfig } from 'valaxy'
3
- import toc from 'markdown-toc'
4
-
5
- function addonToc(): ValaxyExtendConfig {
6
- return {
7
- extendMd(ctx) {
8
- if (!ctx.route.path.startsWith('/posts/'))
9
- return
10
- const file = fs.readFileSync(ctx.path, 'utf-8')
11
- ctx.route.meta.frontmatter['it-toc'] = toc(file).json.map((item: any) => ({
12
- title: item.content,
13
- level: item.lvl,
14
- slug: item.slug,
15
- }))
16
- },
17
- }
18
- }
19
-
20
- export default addonToc
package/node/utils.ts DELETED
@@ -1,20 +0,0 @@
1
- import { createDefu } from 'defu'
2
- import { isFunction } from 'lodash-es'
3
- import { mergeConfig as mergeViteConfig } from 'vite'
4
- /**
5
- * merge valaxy.config
6
- * (source, default)
7
- */
8
- export const mergeValaxyConfig = createDefu((obj: any, key, value) => {
9
- if (isFunction(obj[key]) || isFunction(value)) {
10
- obj[key] = function (...args: any[]) {
11
- obj[key]?.call(this, ...args)
12
- value?.call(this, ...args)
13
- }
14
- }
15
- if (key === 'vite') {
16
- // a deep copy and needs to be taken over
17
- obj[key] = mergeViteConfig(obj[key], value)
18
- return true
19
- }
20
- })
@@ -1,40 +0,0 @@
1
- /*
2
- * @Author: Mr'Mao https://github.com/TuiMao233
3
- * @Date: 2022-02-09 10:56:30
4
- * @LastEditors: Mr'Mao
5
- * @LastEditTime: 2022-02-26 13:47:57
6
- */
7
-
8
- import type { InjectionKey } from 'vue'
9
- import { inject, provide } from 'vue'
10
-
11
- /**
12
- * 创建上下文
13
- * @param key 控制器的 key
14
- * @param callback 控制器注入的内容
15
- * @returns
16
- */
17
- export function createContext<T>(key: string, getter: () => T) {
18
- const _key: InjectionKey<T> = Symbol(key)
19
-
20
- const _provide = () => {
21
- const controller = getter()
22
- provide(_key, controller)
23
- return controller
24
- }
25
-
26
- const _inject = () => {
27
- const controller = inject(_key)
28
- if (!controller)
29
- throw new Error(`Please wrap the container in ${_key}`)
30
-
31
- return controller
32
- }
33
-
34
- return {
35
- key: _key,
36
- provide: _provide,
37
- inject: _inject,
38
- getter,
39
- }
40
- }
package/utils/fonts.ts DELETED
@@ -1,15 +0,0 @@
1
- import Seto from '../styles/fonts/Seto.ttf?url'
2
- import { createPromise } from '.'
3
-
4
- export const fontFacePromise = createPromise<void>()
5
-
6
- async function loadFonts(fontFamily: string, url: string) {
7
- const font = new FontFace(fontFamily, `url(${url})`)
8
- await font.load()
9
- ;(document.fonts as any).add(font)
10
- }
11
-
12
- (async () => {
13
- await loadFonts('Seto', Seto)
14
- fontFacePromise.resolve()
15
- })()
File without changes
File without changes