valaxy 0.7.2 → 0.7.5

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
@@ -1,10 +1,9 @@
1
1
  // @ts-expect-error virtual module @valaxyjs/config
2
- import valaxyConfig from '@valaxyjs/config'
2
+ import valaxyConfig from '/@valaxyjs/config'
3
3
  // @ts-expect-error virtual module @valaxyjs/context
4
- import valaxyContext from '@valaxyjs/context'
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>
package/client/index.ts CHANGED
@@ -4,6 +4,3 @@ export * from './composables'
4
4
  export * from './utils'
5
5
 
6
6
  export * from './setups'
7
-
8
- // fix client alias export
9
- export * from '../shared'
package/client/main.ts CHANGED
@@ -25,9 +25,6 @@ export const createApp = ViteSSG(
25
25
  },
26
26
  },
27
27
  (ctx) => {
28
- // install all modules under `modules/`
29
- Object.values(import.meta.globEager('./modules/*.ts')).forEach(i => i.install?.(ctx))
30
-
31
28
  setupMain(ctx)
32
29
  },
33
30
  )
@@ -1,11 +1,17 @@
1
1
  /* __imports__ */
2
-
3
2
  import type { ViteSSGContext } from 'vite-ssg'
3
+ import { install as installValaxy } from '../modules/valaxy'
4
+ import { install as installPinia } from '../modules/pinia'
5
+ import { install as installNprogress } from '../modules/nprogress'
4
6
 
5
7
  export default function setupMain(ctx: ViteSSGContext) {
6
8
  // @ts-expect-error inject in runtime
7
9
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
8
10
  const injection_arg = ctx
9
11
 
12
+ installValaxy(ctx)
13
+ installPinia(ctx)
14
+ installNprogress(ctx)
15
+
10
16
  /* __injections__ */
11
17
  }
package/client/shims.d.ts CHANGED
@@ -17,13 +17,13 @@ declare module '*.vue' {
17
17
  }
18
18
 
19
19
  // vite hmr data
20
- declare module '@valaxyjs/config' {
20
+ declare module '/@valaxyjs/config' {
21
21
  // import type { ValaxyConfig } from 'valaxy'
22
22
  const config: string
23
23
  export default config
24
24
  }
25
25
 
26
- declare module '@valaxyjs/context' {
26
+ declare module '/@valaxyjs/context' {
27
27
  const ctx: string
28
28
  export default ctx
29
29
  }
@@ -0,0 +1 @@
1
+ var g=Object.create;var f=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(a=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(a,{get:(b,c)=>(typeof require!="undefined"?require:b)[c]}):a)(function(a){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+a+'" is not supported')});var n=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var l=(a,b,c,e)=>{if(b&&typeof b=="object"||typeof b=="function")for(let d of i(b))!k.call(a,d)&&d!==c&&f(a,d,{get:()=>b[d],enumerable:!(e=h(b,d))||e.enumerable});return a};var o=(a,b,c)=>(c=a!=null?g(j(a)):{},l(b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c,a));export{m as a,n as b,o as c};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var g=Object.create;var f=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(a=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(a,{get:(b,c)=>(typeof require!="undefined"?require:b)[c]}):a)(function(a){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+a+'" is not supported')});var n=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var l=(a,b,c,e)=>{if(b&&typeof b=="object"||typeof b=="function")for(let d of i(b))!k.call(a,d)&&d!==c&&f(a,d,{get:()=>b[d],enumerable:!(e=h(b,d))||e.enumerable});return a};var o=(a,b,c)=>(c=a!=null?g(j(a)):{},l(b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c,a));exports.a = m; exports.b = n; exports.c = o;