valaxy 0.18.0-beta.0 → 0.18.0-beta.2
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/composables/{post.ts → post/index.ts} +4 -30
- package/client/composables/post/usePrevNext.ts +30 -0
- package/client/main.ts +4 -0
- package/client/modules/devtools.ts +1 -1
- package/client/modules/valaxy.ts +3 -0
- package/client/setup/main.ts +8 -6
- package/client/stores/site.ts +4 -0
- package/client/utils/dev.ts +13 -0
- package/dist/{chunk-AQGELPBR.mjs → chunk-OKWTZ6SV.mjs} +39 -36
- package/dist/{chunk-GO3LEXT4.cjs → chunk-V3BYMJ7P.cjs} +42 -39
- package/dist/node/cli/index.cjs +1 -1
- package/dist/node/cli/index.mjs +1 -1
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.cts +23 -2
- package/dist/node/index.d.ts +23 -2
- package/dist/node/index.mjs +1 -1
- package/package.json +5 -5
- package/shims.d.ts +5 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ComputedRef } from 'vue'
|
|
2
2
|
import { computed } from 'vue'
|
|
3
|
-
import { useRoute } from 'vue-router'
|
|
4
3
|
import { useI18n } from 'vue-i18n'
|
|
5
4
|
import type { Post } from 'valaxy'
|
|
6
|
-
import { sortByDate } from '
|
|
7
|
-
import { useRouterStore
|
|
5
|
+
import { sortByDate } from '../../utils'
|
|
6
|
+
import { useRouterStore } from '../../stores'
|
|
7
|
+
|
|
8
|
+
export * from './usePrevNext'
|
|
8
9
|
|
|
9
10
|
export function usePostTitle(post: ComputedRef<Post>) {
|
|
10
11
|
const { locale } = useI18n()
|
|
@@ -62,30 +63,3 @@ export function usePostList(params: {
|
|
|
62
63
|
return topPosts.concat(otherPosts)
|
|
63
64
|
})
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* get prev and next post
|
|
68
|
-
* @param path
|
|
69
|
-
*/
|
|
70
|
-
export function usePrevNext(path?: string) {
|
|
71
|
-
const route = useRoute()
|
|
72
|
-
const p = computed(() => path || route.path)
|
|
73
|
-
const site = useSiteStore()
|
|
74
|
-
|
|
75
|
-
const index = computed(() => {
|
|
76
|
-
let order = -1
|
|
77
|
-
site.postList.find((item, i) => {
|
|
78
|
-
if (item.path === p.value) {
|
|
79
|
-
order = i
|
|
80
|
-
return true
|
|
81
|
-
}
|
|
82
|
-
return false
|
|
83
|
-
})
|
|
84
|
-
return order
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
const prev = computed(() => index.value - 1 >= 0 ? site.postList[index.value - 1] : null)
|
|
88
|
-
const next = computed(() => index.value + 1 < site.postList.length ? site.postList[index.value + 1] : null)
|
|
89
|
-
|
|
90
|
-
return [prev, next]
|
|
91
|
-
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { computed } from 'vue'
|
|
2
|
+
import { useRoute } from 'vue-router'
|
|
3
|
+
import { useSiteStore } from '../../stores'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* get prev and next post
|
|
7
|
+
* @param path
|
|
8
|
+
*/
|
|
9
|
+
export function usePrevNext(path?: string) {
|
|
10
|
+
const route = useRoute()
|
|
11
|
+
const p = computed(() => path || route.path)
|
|
12
|
+
const site = useSiteStore()
|
|
13
|
+
|
|
14
|
+
const index = computed(() => {
|
|
15
|
+
let order = -1
|
|
16
|
+
site.postList.find((item, i) => {
|
|
17
|
+
if (item.path === p.value) {
|
|
18
|
+
order = i
|
|
19
|
+
return true
|
|
20
|
+
}
|
|
21
|
+
return false
|
|
22
|
+
})
|
|
23
|
+
return order
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const prev = computed(() => index.value - 1 >= 0 ? site.postList[index.value - 1] : null)
|
|
27
|
+
const next = computed(() => index.value + 1 < site.postList.length ? site.postList[index.value + 1] : null)
|
|
28
|
+
|
|
29
|
+
return [prev, next]
|
|
30
|
+
}
|
package/client/main.ts
CHANGED
|
@@ -20,6 +20,7 @@ import '/@valaxyjs/styles'
|
|
|
20
20
|
import 'uno.css'
|
|
21
21
|
|
|
22
22
|
import setupMain from './setup/main'
|
|
23
|
+
import { initDevToolsClientLogic } from './utils/dev'
|
|
23
24
|
|
|
24
25
|
const valaxyConfig = initValaxyConfig()
|
|
25
26
|
|
|
@@ -58,6 +59,9 @@ const routesWithLayout = setupLayouts(import.meta.env.DEV
|
|
|
58
59
|
: filterDraft(routes),
|
|
59
60
|
)
|
|
60
61
|
|
|
62
|
+
if (import.meta.env.DEV)
|
|
63
|
+
initDevToolsClientLogic()
|
|
64
|
+
|
|
61
65
|
// https://github.com/antfu/vite-ssg
|
|
62
66
|
export const createApp = ViteSSG(
|
|
63
67
|
App,
|
package/client/modules/valaxy.ts
CHANGED
|
@@ -63,6 +63,9 @@ function handleHMR(router: Router): void {
|
|
|
63
63
|
if (import.meta.hot) {
|
|
64
64
|
import.meta.hot.on('valaxy:pageData', (payload: PageDataPayload) => {
|
|
65
65
|
if (shouldHotReload(payload)) {
|
|
66
|
+
// @ts-expect-error $pageData
|
|
67
|
+
window.$pageData = payload.pageData
|
|
68
|
+
|
|
66
69
|
// console.log(payload.pageData.headers)
|
|
67
70
|
Object.assign(router.currentRoute.value.meta, payload.pageData)
|
|
68
71
|
}
|
package/client/setup/main.ts
CHANGED
|
@@ -26,12 +26,6 @@ export default function setupMain(ctx: ViteSSGContext, config: ComputedRef<Valax
|
|
|
26
26
|
|
|
27
27
|
installValaxy(ctx, config)
|
|
28
28
|
|
|
29
|
-
if (import.meta.env.DEV && ctx.isClient) {
|
|
30
|
-
import('../modules/devtools').then(({ install: installDevtools }) => {
|
|
31
|
-
installDevtools(ctx)
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
|
|
35
29
|
installSchema(ctx)
|
|
36
30
|
|
|
37
31
|
installPinia(ctx)
|
|
@@ -42,5 +36,13 @@ export default function setupMain(ctx: ViteSSGContext, config: ComputedRef<Valax
|
|
|
42
36
|
dayjs.extend(utc)
|
|
43
37
|
dayjs.extend(timezone)
|
|
44
38
|
|
|
39
|
+
if (import.meta.env.DEV && ctx.isClient) {
|
|
40
|
+
import('../modules/devtools').then(({ install: installDevtools }) => {
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
installDevtools(ctx)
|
|
43
|
+
}, 0)
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
45
47
|
/* __injections__ */
|
|
46
48
|
}
|
package/client/stores/site.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { computed, ref } from 'vue'
|
|
|
2
2
|
import { acceptHMRUpdate, defineStore } from 'pinia'
|
|
3
3
|
import { usePostList, useRouterStore } from '..'
|
|
4
4
|
import type { PageDataPayload } from '../../types'
|
|
5
|
+
import { setWindowValaxyProp } from '../utils/dev'
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* cache site global store
|
|
@@ -57,6 +58,9 @@ export const useSiteStore = defineStore('site', () => {
|
|
|
57
58
|
})
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
if (import.meta.env.DEV)
|
|
62
|
+
setWindowValaxyProp('postList', postList)
|
|
63
|
+
|
|
60
64
|
return {
|
|
61
65
|
postList,
|
|
62
66
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function initDevToolsClientLogic() {
|
|
2
|
+
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function setWindowValaxyProp(property: string, value: any) {
|
|
6
|
+
if (!(window as any).$valaxy) {
|
|
7
|
+
;(window as any).$valaxy = {}
|
|
8
|
+
}
|
|
9
|
+
const $valaxy = ((window as any).$valaxy) as {
|
|
10
|
+
[key: string]: any
|
|
11
|
+
}
|
|
12
|
+
$valaxy[property] = value
|
|
13
|
+
}
|