valaxy 0.22.12 → 0.22.14
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.
- package/client/app/data.ts +19 -0
- package/client/components/ValaxyOverlay.vue +1 -1
- package/client/composables/common.ts +10 -6
- package/client/config.ts +4 -1
- package/client/main.ts +6 -2
- package/dist/chunk-IIRPH2I3.js +4790 -0
- package/dist/chunk-VYN4JENY.js +19 -0
- package/dist/chunk-XJIR7Y6C.js +426 -0
- package/dist/node/cli/index.js +14 -1
- package/dist/node/index.d.ts +4 -2
- package/dist/node/index.js +108 -1
- package/dist/node/worker_shikiResolveLang.js +13 -1
- package/dist/types/index.js +1 -1
- package/package.json +18 -13
- package/dist/chunk-2TIFAWAJ.js +0 -2
- package/dist/chunk-3KRYIAHJ.js +0 -2
- package/dist/chunk-Y2R2NVO2.js +0 -165
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Ref } from 'vue'
|
|
2
|
+
import type { Router } from 'vue-router'
|
|
3
|
+
import type { PageData } from '../../types'
|
|
4
|
+
import { computed } from 'vue'
|
|
5
|
+
|
|
6
|
+
export interface ValaxyData {
|
|
7
|
+
page: Ref<PageData>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* init valaxy data
|
|
12
|
+
*/
|
|
13
|
+
export function initData(router: Router): ValaxyData {
|
|
14
|
+
return {
|
|
15
|
+
page: computed(() => (router.currentRoute.value as unknown as {
|
|
16
|
+
data: PageData
|
|
17
|
+
}).data),
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PostFrontMatter } from 'valaxy/types'
|
|
2
|
+
import type { ValaxyData } from '../app/data'
|
|
2
3
|
import { isClient } from '@vueuse/core'
|
|
3
|
-
import { computed, inject } from 'vue'
|
|
4
4
|
|
|
5
|
+
import { computed, inject } from 'vue'
|
|
5
6
|
import { useRoute } from 'vue-router'
|
|
6
|
-
import { useSiteConfig } from '../config'
|
|
7
|
+
import { dataSymbol, useSiteConfig } from '../config'
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Get `route.meta.frontmatter` from your markdown file
|
|
@@ -71,9 +72,12 @@ export function useEncryptedPhotos() {
|
|
|
71
72
|
/**
|
|
72
73
|
* inject pageData
|
|
73
74
|
*/
|
|
74
|
-
export function useData():
|
|
75
|
-
const
|
|
76
|
-
|
|
75
|
+
export function useData(): ValaxyData {
|
|
76
|
+
const data = inject(dataSymbol, {} as any)
|
|
77
|
+
if (!data) {
|
|
78
|
+
throw new Error('Valaxy data not properly injected in app')
|
|
79
|
+
}
|
|
80
|
+
return data
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
/**
|
package/client/config.ts
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
import type { DefaultTheme, ValaxyConfig } from 'valaxy/types'
|
|
6
6
|
|
|
7
7
|
import type { ComputedRef, InjectionKey } from 'vue'
|
|
8
|
+
import type { ValaxyData } from './app/data'
|
|
8
9
|
import { computed, inject, readonly, shallowRef } from 'vue'
|
|
10
|
+
|
|
9
11
|
// @ts-expect-error virtual module @valaxyjs/config
|
|
10
12
|
import valaxyConfig from '/@valaxyjs/config'
|
|
11
|
-
|
|
12
13
|
// @ts-expect-error virtual module @valaxyjs/context
|
|
13
14
|
import valaxyContext from '/@valaxyjs/context'
|
|
14
15
|
|
|
@@ -28,6 +29,8 @@ interface ValaxyContext {
|
|
|
28
29
|
export const valaxyConfigSymbol: InjectionKey<ComputedRef<ValaxyConfig>> = Symbol('valaxy:config')
|
|
29
30
|
export const valaxyConfigRef = shallowRef<ValaxyConfig>(parse<ValaxyConfig>(valaxyConfig))
|
|
30
31
|
|
|
32
|
+
export const dataSymbol: InjectionKey<ValaxyData> = Symbol('ValaxyData')
|
|
33
|
+
|
|
31
34
|
export const valaxyContextRef = shallowRef<ValaxyContext>(parse<ValaxyContext>(valaxyContext))
|
|
32
35
|
|
|
33
36
|
valaxyConfigRef.value = parse<ValaxyConfig>(valaxyConfig)
|
package/client/main.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ViteSSGContext } from 'vite-ssg'
|
|
2
2
|
import { DataLoaderPlugin } from 'unplugin-vue-router/data-loaders'
|
|
3
|
-
import { initValaxyConfig, valaxyConfigSymbol } from 'valaxy'
|
|
3
|
+
import { dataSymbol, initValaxyConfig, valaxyConfigSymbol } from 'valaxy'
|
|
4
4
|
import { setupLayouts } from 'virtual:generated-layouts'
|
|
5
5
|
import { ViteSSG } from 'vite-ssg'
|
|
6
6
|
|
|
@@ -8,11 +8,12 @@ import { routes } from 'vue-router/auto-routes'
|
|
|
8
8
|
// import App from '/@valaxyjs/App.vue'
|
|
9
9
|
import App from './App.vue'
|
|
10
10
|
|
|
11
|
+
import { initData } from './app/data'
|
|
11
12
|
import AppLink from './components/AppLink.vue'
|
|
13
|
+
|
|
12
14
|
import setupMain from './setup/main'
|
|
13
15
|
|
|
14
16
|
import { setupValaxyDevTools } from './utils/dev'
|
|
15
|
-
|
|
16
17
|
// generate user styles
|
|
17
18
|
import '#valaxy/styles'
|
|
18
19
|
|
|
@@ -71,6 +72,9 @@ export const createApp = ViteSSG(
|
|
|
71
72
|
// app-level provide
|
|
72
73
|
const { app, router } = ctx
|
|
73
74
|
|
|
75
|
+
const data = initData(router)
|
|
76
|
+
app.provide(dataSymbol, data)
|
|
77
|
+
|
|
74
78
|
// Register the plugin before the router
|
|
75
79
|
app.use(DataLoaderPlugin, { router })
|
|
76
80
|
|