valaxy 0.9.3 → 0.10.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/App.vue +11 -3
- package/client/components/ValaxyAddons.vue +10 -0
- package/client/components/ValaxyMd.vue +0 -10
- package/client/components/ValaxyOverlay.vue +1 -1
- package/client/composables/category.ts +5 -0
- package/client/composables/common.ts +1 -1
- package/client/composables/outline.ts +1 -1
- package/client/composables/post.ts +24 -24
- package/client/config.ts +25 -15
- package/client/layouts/404.vue +1 -1
- package/client/layouts/default.vue +3 -0
- package/client/layouts/layout.vue +34 -0
- package/client/layouts/post.vue +3 -0
- package/client/modules/valaxy.ts +3 -3
- package/client/setups.ts +1 -1
- package/client/styles/common/markdown.scss +9 -0
- package/client/styles/common/sidebar.scss +1 -1
- package/client/styles/global/reset.scss +0 -2
- package/client/styles/mixins/size.scss +12 -13
- package/client/styles/palette.scss +1 -1
- package/client/styles/vars.scss +1 -1
- package/client/{index.html → template.html} +0 -6
- package/dist/chunk-6PDG5NQV.mjs +102 -0
- package/dist/chunk-S7EBKLNL.js +102 -0
- package/dist/{config-1d2e9ebd.d.ts → config-1d500fb4.d.ts} +4 -4
- package/dist/node/cli.js +7 -7
- package/dist/node/cli.mjs +7 -7
- package/dist/node/index.d.ts +88 -45
- package/dist/node/index.js +1 -1
- package/dist/node/index.mjs +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +9 -11
- package/types/config.ts +4 -5
- package/dist/chunk-4ICNZPIN.js +0 -2326
- package/dist/chunk-WXYDKT6O.mjs +0 -2326
package/client/App.vue
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed } from 'vue'
|
|
3
3
|
import { useHead } from '@vueuse/head'
|
|
4
|
+
// @ts-expect-error virtual module
|
|
5
|
+
import ValaxyUserApp from '/@valaxyjs/UserAppVue'
|
|
4
6
|
import { isDark } from './composables'
|
|
5
7
|
|
|
6
8
|
// https://github.com/vueuse/head
|
|
@@ -10,28 +12,34 @@ import { useConfig } from './config'
|
|
|
10
12
|
|
|
11
13
|
// <link rel="apple-touch-icon" href="/pwa-192x192.png">
|
|
12
14
|
// <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#00aba9">
|
|
13
|
-
// <meta name="msapplication-TileColor" content = "#00aba9" >
|
|
14
15
|
|
|
15
16
|
const config = useConfig()
|
|
17
|
+
const themeColor = computed(() => isDark.value ? '#00aba9' : '#ffffff')
|
|
16
18
|
useHead({
|
|
17
19
|
title: config.value.title,
|
|
18
20
|
link: [
|
|
19
21
|
{
|
|
20
22
|
rel: 'icon',
|
|
21
23
|
href: config.value.favicon,
|
|
22
|
-
type: config.value.favicon
|
|
24
|
+
type: config.value.favicon?.endsWith('svg') ? 'image/svg+xml' : 'image/png',
|
|
23
25
|
},
|
|
24
26
|
],
|
|
25
27
|
meta: [
|
|
26
28
|
{ name: 'description', content: config.value.description },
|
|
27
29
|
{
|
|
28
30
|
name: 'theme-color',
|
|
29
|
-
content:
|
|
31
|
+
content: themeColor,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'msapplication-TileColor',
|
|
35
|
+
content: themeColor,
|
|
30
36
|
},
|
|
31
37
|
],
|
|
32
38
|
})
|
|
33
39
|
</script>
|
|
34
40
|
|
|
35
41
|
<template>
|
|
42
|
+
<ValaxyUserApp />
|
|
43
|
+
<ValaxyAddons />
|
|
36
44
|
<router-view />
|
|
37
45
|
</template>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
// @ts-expect-error virtual
|
|
3
|
+
import addonComponents from '/@valaxyjs/addons'
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<template>
|
|
7
|
+
<component :is="component" v-bind="props" v-for="({ component, props }, index) in addonComponents" :key="index" />
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<style lang="scss" scoped></style>
|
|
@@ -99,6 +99,11 @@ export function useCategory(category?: string, posts: Post[] = []): ParentCatego
|
|
|
99
99
|
}
|
|
100
100
|
})
|
|
101
101
|
|
|
102
|
+
categoryMap.children.forEach((child) => {
|
|
103
|
+
if ('posts' in child)
|
|
104
|
+
child.posts.sort((a, b) => (b.top || 0) - (a.top || 0))
|
|
105
|
+
})
|
|
106
|
+
|
|
102
107
|
// clear uncategorized
|
|
103
108
|
if (uncategorized!.total === 0)
|
|
104
109
|
categoryMap.children?.delete('Uncategorized')
|
|
@@ -7,7 +7,7 @@ import { useConfig } from '../config'
|
|
|
7
7
|
|
|
8
8
|
export function useFrontmatter() {
|
|
9
9
|
const route = useRoute()
|
|
10
|
-
const frontmatter = computed<Post>(() => route.meta.frontmatter)
|
|
10
|
+
const frontmatter = computed<Post>(() => route.meta.frontmatter || {})
|
|
11
11
|
|
|
12
12
|
return frontmatter
|
|
13
13
|
}
|
|
@@ -88,7 +88,7 @@ export function useActiveAnchor(
|
|
|
88
88
|
|
|
89
89
|
const scrollY = window.scrollY
|
|
90
90
|
const innerHeight = window.innerHeight
|
|
91
|
-
const offsetHeight =
|
|
91
|
+
const offsetHeight = container.value.offsetHeight
|
|
92
92
|
const isBottom = (scrollY + innerHeight) === offsetHeight
|
|
93
93
|
|
|
94
94
|
// console.log(scrollY, innerHeight, offsetHeight)
|
|
@@ -14,7 +14,25 @@ export const usePostTitle = (post: Ref<Post>) => {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* get
|
|
17
|
+
* get all page in 'pages' folder
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export function usePageList() {
|
|
21
|
+
const router = useRouter()
|
|
22
|
+
return computed<Post[]>(() => {
|
|
23
|
+
const excludePages = ['/:..all', '/:all(.*)*', '/']
|
|
24
|
+
const routes = router.getRoutes()
|
|
25
|
+
.filter(i => i.meta.frontmatter)
|
|
26
|
+
.filter(i => i.path && !excludePages.includes(i.path))
|
|
27
|
+
.map((i) => {
|
|
28
|
+
return Object.assign({ path: i.path, excerpt: i.meta.excerpt }, i.meta.frontmatter)
|
|
29
|
+
})
|
|
30
|
+
return routes
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* get post list in 'pages/posts' folder
|
|
18
36
|
* todo: use vue provide/inject to global
|
|
19
37
|
* @param params
|
|
20
38
|
* @returns
|
|
@@ -22,15 +40,12 @@ export const usePostTitle = (post: Ref<Post>) => {
|
|
|
22
40
|
export function usePostList(params: {
|
|
23
41
|
type?: string
|
|
24
42
|
} = {}) {
|
|
25
|
-
const router = useRouter()
|
|
26
43
|
return computed(() => {
|
|
27
|
-
const routes =
|
|
28
|
-
.filter(i => i.path
|
|
29
|
-
.filter(i => !i.path
|
|
30
|
-
.filter(i =>
|
|
31
|
-
.
|
|
32
|
-
return Object.assign({ path: i.path, excerpt: i.meta.excerpt }, i.meta.frontmatter)
|
|
33
|
-
})
|
|
44
|
+
const routes = usePageList().value
|
|
45
|
+
.filter(i => i.path?.startsWith('/posts'))
|
|
46
|
+
.filter(i => !i.path?.endsWith('.html'))
|
|
47
|
+
.filter(i => i.date)
|
|
48
|
+
.filter(i => !params.type || i.type === params.type)
|
|
34
49
|
|
|
35
50
|
/**
|
|
36
51
|
* 置顶
|
|
@@ -42,21 +57,6 @@ export function usePostList(params: {
|
|
|
42
57
|
})
|
|
43
58
|
}
|
|
44
59
|
|
|
45
|
-
/**
|
|
46
|
-
* get all page
|
|
47
|
-
* @returns
|
|
48
|
-
*/
|
|
49
|
-
export function usePageList() {
|
|
50
|
-
const router = useRouter()
|
|
51
|
-
return computed<Post[]>(() => {
|
|
52
|
-
const routes = router.getRoutes()
|
|
53
|
-
.map((i) => {
|
|
54
|
-
return Object.assign({ path: i.path, excerpt: i.meta.excerpt }, i.meta.frontmatter)
|
|
55
|
-
})
|
|
56
|
-
return routes
|
|
57
|
-
})
|
|
58
|
-
}
|
|
59
|
-
|
|
60
60
|
/**
|
|
61
61
|
* get prev and next post
|
|
62
62
|
* @param path
|
package/client/config.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-expect-error virtual module @valaxyjs/config
|
|
2
|
-
import
|
|
2
|
+
import valaxySiteConfig from '/@valaxyjs/site'
|
|
3
3
|
// @ts-expect-error virtual module @valaxyjs/context
|
|
4
4
|
import valaxyContext from '/@valaxyjs/context'
|
|
5
5
|
import type { ComputedRef, InjectionKey } from 'vue'
|
|
@@ -8,7 +8,7 @@ import { computed, inject, readonly, shallowRef } from 'vue'
|
|
|
8
8
|
// fix build caused by pnpm
|
|
9
9
|
// This is likely not portable. A type annotation is necessary.
|
|
10
10
|
// https://github.com/microsoft/TypeScript/issues/42873
|
|
11
|
-
import type {
|
|
11
|
+
import type { DefaultThemeConfig, SiteConfig as ValaxySiteConfig } from 'valaxy/types'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* parse valaxy config
|
|
@@ -24,16 +24,16 @@ interface ValaxyContext {
|
|
|
24
24
|
userRoot: string
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export const
|
|
28
|
-
export const
|
|
27
|
+
export const valaxySiteConfigSymbol: InjectionKey<ComputedRef<ValaxySiteConfig>> = Symbol('valaxy:site')
|
|
28
|
+
export const valaxySiteConfigRef = shallowRef<ValaxySiteConfig>(parse<ValaxySiteConfig>(valaxySiteConfig))
|
|
29
29
|
|
|
30
30
|
export const valaxyContextRef = shallowRef<ValaxyContext>(parse<ValaxyContext>(valaxyContext))
|
|
31
31
|
|
|
32
32
|
// hmr
|
|
33
33
|
if (import.meta.hot) {
|
|
34
|
-
// /@valaxyjs/
|
|
35
|
-
import.meta.hot.accept('/@valaxyjs/
|
|
36
|
-
|
|
34
|
+
// /@valaxyjs/site must be static string
|
|
35
|
+
import.meta.hot.accept('/@valaxyjs/site', (m) => {
|
|
36
|
+
valaxySiteConfigRef.value = parse<ValaxySiteConfig>(m.default)
|
|
37
37
|
})
|
|
38
38
|
|
|
39
39
|
// context
|
|
@@ -42,33 +42,43 @@ if (import.meta.hot) {
|
|
|
42
42
|
})
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export function
|
|
46
|
-
return computed(() =>
|
|
45
|
+
export function initSite() {
|
|
46
|
+
return computed(() => valaxySiteConfigRef.value)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export function initContext() {
|
|
50
50
|
return computed(() => valaxyContextRef.value)
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
/**
|
|
54
54
|
* get valaxy config
|
|
55
55
|
* @public
|
|
56
56
|
* @returns
|
|
57
57
|
*/
|
|
58
|
-
export function
|
|
59
|
-
const config = inject<ComputedRef<
|
|
58
|
+
export function useSite<ThemeConfig = DefaultThemeConfig>() {
|
|
59
|
+
const config = inject<ComputedRef<ValaxySiteConfig<ThemeConfig>>>(valaxySiteConfigSymbol)
|
|
60
60
|
if (!config)
|
|
61
|
-
throw new Error('[Valaxy] config not properly injected in app')
|
|
61
|
+
throw new Error('[Valaxy] site config not properly injected in app')
|
|
62
62
|
return config!
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* alias for useSite
|
|
67
|
+
* @public
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
export function useConfig<ThemeConfig = DefaultThemeConfig>() {
|
|
71
|
+
return useSite<ThemeConfig>()
|
|
72
|
+
}
|
|
73
|
+
|
|
65
74
|
/**
|
|
66
75
|
* You can use like this: import { useThemeConfig } from 'valaxy-theme-xxx'
|
|
67
76
|
* if you want to: import { useThemeConfig } from 'valaxy'
|
|
68
77
|
* you need pass themeConfig by yourself
|
|
78
|
+
* @internal
|
|
69
79
|
* @returns
|
|
70
80
|
*/
|
|
71
|
-
export function useThemeConfig<
|
|
72
|
-
const config =
|
|
81
|
+
export function useThemeConfig<ThemeConfig = DefaultThemeConfig>() {
|
|
82
|
+
const config = useSite<ThemeConfig>()
|
|
73
83
|
return computed(() => config!.value.themeConfig)
|
|
74
84
|
}
|
package/client/layouts/404.vue
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<router-view v-slot="{ Component }">
|
|
3
|
+
<component :is="Component">
|
|
4
|
+
<template #main-header>
|
|
5
|
+
<slot name="main-header" />
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<template #main-header-after>
|
|
9
|
+
<slot name="main-header-after" />
|
|
10
|
+
</template>
|
|
11
|
+
<template #main>
|
|
12
|
+
<slot name="main" />
|
|
13
|
+
</template>
|
|
14
|
+
<template #main-content>
|
|
15
|
+
<slot name="main-content" />
|
|
16
|
+
</template>
|
|
17
|
+
<template #main-content-after>
|
|
18
|
+
<slot name="main-content-after" />
|
|
19
|
+
</template>
|
|
20
|
+
<template #main-nav-before>
|
|
21
|
+
<slot name="main-nav-before" />
|
|
22
|
+
</template>
|
|
23
|
+
<template #main-nav-after>
|
|
24
|
+
<slot name="main-nav-after" />
|
|
25
|
+
</template>
|
|
26
|
+
<template #aside-custom>
|
|
27
|
+
<slot name="aside-custom" />
|
|
28
|
+
</template>
|
|
29
|
+
<template #footer>
|
|
30
|
+
<slot name="footer" />
|
|
31
|
+
</template>
|
|
32
|
+
</component>
|
|
33
|
+
</router-view>
|
|
34
|
+
</template>
|
package/client/modules/valaxy.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { useStorage } from '@vueuse/core'
|
|
|
12
12
|
|
|
13
13
|
import type { Router } from 'vue-router'
|
|
14
14
|
import type { PageDataPayload } from '../../types'
|
|
15
|
-
import {
|
|
15
|
+
import { initSite, valaxySiteConfigSymbol } from '../config'
|
|
16
16
|
import { ensureSuffix } from '@antfu/utils'
|
|
17
17
|
|
|
18
18
|
import type { UserModule } from 'valaxy/client/types'
|
|
@@ -45,8 +45,8 @@ function shouldHotReload(payload: PageDataPayload): boolean {
|
|
|
45
45
|
|
|
46
46
|
export const install: UserModule = ({ app, router }) => {
|
|
47
47
|
// inject valaxy config before modules
|
|
48
|
-
const config =
|
|
49
|
-
app.provide(
|
|
48
|
+
const config = initSite()
|
|
49
|
+
app.provide(valaxySiteConfigSymbol, config)
|
|
50
50
|
|
|
51
51
|
const locale = useStorage('valaxy-locale', config.value.lang || 'en')
|
|
52
52
|
|
package/client/setups.ts
CHANGED
|
@@ -1,49 +1,48 @@
|
|
|
1
1
|
@use "sass:map";
|
|
2
2
|
|
|
3
3
|
$breakpoints: (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
"sm": 640px,
|
|
5
|
+
"md": 768px,
|
|
6
|
+
"lg": 1024px,
|
|
7
|
+
"xl": 1280px,
|
|
8
|
+
"2xl": 1536px,
|
|
9
9
|
);
|
|
10
10
|
|
|
11
11
|
// for mobile
|
|
12
12
|
@mixin mobile {
|
|
13
|
-
@media screen and (max-width: map.get($breakpoints,
|
|
13
|
+
@media screen and (max-width: map.get($breakpoints, "sm")) {
|
|
14
14
|
@content;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
// for tablet
|
|
19
19
|
@mixin tablet {
|
|
20
|
-
@media screen and (min-width: map.get($breakpoints,
|
|
20
|
+
@media screen and (min-width: map.get($breakpoints, "sm")) and (max-width: map.get($breakpoints, "lg")) {
|
|
21
21
|
@content;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// for desktop
|
|
26
26
|
@mixin desktop {
|
|
27
|
-
@media screen and (min-width: map.get($breakpoints,
|
|
27
|
+
@media screen and (min-width: map.get($breakpoints, "lg")) {
|
|
28
28
|
@content;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
33
32
|
@mixin sm-md {
|
|
34
|
-
@media screen and (min-width: map.get($breakpoints,
|
|
33
|
+
@media screen and (min-width: map.get($breakpoints, "sm")) and (max-width: map.get($breakpoints, "md")) {
|
|
35
34
|
@content;
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
@mixin md-lg {
|
|
40
|
-
@media screen and (min-width: map.get($breakpoints,
|
|
39
|
+
@media screen and (min-width: map.get($breakpoints, "md")) and (max-width: map.get($breakpoints, "lg")) {
|
|
41
40
|
@content;
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
@mixin
|
|
46
|
-
@media screen and (min-width: map.get($breakpoints,
|
|
44
|
+
@mixin media($size) {
|
|
45
|
+
@media screen and (min-width: map.get($breakpoints, $size)) {
|
|
47
46
|
@content;
|
|
48
47
|
}
|
|
49
48
|
}
|
package/client/styles/vars.scss
CHANGED
|
@@ -4,12 +4,6 @@
|
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8">
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
-
<script>
|
|
8
|
-
(function () {
|
|
9
|
-
const locale = localStorage.getItem('valaxy-locale') || 'en'
|
|
10
|
-
document.documentElement.setAttribute('lang', locale)
|
|
11
|
-
})()
|
|
12
|
-
</script>
|
|
13
7
|
<!-- head -->
|
|
14
8
|
</head>
|
|
15
9
|
|