valaxy 0.17.0-beta.3 → 0.17.0
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/components/ValaxyCopyright.vue +1 -1
- package/client/composables/categories.ts +22 -22
- package/client/composables/post.ts +4 -1
- package/client/composables/tags.ts +1 -1
- package/client/modules/valaxy.ts +2 -3
- package/client/stores/site.ts +11 -5
- package/client/utils/time.ts +1 -1
- package/dist/chunk-ALNY7KGH.mjs +148 -0
- package/dist/chunk-O4TV2H4O.cjs +147 -0
- package/dist/{config-OaNeBI1c.d.cts → config-hKSeaczj.d.cts} +8 -7
- package/dist/{config-OaNeBI1c.d.ts → config-hKSeaczj.d.ts} +8 -7
- 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 +94 -51
- package/dist/node/index.d.ts +94 -51
- package/dist/node/index.mjs +1 -1
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.mjs +1 -1
- package/package.json +16 -13
- package/shims.d.ts +62 -0
- package/types/README.md +5 -0
- package/types/config.ts +8 -6
- package/types/index.ts +1 -0
- package/dist/chunk-2HLMSZO4.mjs +0 -150
- package/dist/chunk-45B2VOLU.cjs +0 -149
- /package/dist/{chunk-GXMNHGBP.cjs → chunk-TEOGEXZQ.cjs} +0 -0
- /package/dist/{chunk-WSC7UAH5.mjs → chunk-ZO24WTQL.mjs} +0 -0
|
@@ -38,7 +38,7 @@ const licenseHtml = computed(() => {
|
|
|
38
38
|
{{ t('post.copyright.link') + t('symbol.colon') }}
|
|
39
39
|
</strong>
|
|
40
40
|
<a :href="url" target="_blank" :title="t('post.copyright.link')">
|
|
41
|
-
{{ url }}
|
|
41
|
+
{{ decodeURI(url) }}
|
|
42
42
|
</a>
|
|
43
43
|
</li>
|
|
44
44
|
<li class="post-copyright-license">
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MaybeRef } from '@vueuse/core'
|
|
2
2
|
import { computed, unref } from 'vue'
|
|
3
|
-
import type { Post } from '
|
|
3
|
+
import type { Post } from '../../types'
|
|
4
4
|
import { useSiteStore } from '../stores'
|
|
5
5
|
|
|
6
6
|
export interface BaseCategory {
|
|
@@ -16,10 +16,10 @@ export interface CategoryList {
|
|
|
16
16
|
* total posts
|
|
17
17
|
*/
|
|
18
18
|
total: number
|
|
19
|
-
children:
|
|
19
|
+
children: Map<string, Post | CategoryList>
|
|
20
20
|
}
|
|
21
21
|
export type Category = CategoryList
|
|
22
|
-
export type Categories =
|
|
22
|
+
export type Categories = Map<string, Post | CategoryList>
|
|
23
23
|
|
|
24
24
|
// todo write unit test
|
|
25
25
|
export function isCategoryList(category: any): category is CategoryList {
|
|
@@ -53,12 +53,12 @@ export function useCategories(category?: MaybeRef<string>, posts: Post[] = []) {
|
|
|
53
53
|
const categoryList: CategoryList = {
|
|
54
54
|
name: 'All',
|
|
55
55
|
total: posts.length,
|
|
56
|
-
children: [
|
|
57
|
-
{ name: 'Uncategorized', total: 0, children:
|
|
58
|
-
],
|
|
56
|
+
children: new Map([
|
|
57
|
+
['Uncategorized', { name: 'Uncategorized', total: 0, children: new Map() }],
|
|
58
|
+
]),
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
const uncategorized = categoryList.children.
|
|
61
|
+
const uncategorized = categoryList.children.get('Uncategorized')!
|
|
62
62
|
|
|
63
63
|
posts.forEach((post: Post) => {
|
|
64
64
|
if (post.categories) {
|
|
@@ -69,20 +69,21 @@ export function useCategories(category?: MaybeRef<string>, posts: Post[] = []) {
|
|
|
69
69
|
let parentCategory: CategoryList = curCategoryList
|
|
70
70
|
|
|
71
71
|
post.categories.forEach((categoryName, i) => {
|
|
72
|
+
// console.log(parentCategory, curCategoryList.children, 'post', categoryName)
|
|
72
73
|
curCategoryList.total += 1
|
|
73
|
-
curCategoryList =
|
|
74
|
+
curCategoryList = curCategoryList.children.get(categoryName) as CategoryList
|
|
74
75
|
|
|
75
76
|
if (!curCategoryList) {
|
|
76
77
|
curCategoryList = {
|
|
77
78
|
name: categoryName,
|
|
78
79
|
total: 0,
|
|
79
|
-
children:
|
|
80
|
+
children: new Map(),
|
|
80
81
|
}
|
|
81
|
-
parentCategory.children.
|
|
82
|
+
parentCategory.children.set(categoryName, curCategoryList)
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
if (i === len - 1) {
|
|
85
|
-
curCategoryList.children.
|
|
86
|
+
curCategoryList.children.set(post.path!, post)
|
|
86
87
|
curCategoryList.total += 1
|
|
87
88
|
}
|
|
88
89
|
|
|
@@ -92,23 +93,25 @@ export function useCategories(category?: MaybeRef<string>, posts: Post[] = []) {
|
|
|
92
93
|
else {
|
|
93
94
|
// for string
|
|
94
95
|
const categoryName = post.categories
|
|
95
|
-
const curCategory = categoryList.children.
|
|
96
|
+
const curCategory = categoryList.children.get(categoryName)
|
|
96
97
|
if (curCategory) {
|
|
97
98
|
curCategory.total += 1
|
|
98
|
-
curCategory.children.
|
|
99
|
+
curCategory.children.set(post.path!, post)
|
|
99
100
|
}
|
|
100
101
|
else {
|
|
101
|
-
categoryList.children.
|
|
102
|
+
categoryList.children.set(categoryName, {
|
|
102
103
|
name: categoryName,
|
|
103
104
|
total: 1,
|
|
104
|
-
children: [
|
|
105
|
+
children: new Map([
|
|
106
|
+
[post.path!, post],
|
|
107
|
+
]),
|
|
105
108
|
})
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
}
|
|
109
112
|
else {
|
|
110
113
|
uncategorized.total += 1
|
|
111
|
-
uncategorized.children.
|
|
114
|
+
uncategorized.children.set(post.path!, post)
|
|
112
115
|
}
|
|
113
116
|
})
|
|
114
117
|
|
|
@@ -116,7 +119,7 @@ export function useCategories(category?: MaybeRef<string>, posts: Post[] = []) {
|
|
|
116
119
|
|
|
117
120
|
// clear uncategorized
|
|
118
121
|
if (uncategorized!.total === 0)
|
|
119
|
-
categoryList.children.
|
|
122
|
+
categoryList.children.delete('Uncategorized')
|
|
120
123
|
|
|
121
124
|
if (!categories) {
|
|
122
125
|
return categoryList
|
|
@@ -125,7 +128,7 @@ export function useCategories(category?: MaybeRef<string>, posts: Post[] = []) {
|
|
|
125
128
|
let curCategoryList = categoryList
|
|
126
129
|
const categoryArr = categories.split('/')
|
|
127
130
|
for (const categoryName of categoryArr) {
|
|
128
|
-
const tempCList = curCategoryList.children.
|
|
131
|
+
const tempCList = curCategoryList.children.get(categoryName)
|
|
129
132
|
if (tempCList && tempCList.children) {
|
|
130
133
|
curCategoryList = tempCList as CategoryList
|
|
131
134
|
}
|
|
@@ -147,10 +150,7 @@ export function useCategories(category?: MaybeRef<string>, posts: Post[] = []) {
|
|
|
147
150
|
export function removeItemFromCategory(categoryList: CategoryList, categoryName: string) {
|
|
148
151
|
if (isCategoryList(categoryList)) {
|
|
149
152
|
const categoryArr = categoryName.split('/')
|
|
150
|
-
|
|
151
|
-
const categoryListItemIndex = categoryList.children.findIndex(item => item.name === categoryArr[0])
|
|
152
|
-
|
|
153
|
-
categoryList.children.splice(categoryListItemIndex, 1)
|
|
153
|
+
categoryList.children.delete(categoryArr[0])
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
|
|
@@ -18,9 +18,12 @@ export function usePostTitle(post: ComputedRef<Post>) {
|
|
|
18
18
|
* get all page in 'pages' folder
|
|
19
19
|
*/
|
|
20
20
|
export function usePageList() {
|
|
21
|
+
const router = useRouter()
|
|
21
22
|
return computed<Post[]>(() => {
|
|
22
23
|
const excludePages = ['/:..all', '/:all(.*)*', '/', '/:path(.*)']
|
|
23
|
-
|
|
24
|
+
if (!router)
|
|
25
|
+
return []
|
|
26
|
+
|
|
24
27
|
const routes = router.getRoutes()
|
|
25
28
|
.filter(i => i.name)
|
|
26
29
|
.filter(i => i.meta)
|
package/client/modules/valaxy.ts
CHANGED
|
@@ -39,8 +39,7 @@ import valaxyMessages from '/@valaxyjs/locales'
|
|
|
39
39
|
function shouldHotReload(payload: PageDataPayload): boolean {
|
|
40
40
|
const payloadPath = payload.path.replace(/(\bindex)?\.md$/, '')
|
|
41
41
|
const locationPath = location.pathname.replace(/(\bindex)?\.html$/, '')
|
|
42
|
-
|
|
43
|
-
return ensureSuffix('/', payloadPath) === ensureSuffix('/', locationPath)
|
|
42
|
+
return ensureSuffix('/', encodeURI(payloadPath)) === ensureSuffix('/', encodeURI(locationPath))
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
export async function install({ app, router }: ViteSSGContext, config: ComputedRef<ValaxyConfig<DefaultTheme.Config>>) {
|
|
@@ -62,7 +61,7 @@ export async function install({ app, router }: ViteSSGContext, config: ComputedR
|
|
|
62
61
|
function handleHMR(router: Router): void {
|
|
63
62
|
// update route.data on HMR updates of active page
|
|
64
63
|
if (import.meta.hot) {
|
|
65
|
-
import.meta.hot
|
|
64
|
+
import.meta.hot.on('valaxy:pageData', (payload: PageDataPayload) => {
|
|
66
65
|
if (shouldHotReload(payload)) {
|
|
67
66
|
// console.log(payload.pageData.headers)
|
|
68
67
|
Object.assign(router.currentRoute.value.meta, payload.pageData)
|
package/client/stores/site.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { PageDataPayload } from '../../types'
|
|
|
12
12
|
*/
|
|
13
13
|
export const useSiteStore = defineStore('site', () => {
|
|
14
14
|
const reload = ref(1)
|
|
15
|
+
// for dev hot reload
|
|
15
16
|
const postList = computed(() => {
|
|
16
17
|
if (reload.value)
|
|
17
18
|
return usePostList().value
|
|
@@ -19,6 +20,8 @@ export const useSiteStore = defineStore('site', () => {
|
|
|
19
20
|
return usePostList().value
|
|
20
21
|
})
|
|
21
22
|
|
|
23
|
+
// const postList = usePostList()
|
|
24
|
+
|
|
22
25
|
const router = useRouter()
|
|
23
26
|
if (router) {
|
|
24
27
|
router.isReady().then(() => {
|
|
@@ -30,19 +33,22 @@ export const useSiteStore = defineStore('site', () => {
|
|
|
30
33
|
if (payload.path.endsWith('.md'))
|
|
31
34
|
path = payload.path.slice(0, -3)
|
|
32
35
|
|
|
33
|
-
const routeName = path
|
|
34
|
-
|
|
36
|
+
const routeName = path
|
|
35
37
|
if (!router.hasRoute(routeName))
|
|
36
38
|
return
|
|
37
39
|
|
|
38
40
|
// can not use generatedRoutes, otherwise will trigger ValaxyMain refresh
|
|
39
41
|
const route = router.getRoutes().find(r => r.name === routeName)!
|
|
40
42
|
router.removeRoute(routeName)
|
|
41
|
-
if (route.meta)
|
|
42
|
-
route.meta.frontmatter =
|
|
43
|
+
if (route.meta) {
|
|
44
|
+
route.meta.frontmatter = {
|
|
45
|
+
...route.meta.frontmatter,
|
|
46
|
+
...payload.pageData.frontmatter,
|
|
47
|
+
}
|
|
48
|
+
}
|
|
43
49
|
router.addRoute(route)
|
|
44
50
|
|
|
45
|
-
// trigger computed reload
|
|
51
|
+
// trigger `computed` reload, not server
|
|
46
52
|
reload.value += 1
|
|
47
53
|
})
|
|
48
54
|
}
|
package/client/utils/time.ts
CHANGED