valaxy 0.7.1 → 0.7.4

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.
@@ -1,8 +1,7 @@
1
- import type { Ref, StyleValue } from 'vue'
1
+ import type { Ref } from 'vue'
2
2
  import { computed } from 'vue'
3
3
  import { useRoute, useRouter } from 'vue-router'
4
4
  import { useI18n } from 'vue-i18n'
5
- import { useThemeConfig } from '../config'
6
5
  import { sortByDate } from '../utils'
7
6
  import type { Post } from '../../types'
8
7
 
@@ -85,37 +84,3 @@ export function usePrevNext(path?: string) {
85
84
 
86
85
  return [prev, next]
87
86
  }
88
-
89
- /**
90
- * get type card property
91
- * todo: test reactive
92
- */
93
- export function usePostProperty(type?: string) {
94
- if (!type) {
95
- return {
96
- color: '',
97
- icon: '',
98
- styles: {},
99
- }
100
- }
101
-
102
- const themeConfig = useThemeConfig()
103
-
104
- if (!(type in themeConfig.value.types))
105
- type = 'link'
106
-
107
- const color = themeConfig.value.types[type].color
108
- const icon = themeConfig.value.types[type].icon
109
-
110
- const styles = computed(() => {
111
- return {
112
- '--card-c-primary': type && color,
113
- } as StyleValue
114
- })
115
-
116
- return {
117
- color,
118
- icon,
119
- styles,
120
- }
121
- }
@@ -1,52 +1,5 @@
1
1
  import type { Ref } from 'vue'
2
- import { computed, onMounted, onUnmounted, ref } from 'vue'
3
- import { useRoute } from 'vue-router'
4
- import { useThemeConfig } from '..'
5
- import { getSidebar } from '../utils/sidebar'
6
- import { useFrontmatter } from './common'
7
-
8
- // todo: refactor
9
-
10
- export function useSidebar() {
11
- const route = useRoute()
12
- const frontmatter = useFrontmatter()
13
- const themeConfig = useThemeConfig()
14
-
15
- const isOpen = ref(false)
16
-
17
- const sidebar = computed(() => {
18
- const sidebarConfig = themeConfig.value.sidebar
19
- const relativePath = route.path
20
-
21
- return sidebarConfig ? getSidebar(sidebarConfig, relativePath) : []
22
- })
23
-
24
- const hasSidebar = computed(() => {
25
- // return frontmatter.value.sidebar !== false && sidebar.value.length > 0
26
- return frontmatter.value.sidebar !== false
27
- })
28
-
29
- function open() {
30
- isOpen.value = true
31
- }
32
-
33
- function close() {
34
- isOpen.value = false
35
- }
36
-
37
- function toggle() {
38
- isOpen.value ? close() : open()
39
- }
40
-
41
- return {
42
- isOpen,
43
- sidebar,
44
- hasSidebar,
45
- open,
46
- close,
47
- toggle,
48
- }
49
- }
2
+ import { onMounted, onUnmounted } from 'vue'
50
3
 
51
4
  export function useActiveSidebarLinks(container: Ref<HTMLElement>, marker: Ref<HTMLElement>) {
52
5
  const onScroll = throttleAndDebounce(setActiveLink, 200)
package/client/config.ts CHANGED
@@ -4,7 +4,6 @@ import valaxyConfig from '@valaxyjs/config'
4
4
  import valaxyContext from '@valaxyjs/context'
5
5
  import type { ComputedRef, InjectionKey, Ref } from 'vue'
6
6
  import { computed, inject, readonly, shallowRef } from 'vue'
7
- import type { ThemeConfig } from 'valaxy-theme-yun'
8
7
  // import type { RouteMeta } from 'vue-router'
9
8
  import type { PageData, ValaxyConfig } from '../types'
10
9
 
@@ -22,7 +21,7 @@ interface ValaxyContext {
22
21
  userRoot: string
23
22
  }
24
23
 
25
- export const valaxyConfigSymbol: InjectionKey<ComputedRef<ValaxyConfig<ThemeConfig>>> = Symbol('valaxy:config')
24
+ export const valaxyConfigSymbol: InjectionKey<ComputedRef<ValaxyConfig>> = Symbol('valaxy:config')
26
25
  export const valaxyConfigRef = shallowRef<ValaxyConfig>(parse<ValaxyConfig>(valaxyConfig))
27
26
 
28
27
  export const valaxyContextRef = shallowRef<ValaxyContext>(parse<ValaxyContext>(valaxyContext))
@@ -50,25 +49,17 @@ export function initContext() {
50
49
  }
51
50
 
52
51
  /*
53
- * get Config
52
+ * get valaxy config
53
+ * @public
54
54
  * @returns
55
55
  */
56
- export function useConfig() {
57
- const config = inject(valaxyConfigSymbol)
56
+ export function useConfig<ThemeConfig = any>() {
57
+ const config = inject<ComputedRef<ValaxyConfig<ThemeConfig>>>(valaxyConfigSymbol)
58
58
  if (!config)
59
59
  throw new Error('[Valaxy] config not properly injected in app')
60
60
  return config!
61
61
  }
62
62
 
63
- /**
64
- * getThemeConfig
65
- * @returns
66
- */
67
- export function useThemeConfig() {
68
- const config = useConfig()
69
- return computed(() => config!.value.themeConfig)
70
- }
71
-
72
63
  export interface ValaxyData<T = any> {
73
64
  page: Ref<PageData>
74
65
  theme: Ref<T>
@@ -0,0 +1 @@
1
+ var r=Object.create;var t=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var s=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(n,o)=>(typeof require!="undefined"?require:n)[o]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var T=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var p=(e,n,o,f)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of C(n))!m.call(e,i)&&i!==o&&t(e,i,{get:()=>n[i],enumerable:!(f=g(n,i))||f.enumerable});return e};var u=(e,n,o)=>(o=e!=null?r(h(e)):{},p(n||!e||!e.__esModule?t(o,"default",{value:e,enumerable:!0}):o,e));var c=/^https?:/i;function x(e){return e}function E(e){return e}export{s as a,T as b,u as c,c as d,x as e,E as f};