valaxy 0.1.0 → 0.2.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/bin/valaxy.js +1 -1
- package/dist/chunk-4LP5LOFC.js +86 -0
- package/dist/chunk-BDKTP6RW.js +1 -0
- package/dist/chunk-UVMBC7I3.mjs +1 -0
- package/dist/chunk-VLZSM7W4.mjs +86 -0
- package/dist/config-24b4f209.d.ts +188 -0
- package/dist/index.d.ts +316 -151
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{cli.d.ts → node/cli.d.ts} +0 -0
- package/dist/node/cli.js +45 -0
- package/dist/node/cli.mjs +45 -0
- package/dist/node/index.d.ts +46 -0
- package/dist/node/index.js +1 -0
- package/dist/node/index.mjs +1 -0
- package/package.json +22 -18
- package/src/client/components/PostCard.vue +1 -1
- package/src/client/components/PostList.vue +5 -5
- package/src/client/components/ValaxyCopyright.vue +1 -1
- package/src/client/components/ValaxyFooter.vue +1 -1
- package/src/client/components/ValaxyOverlay.vue +4 -4
- package/src/client/components/ValaxyPagination.vue +16 -14
- package/src/client/components/ValaxyRightSidebar.vue +4 -4
- package/src/client/components/ValaxySidebar.vue +4 -8
- package/src/client/components/ValaxyToc.vue +11 -9
- package/src/client/composables/comments/index.ts +1 -0
- package/src/client/composables/comments/twikoo.ts +37 -0
- package/src/client/composables/comments/waline.ts +8 -5
- package/src/client/composables/common.ts +3 -4
- package/src/client/composables/search/algolia.ts +2 -1
- package/src/client/composables/sidebar.ts +2 -2
- package/src/client/composables/tag.ts +9 -2
- package/src/client/composables/widgets/backToTop.ts +10 -4
- package/src/client/main.ts +1 -8
- package/src/client/modules/valaxy.ts +36 -15
- package/src/client/shims.d.ts +5 -5
- package/src/client/styles/common/button.scss +3 -5
- package/src/client/styles/common/code.scss +157 -0
- package/src/client/styles/common/hamburger.scss +2 -2
- package/src/client/styles/common/markdown.scss +6 -5
- package/src/client/styles/common/sidebar.scss +3 -3
- package/src/client/styles/common/transition.scss +2 -2
- package/src/client/styles/css-vars.scss +39 -0
- package/src/client/styles/global/helper.scss +2 -2
- package/src/client/styles/global/index.scss +1 -1
- package/src/client/styles/global/nprogress.scss +1 -1
- package/src/client/styles/global/reset.scss +2 -1
- package/src/client/styles/index.scss +12 -1
- package/src/client/styles/mixins/config.scss +1 -1
- package/src/client/styles/mixins/index.scss +1 -0
- package/src/client/styles/palette.scss +6 -8
- package/src/client/styles/vars.scss +1 -13
- package/src/client/styles/widgets/banner.scss +2 -2
- package/src/client/utils/index.ts +0 -2
- package/src/node/build.ts +20 -1
- package/src/node/cli.ts +32 -19
- package/src/node/markdown/highlight.ts +50 -0
- package/src/node/markdown/highlightLines.ts +96 -0
- package/src/node/markdown/index.ts +22 -11
- package/src/node/markdown/markdown-it-katex.ts +20 -10
- package/src/node/markdown/parseHeader.ts +4 -2
- package/src/node/options.ts +3 -1
- package/src/node/plugins/index.ts +53 -24
- package/src/node/plugins/markdown.ts +1 -1
- package/src/node/plugins/preset.ts +46 -10
- package/src/node/plugins/unocss.ts +12 -7
- package/src/node/rss.ts +121 -0
- package/src/node/server.ts +1 -1
- package/src/node/shims.d.ts +15 -0
- package/src/node/utils/cli.ts +0 -1
- package/src/node/vite.ts +7 -15
- package/src/types/config.ts +27 -2
- package/tsup.config.ts +1 -0
- package/dist/build-CLF7GOPQ.mjs +0 -1
- package/dist/build-F47TGGER.js +0 -1
- package/dist/chunk-5S6S3FLN.mjs +0 -83
- package/dist/chunk-JORQSKHF.mjs +0 -1
- package/dist/chunk-TOMJSB6R.js +0 -83
- package/dist/chunk-VJNIZVTJ.js +0 -1
- package/dist/cli.js +0 -6
- package/dist/cli.mjs +0 -6
- package/src/client/pages/about/index.md +0 -5
- package/src/client/pages/posts/index.md +0 -5
- package/src/client/styles/css-vars/dark.scss +0 -17
- package/src/client/styles/css-vars/index.scss +0 -18
- package/src/client/styles/css-vars/light.scss +0 -9
|
@@ -30,21 +30,24 @@ const surLen = computed(() => {
|
|
|
30
30
|
})
|
|
31
31
|
|
|
32
32
|
const showPage = (i: number) => {
|
|
33
|
-
if (i === 1)
|
|
34
|
-
|
|
33
|
+
if (i === 1)
|
|
34
|
+
return true
|
|
35
|
+
else if (i === totalPages.value)
|
|
36
|
+
return true
|
|
35
37
|
return i > props.curPage - surLen.value && i < props.curPage + surLen.value
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
const jumpTo = (page: number) => {
|
|
39
41
|
emit('page-change', page)
|
|
40
|
-
if (page === 1)
|
|
42
|
+
if (page === 1)
|
|
43
|
+
return '/'
|
|
41
44
|
else return `/page/${page}`
|
|
42
45
|
}
|
|
43
46
|
</script>
|
|
44
47
|
|
|
45
48
|
<template>
|
|
46
49
|
<nav class="pagination">
|
|
47
|
-
<router-link v-if="curPage !== 1" class="page-number" :to="jumpTo(curPage - 1)">
|
|
50
|
+
<router-link v-if="curPage !== 1" class="page-number" :to="jumpTo(curPage - 1)" aria-label="prev">
|
|
48
51
|
<div i-ri-arrow-left-s-line />
|
|
49
52
|
</router-link>
|
|
50
53
|
|
|
@@ -60,7 +63,7 @@ const jumpTo = (page: number) => {
|
|
|
60
63
|
</span>
|
|
61
64
|
</template>
|
|
62
65
|
|
|
63
|
-
<router-link v-if="curPage !== totalPages" class="page-number" :to="jumpTo(curPage + 1)">
|
|
66
|
+
<router-link v-if="curPage !== totalPages" class="page-number" :to="jumpTo(curPage + 1)" aria-label="next">
|
|
64
67
|
<div i-ri-arrow-right-s-line />
|
|
65
68
|
</router-link>
|
|
66
69
|
</nav>
|
|
@@ -69,12 +72,12 @@ const jumpTo = (page: number) => {
|
|
|
69
72
|
<style lang="scss">
|
|
70
73
|
:root {
|
|
71
74
|
--page-btn-bg-color: rgba(255, 255, 255, 0.5);
|
|
72
|
-
--page-btn-hover-bg-color: var(--
|
|
73
|
-
--page-btn-active-bg-color: var(--
|
|
75
|
+
--page-btn-hover-bg-color: var(--va-c-primary-lighter);
|
|
76
|
+
--page-btn-active-bg-color: var(--va-c-primary-light);
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
.dark {
|
|
77
|
-
--page-btn-bg-color: var(--
|
|
80
|
+
--page-btn-bg-color: var(--va-c-bg-light);
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
.pagination {
|
|
@@ -90,33 +93,32 @@ const jumpTo = (page: number) => {
|
|
|
90
93
|
width: 2rem;
|
|
91
94
|
height: 2rem;
|
|
92
95
|
margin: 0;
|
|
93
|
-
transition: background-color var(--
|
|
96
|
+
transition: background-color var(--va-transition-duration) ease;
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
.prev, .next, .page-number {
|
|
97
100
|
cursor: pointer;
|
|
98
101
|
|
|
99
|
-
color: var(--
|
|
102
|
+
color: var(--va-c-text);
|
|
100
103
|
text-decoration: none;
|
|
101
104
|
background-color: var(--page-btn-bg-color);
|
|
102
105
|
|
|
103
106
|
&:hover {
|
|
104
|
-
color: var(--
|
|
107
|
+
color: var(--va-c-bg);
|
|
105
108
|
background: var(--page-btn-hover-bg-color);
|
|
106
109
|
}
|
|
107
110
|
|
|
108
111
|
&:active {
|
|
109
|
-
color: var(--
|
|
112
|
+
color: var(--va-c-bg);
|
|
110
113
|
background: var(--page-btn-active-bg-color);
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
&.active {
|
|
114
117
|
font-weight: normal;
|
|
115
118
|
background: var(--page-btn-active-bg-color);
|
|
116
|
-
color: var(--
|
|
119
|
+
color: var(--va-c-bg);
|
|
117
120
|
cursor: default;
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
|
-
|
|
122
124
|
</style>
|
|
@@ -7,13 +7,13 @@ defineProps<{ frontmatter: Post }>()
|
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
9
|
<template>
|
|
10
|
-
<aside class="right-sidebar
|
|
11
|
-
<h2 v-if="frontmatter.toc" m="t-6 b-2" font="serif black">
|
|
10
|
+
<aside class="right-sidebar va-card relative" m="l-4" text="center">
|
|
11
|
+
<h2 v-if="frontmatter.toc !== false" m="t-6 b-2" font="serif black">
|
|
12
12
|
{{ t('sidebar.toc') }}
|
|
13
13
|
</h2>
|
|
14
14
|
|
|
15
15
|
<div class="right-sidebar-container sticky">
|
|
16
|
-
<ValaxyToc v-if="frontmatter.toc" />
|
|
16
|
+
<ValaxyToc v-if="frontmatter.toc !== false" />
|
|
17
17
|
|
|
18
18
|
<div v-if="$slots.custom" class="custom-container">
|
|
19
19
|
<slot name="custom" />
|
|
@@ -24,7 +24,7 @@ defineProps<{ frontmatter: Post }>()
|
|
|
24
24
|
|
|
25
25
|
<style lang="scss">
|
|
26
26
|
.right-sidebar {
|
|
27
|
-
width: var(--
|
|
27
|
+
width: var(--va-sidebar-width-mobile);
|
|
28
28
|
}
|
|
29
29
|
.right-sidebar-container {
|
|
30
30
|
top: 1rem;
|
|
@@ -11,25 +11,21 @@ const isHome = useLayout('home')
|
|
|
11
11
|
|
|
12
12
|
<ValaxyHamburger :active="app.isSidebarOpen" class="menu-btn sidebar-toggle yun-icon-btn" :class="isHome ? '' : 'md:hidden'" @click="app.toggleSidebar()" />
|
|
13
13
|
|
|
14
|
-
<aside class="
|
|
14
|
+
<aside class="va-card" :class="['sidebar', app.isSidebarOpen && 'open', !isHome && 'md:translate-x-0']">
|
|
15
15
|
<YunSidebar />
|
|
16
|
-
|
|
17
16
|
<YunConfig />
|
|
17
|
+
<slot />
|
|
18
18
|
</aside>
|
|
19
19
|
</template>
|
|
20
20
|
|
|
21
|
-
<style
|
|
22
|
-
@use "sass:map";
|
|
23
|
-
|
|
24
|
-
@use "~/styles/vars" as *;
|
|
25
|
-
|
|
21
|
+
<style>
|
|
26
22
|
.menu-btn {
|
|
27
23
|
display: inline-flex;
|
|
28
24
|
position: fixed;
|
|
29
25
|
left: 0.8rem;
|
|
30
26
|
top: 0.6rem;
|
|
31
27
|
line-height: 1;
|
|
32
|
-
z-index:
|
|
28
|
+
z-index: var(--yun-z-menu-btn);
|
|
33
29
|
cursor: pointer;
|
|
34
30
|
}
|
|
35
31
|
</style>
|
|
@@ -20,7 +20,7 @@ function getStylesByLevel(level: number) {
|
|
|
20
20
|
</script>
|
|
21
21
|
|
|
22
22
|
<template>
|
|
23
|
-
<ul class="
|
|
23
|
+
<ul class="va-toc" p="l-4">
|
|
24
24
|
<li v-for="header, i in headers" :key="i" :style="getStylesByLevel(header.level)">
|
|
25
25
|
<a class="toc-link-item" :href="`#${header.slug}`">{{ header.title }}</a>
|
|
26
26
|
</li>
|
|
@@ -28,14 +28,14 @@ function getStylesByLevel(level: number) {
|
|
|
28
28
|
</template>
|
|
29
29
|
|
|
30
30
|
<style lang="scss">
|
|
31
|
-
.
|
|
31
|
+
.va-toc {
|
|
32
32
|
top: 10px;
|
|
33
33
|
width: var(--yun-sidebar-width-mobile);
|
|
34
34
|
|
|
35
|
-
background-color: var(--
|
|
35
|
+
background-color: var(--va-c-bg-light);
|
|
36
36
|
|
|
37
37
|
font-size: 1rem;
|
|
38
|
-
font-family: var(--
|
|
38
|
+
font-family: var(--va-font-serif);
|
|
39
39
|
font-weight: 900;
|
|
40
40
|
line-height: 1.6;
|
|
41
41
|
|
|
@@ -44,26 +44,28 @@ function getStylesByLevel(level: number) {
|
|
|
44
44
|
a {
|
|
45
45
|
display: block;
|
|
46
46
|
color: var(--c-toc-link);
|
|
47
|
-
transition: color var(--
|
|
47
|
+
transition: color var(--va-transition-duration);
|
|
48
48
|
|
|
49
49
|
overflow: hidden;
|
|
50
50
|
white-space: nowrap;
|
|
51
51
|
text-overflow: ellipsis;
|
|
52
52
|
|
|
53
|
+
font-weight: 900;
|
|
54
|
+
|
|
53
55
|
&:hover {
|
|
54
|
-
color: var(--
|
|
56
|
+
color: var(--va-c-text);
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
.toc-link-item {
|
|
59
|
-
color: var(--
|
|
61
|
+
color: var(--va-c-text-light);
|
|
60
62
|
|
|
61
63
|
&:hover {
|
|
62
|
-
color: var(--
|
|
64
|
+
color: var(--va-c-text);
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
&.active {
|
|
66
|
-
color: var(--
|
|
68
|
+
color: var(--va-c-primary);
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isClient, useScriptTag } from '@vueuse/core'
|
|
2
|
+
import { useI18n } from 'vue-i18n'
|
|
3
|
+
import { useRoute } from 'vue-router'
|
|
4
|
+
|
|
5
|
+
export function useTwikoo(options: {} = {}) {
|
|
6
|
+
const route = useRoute()
|
|
7
|
+
|
|
8
|
+
const { locale } = useI18n()
|
|
9
|
+
|
|
10
|
+
let twikoo: any
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* init waline
|
|
14
|
+
* @param options waline options
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
function initTwikoo(options: {} = {}) {
|
|
18
|
+
if (!isClient)
|
|
19
|
+
return
|
|
20
|
+
|
|
21
|
+
const defaultOptions = {
|
|
22
|
+
el: '.comment #tcomment',
|
|
23
|
+
lang: locale.value,
|
|
24
|
+
path: route.path,
|
|
25
|
+
}
|
|
26
|
+
const twikooOptions = Object.assign(defaultOptions, options)
|
|
27
|
+
return window.twikoo.init(twikooOptions)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 直接使用 CDN
|
|
31
|
+
useScriptTag('//cdn.jsdelivr.net/npm/twikoo@1.5.1/dist/twikoo.all.min.js', () => {
|
|
32
|
+
twikoo = initTwikoo(options)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
// eslint-disable-next-line no-console
|
|
36
|
+
console.log(twikoo)
|
|
37
|
+
}
|
|
@@ -16,7 +16,8 @@ export function useWaline(options: {} = {}) {
|
|
|
16
16
|
* @returns
|
|
17
17
|
*/
|
|
18
18
|
function initWaline(options: {} = {}) {
|
|
19
|
-
if (!isClient)
|
|
19
|
+
if (!isClient)
|
|
20
|
+
return
|
|
20
21
|
|
|
21
22
|
const defaultOptions = {
|
|
22
23
|
el: '.comment #waline',
|
|
@@ -30,7 +31,6 @@ export function useWaline(options: {} = {}) {
|
|
|
30
31
|
path: route.path,
|
|
31
32
|
}
|
|
32
33
|
const walineOptions = Object.assign(defaultOptions, options)
|
|
33
|
-
// @ts-expect-error waline type
|
|
34
34
|
return window.Waline(walineOptions)
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -40,21 +40,24 @@ export function useWaline(options: {} = {}) {
|
|
|
40
40
|
})
|
|
41
41
|
|
|
42
42
|
watch(() => route.path, (path) => {
|
|
43
|
-
if (!waline)
|
|
43
|
+
if (!waline)
|
|
44
|
+
return
|
|
44
45
|
waline.update({
|
|
45
46
|
path,
|
|
46
47
|
})
|
|
47
48
|
})
|
|
48
49
|
|
|
49
50
|
watch(locale, (lang) => {
|
|
50
|
-
if (!waline)
|
|
51
|
+
if (!waline)
|
|
52
|
+
return
|
|
51
53
|
waline.update({
|
|
52
54
|
lang,
|
|
53
55
|
})
|
|
54
56
|
})
|
|
55
57
|
|
|
56
58
|
onUnmounted(() => {
|
|
57
|
-
if (!waline)
|
|
59
|
+
if (!waline)
|
|
60
|
+
return
|
|
58
61
|
waline.destroy()
|
|
59
62
|
})
|
|
60
63
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useRoute } from 'vue-router'
|
|
2
2
|
import { computed } from 'vue'
|
|
3
|
+
import { isClient } from '@vueuse/core'
|
|
3
4
|
|
|
4
|
-
import { isDev } from '../..'
|
|
5
5
|
import type { Post } from '../../types'
|
|
6
6
|
import { useConfig } from '../config'
|
|
7
7
|
|
|
@@ -9,8 +9,6 @@ export function useFrontmatter() {
|
|
|
9
9
|
const route = useRoute()
|
|
10
10
|
const frontmatter = computed<Post>(() => route.meta.frontmatter)
|
|
11
11
|
|
|
12
|
-
// eslint-disable-next-line no-console
|
|
13
|
-
if (isDev) console.log(frontmatter.value)
|
|
14
12
|
return frontmatter
|
|
15
13
|
}
|
|
16
14
|
|
|
@@ -21,7 +19,8 @@ export function useFullUrl() {
|
|
|
21
19
|
const config = useConfig()
|
|
22
20
|
const route = useRoute()
|
|
23
21
|
const url = computed(() => {
|
|
24
|
-
const
|
|
22
|
+
const siteUrl = config.value.url.endsWith('/') ? config.value.url.slice(0, -1) : config.value.url
|
|
23
|
+
const origin = siteUrl || (isClient && window.location.origin)
|
|
25
24
|
return origin + route.path
|
|
26
25
|
})
|
|
27
26
|
return url
|
|
@@ -30,7 +30,7 @@ export function useActiveSidebarLinks() {
|
|
|
30
30
|
deactiveLink(activeLink)
|
|
31
31
|
deactiveLink(rootActiveLink)
|
|
32
32
|
|
|
33
|
-
activeLink = document.querySelector(`.
|
|
33
|
+
activeLink = document.querySelector(`.va-toc a[href="${hash}"]`)
|
|
34
34
|
|
|
35
35
|
if (!activeLink)
|
|
36
36
|
return
|
|
@@ -70,7 +70,7 @@ export function useActiveSidebarLinks() {
|
|
|
70
70
|
|
|
71
71
|
function getSidebarLinks(): HTMLAnchorElement[] {
|
|
72
72
|
return [].slice.call(
|
|
73
|
-
document.querySelectorAll('.
|
|
73
|
+
document.querySelectorAll('.va-toc a.toc-link-item'),
|
|
74
74
|
)
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -9,11 +9,18 @@ export type Tags = Map<string, {
|
|
|
9
9
|
/**
|
|
10
10
|
* get utils about tags
|
|
11
11
|
*/
|
|
12
|
-
export function useTags(
|
|
12
|
+
export function useTags(options: {
|
|
13
|
+
/**
|
|
14
|
+
* Primary Color
|
|
15
|
+
*/
|
|
16
|
+
primary: string
|
|
17
|
+
} = {
|
|
18
|
+
primary: '#0078E7',
|
|
19
|
+
}) {
|
|
13
20
|
const tags = useTag()
|
|
14
21
|
|
|
15
22
|
const gray = new TinyColor('#999999')
|
|
16
|
-
const primaryColor = new TinyColor(
|
|
23
|
+
const primaryColor = new TinyColor(options.primary)
|
|
17
24
|
|
|
18
25
|
const getTagStyle = (count: number) => {
|
|
19
26
|
const counts = Array.from(tags).map(([_, value]) => value.count)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useWindowScroll } from '@vueuse/core'
|
|
2
|
-
import { computed } from 'vue'
|
|
1
|
+
import { isClient, useWindowScroll } from '@vueuse/core'
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* You can use href="#" to back to top
|
|
@@ -13,10 +13,16 @@ export function useBackToTop(options: {
|
|
|
13
13
|
} = {
|
|
14
14
|
offset: 100,
|
|
15
15
|
}) {
|
|
16
|
-
|
|
16
|
+
if (!isClient) {
|
|
17
|
+
return {
|
|
18
|
+
percentage: ref(0),
|
|
19
|
+
show: ref(false),
|
|
20
|
+
}
|
|
21
|
+
}
|
|
17
22
|
|
|
23
|
+
const { y } = useWindowScroll()
|
|
18
24
|
const percentage = computed(() => {
|
|
19
|
-
return y.value / document.body.
|
|
25
|
+
return y.value / (document.body.scrollHeight - window.innerHeight)
|
|
20
26
|
})
|
|
21
27
|
|
|
22
28
|
const show = computed(() => y.value > options.offset)
|
package/src/client/main.ts
CHANGED
|
@@ -5,14 +5,7 @@ import App from './App.vue'
|
|
|
5
5
|
|
|
6
6
|
import '@unocss/reset/tailwind.css'
|
|
7
7
|
|
|
8
|
-
//
|
|
9
|
-
import 'star-markdown-css/src/scss/theme/yun.scss'
|
|
10
|
-
|
|
11
|
-
import './styles/css-vars/index.scss'
|
|
12
|
-
import './styles/css-vars/light.scss'
|
|
13
|
-
import './styles/css-vars/dark.scss'
|
|
14
|
-
import './styles/index.scss'
|
|
15
|
-
|
|
8
|
+
// generate user styles
|
|
16
9
|
import '/@valaxyjs/styles'
|
|
17
10
|
|
|
18
11
|
import 'uno.css'
|
|
@@ -1,19 +1,35 @@
|
|
|
1
1
|
import { createI18n } from 'vue-i18n'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* All i18n resources specified in the plugin `include` option can be loaded
|
|
5
|
+
* at once using the import syntax
|
|
6
|
+
*
|
|
7
|
+
* Not support ssr https://github.com/intlify/bundle-tools/issues/78
|
|
8
|
+
*/
|
|
9
|
+
// import messages from '@intlify/vite-plugin-vue-i18n/messages'
|
|
10
|
+
|
|
2
11
|
import { initConfig, valaxyConfigSymbol } from '../config'
|
|
12
|
+
|
|
3
13
|
import type { UserModule } from '~/types'
|
|
4
14
|
|
|
15
|
+
// @ts-expect-error virtual
|
|
16
|
+
import messages from '/@valaxyjs/locales'
|
|
17
|
+
|
|
5
18
|
// Import i18n resources
|
|
6
19
|
// https://vitejs.dev/guide/features.html#glob-import
|
|
7
20
|
//
|
|
8
21
|
// Don't need this? Try vitesse-lite: https://github.com/antfu/vitesse-lite
|
|
9
|
-
const messages = Object.fromEntries(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
)
|
|
22
|
+
// const messages = Object.fromEntries(
|
|
23
|
+
// Object.entries(
|
|
24
|
+
// import.meta.globEager('../locales/*.y(a)?ml'))
|
|
25
|
+
// .map(([key, value]) => {
|
|
26
|
+
// const yaml = key.endsWith('.yaml')
|
|
27
|
+
// return [key.slice(11, yaml ? -5 : -4), value.default]
|
|
28
|
+
// }),
|
|
29
|
+
// )
|
|
30
|
+
|
|
31
|
+
// import zh from '../../../../../demo/yun/locales/zh-CN.yml'
|
|
32
|
+
// import en from '../../../../../demo/yun/locales/en.yml'
|
|
17
33
|
|
|
18
34
|
function shouldHotReload(payload: any): boolean {
|
|
19
35
|
const payloadPath = payload.path.replace(/(\bindex)?\.md$/, '')
|
|
@@ -24,19 +40,24 @@ function shouldHotReload(payload: any): boolean {
|
|
|
24
40
|
// https://github.com/antfu/vite-plugin-pwa#automatic-reload-when-new-content-available
|
|
25
41
|
export const install: UserModule = ({ app, router }) => {
|
|
26
42
|
// inject valaxy config before modules
|
|
27
|
-
const
|
|
28
|
-
app.provide(valaxyConfigSymbol,
|
|
43
|
+
const config = initConfig()
|
|
44
|
+
app.provide(valaxyConfigSymbol, config)
|
|
45
|
+
|
|
46
|
+
// const {} = await import()
|
|
29
47
|
|
|
30
48
|
// init i18n, by valaxy config
|
|
31
49
|
const i18n = createI18n({
|
|
32
50
|
legacy: false,
|
|
33
|
-
locale:
|
|
51
|
+
locale: config.value.lang || 'en',
|
|
34
52
|
messages,
|
|
35
53
|
})
|
|
36
54
|
app.use(i18n)
|
|
37
55
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
56
|
+
// for dev
|
|
57
|
+
if (__DEV__) {
|
|
58
|
+
import.meta.hot!.on('valaxy:pageHeaders', (payload) => {
|
|
59
|
+
if (shouldHotReload(payload))
|
|
60
|
+
router.currentRoute.value.meta.headers = payload.pageHeaders
|
|
61
|
+
})
|
|
62
|
+
}
|
|
42
63
|
}
|
package/src/client/shims.d.ts
CHANGED
|
@@ -3,11 +3,6 @@ import 'vue-router'
|
|
|
3
3
|
import type { Post } from 'valaxy'
|
|
4
4
|
import type { Header } from '../node/markdown'
|
|
5
5
|
|
|
6
|
-
declare interface Window {
|
|
7
|
-
// extend the window
|
|
8
|
-
Waline: any
|
|
9
|
-
}
|
|
10
|
-
|
|
11
6
|
// with vite-plugin-md, markdowns can be treat as Vue components
|
|
12
7
|
declare module '*.md' {
|
|
13
8
|
import type { DefineComponent } from 'vue'
|
|
@@ -28,6 +23,11 @@ declare module '@valaxyjs/config' {
|
|
|
28
23
|
export default config
|
|
29
24
|
}
|
|
30
25
|
|
|
26
|
+
declare module '/@valaxyjs/locales' {
|
|
27
|
+
const messages: {}
|
|
28
|
+
export default messages
|
|
29
|
+
}
|
|
30
|
+
|
|
31
31
|
declare module 'vue-router' {
|
|
32
32
|
interface RouteMeta {
|
|
33
33
|
headers: Header[]
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
@use "../palette.scss" as * ;
|
|
2
|
-
|
|
3
1
|
.yun-icon-btn {
|
|
4
2
|
cursor: pointer;
|
|
5
3
|
|
|
@@ -13,17 +11,17 @@
|
|
|
13
11
|
|
|
14
12
|
border-radius: 50%;
|
|
15
13
|
|
|
16
|
-
transition: var(--
|
|
14
|
+
transition: background-color var(--va-transition-duration);
|
|
17
15
|
|
|
18
16
|
div {
|
|
19
17
|
font-size: 1.2rem;
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
&:hover {
|
|
23
|
-
background-color: rgba(var(--
|
|
21
|
+
background-color: rgba(var(--va-c-primary-rgb), 0.08);
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
&:active {
|
|
27
|
-
background-color: rgba(var(--
|
|
25
|
+
background-color: rgba(var(--va-c-primary-rgb), 0.16);
|
|
28
26
|
}
|
|
29
27
|
}
|