valaxy 0.0.9 → 0.1.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/dist/chunk-5D7M5SQP.js +1 -0
- package/dist/chunk-CF6MGLH2.mjs +84 -0
- package/dist/chunk-L22LX2G6.mjs +1 -0
- package/dist/chunk-W5MJCUNY.js +84 -0
- package/dist/index.d.ts +9 -5
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/node/cli.js +5 -87
- package/dist/node/cli.mjs +5 -87
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1 -83
- package/dist/node/index.mjs +1 -83
- package/package.json +20 -19
- 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/waline.ts +8 -4
- package/src/client/composables/common.ts +2 -4
- package/src/client/composables/search/algolia.ts +2 -1
- package/src/client/composables/sidebar.ts +2 -2
- package/src/client/composables/tag.ts +1 -1
- package/src/client/composables/widgets/backToTop.ts +10 -4
- package/src/client/main.ts +1 -6
- package/src/client/modules/valaxy.ts +36 -15
- package/src/client/shims.d.ts +5 -0
- package/src/client/styles/common/button.scss +3 -5
- package/src/client/styles/common/hamburger.scss +2 -2
- package/src/client/styles/common/markdown.scss +6 -2
- package/src/client/styles/common/sidebar.scss +3 -3
- package/src/client/styles/common/transition.scss +2 -2
- package/src/client/styles/{css-vars/index.scss → css-vars.scss} +22 -8
- 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/mixins/config.scss +1 -1
- package/src/client/styles/mixins/index.scss +1 -0
- package/src/client/styles/palette.scss +14 -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 +17 -19
- package/src/node/markdown/index.ts +3 -1
- 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 +47 -10
- package/src/node/plugins/unocss.ts +12 -7
- package/src/node/server.ts +1 -1
- package/src/node/shims.d.ts +5 -0
- package/src/node/utils/cli.ts +0 -1
- package/src/node/vite.ts +10 -17
- package/tsup.config.ts +3 -2
- package/src/client/pages/about/index.md +0 -5
- package/src/client/styles/css-vars/dark.scss +0 -17
- package/src/client/styles/css-vars/light.scss +0 -9
|
@@ -19,7 +19,7 @@ $hamburger-size: 22px;
|
|
|
19
19
|
.vt-hamburger.is-active:hover .vt-hamburger-top,
|
|
20
20
|
.vt-hamburger.is-active:hover .vt-hamburger-middle,
|
|
21
21
|
.vt-hamburger.is-active:hover .vt-hamburger-bottom {
|
|
22
|
-
background-color: var(--
|
|
22
|
+
background-color: var(--va-c-primary);
|
|
23
23
|
transition: top .25s, background-color .25s, transform .25s;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -38,7 +38,7 @@ $hamburger-size: 22px;
|
|
|
38
38
|
position: absolute;
|
|
39
39
|
width: $hamburger-size;
|
|
40
40
|
height: 2px;
|
|
41
|
-
background-color: var(--
|
|
41
|
+
background-color: var(--va-c-primary);
|
|
42
42
|
transition: top .25s, background-color .5s, transform .25s;
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
@use './code.scss' as *;
|
|
4
4
|
|
|
5
5
|
.markdown-body {
|
|
6
|
-
--prism-font-family: var(--
|
|
6
|
+
--prism-font-family: var(--va-font-mono);
|
|
7
7
|
|
|
8
|
-
--smc-link-color: var(--
|
|
8
|
+
--smc-link-color: var(--va-c-link);
|
|
9
|
+
--smc-font-family: var(--va-font-sans);
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
// for anchor
|
|
@@ -21,6 +22,7 @@ h5:hover .header-anchor,
|
|
|
21
22
|
h5:focus .header-anchor,
|
|
22
23
|
h6:hover .header-anchor,
|
|
23
24
|
h6:focus .header-anchor {
|
|
25
|
+
visibility: visible;
|
|
24
26
|
opacity: 1;
|
|
25
27
|
}
|
|
26
28
|
|
|
@@ -30,7 +32,9 @@ a.header-anchor {
|
|
|
30
32
|
margin-left: -0.87em;
|
|
31
33
|
padding-right: 0.23em;
|
|
32
34
|
font-size: 0.85em;
|
|
35
|
+
visibility: hidden;
|
|
33
36
|
opacity: 0;
|
|
37
|
+
transition: opacity var(--va-transition-duration);
|
|
34
38
|
|
|
35
39
|
&::before {
|
|
36
40
|
content: none;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
left: 0;
|
|
12
12
|
|
|
13
13
|
width: calc(100vw - 64px);
|
|
14
|
-
max-width: var(--
|
|
14
|
+
max-width: var(--va-sidebar-width-mobile);
|
|
15
15
|
|
|
16
16
|
background-image: var(--yun-sidebar-bg-image);
|
|
17
17
|
background-color: var(--yun-sidebar-bg-color);
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
background-repeat: no-repeat;
|
|
20
20
|
background-position: bottom 1rem center;
|
|
21
21
|
text-align: center;
|
|
22
|
-
z-index:
|
|
22
|
+
z-index: var(--yun-z-sidebar);
|
|
23
23
|
|
|
24
24
|
transform: translateX(-100%);
|
|
25
|
-
transition: transform var(--
|
|
25
|
+
transition: transform var(--va-transition-duration);
|
|
26
26
|
|
|
27
27
|
&.open {
|
|
28
28
|
transform: translateX(0);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.v {
|
|
2
2
|
&-enter-active,
|
|
3
3
|
&-leave-active {
|
|
4
|
-
transition: opacity 0.
|
|
4
|
+
transition: opacity var(--va-transition-duration, 0.4s) ease;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
&-enter-from,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
.fade {
|
|
14
14
|
&-enter-active,
|
|
15
15
|
&-leave-active {
|
|
16
|
-
transition: opacity 0.
|
|
16
|
+
transition: opacity var(--va-transition-duration, 0.4s) ease;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
&-enter-from,
|
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
@use "sass:map";
|
|
2
|
-
@use "
|
|
3
|
-
@use "
|
|
4
|
-
@use "
|
|
2
|
+
@use "./mixins" as *;
|
|
3
|
+
@use "./vars" as *;
|
|
4
|
+
@use "./palette" as *;
|
|
5
5
|
|
|
6
|
+
// common
|
|
7
|
+
:root {
|
|
8
|
+
@include set-css-var-from-map($common);
|
|
9
|
+
@include set-css-var-from-map($border, 'border');
|
|
10
|
+
@include set-css-var-from-map($font, 'font');
|
|
11
|
+
@include set-css-var-from-map($transition, 'transition');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// colors
|
|
6
15
|
:root {
|
|
7
16
|
// palette different with colors
|
|
8
17
|
@include set-css-var-from-map($palette, 'c');
|
|
18
|
+
// primary
|
|
19
|
+
@include set-css-var-from-map($colors, 'c');
|
|
9
20
|
}
|
|
10
21
|
|
|
22
|
+
// light
|
|
11
23
|
:root {
|
|
12
|
-
|
|
13
|
-
@include set-css-var-from-map($
|
|
14
|
-
@include set-css-var-from-map($font, 'font');
|
|
15
|
-
@include set-css-var-from-map($z-index, 'z');
|
|
16
|
-
@include set-css-var-from-map($transition, 'transition');
|
|
24
|
+
color-scheme: light;
|
|
25
|
+
@include set-css-var-from-map($light);
|
|
17
26
|
}
|
|
18
27
|
|
|
28
|
+
// dark
|
|
29
|
+
html.dark {
|
|
30
|
+
color-scheme: dark;
|
|
31
|
+
@include set-css-var-from-map($dark);
|
|
32
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
.
|
|
2
|
-
background-color: var(--
|
|
1
|
+
.va-card {
|
|
2
|
+
background-color: var(--va-c-bg-light);
|
|
3
3
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
$namespace: '
|
|
1
|
+
$namespace: 'va' !default;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
@use "sass:map";
|
|
2
|
+
@use "sass:meta";
|
|
2
3
|
|
|
3
4
|
@use "./mixins" as *;
|
|
4
5
|
|
|
@@ -16,18 +17,26 @@ $colors: map.merge((
|
|
|
16
17
|
'primary': #0078E7,
|
|
17
18
|
), $colors);
|
|
18
19
|
|
|
19
|
-
$c-primary
|
|
20
|
+
// @debug $yun-c-primary;
|
|
21
|
+
// $yun-c-primary: #0078E7 !default;
|
|
22
|
+
// @if meta.variable-exists('yun-c-primary') {
|
|
23
|
+
// $colors: map.merge((
|
|
24
|
+
// 'primary': $yun-c-primary,
|
|
25
|
+
// ), $colors);
|
|
26
|
+
// }
|
|
27
|
+
|
|
28
|
+
$c-primary: map.get($colors, 'primary') !default;
|
|
20
29
|
|
|
21
30
|
$colors: map.merge((
|
|
22
31
|
'primary-light': lighten($c-primary, 15%),
|
|
23
32
|
'primary-lighter': lighten($c-primary, 30%),
|
|
33
|
+
'primary-dark': darken($c-primary, 5%),
|
|
24
34
|
), $colors);
|
|
25
35
|
|
|
26
36
|
|
|
27
37
|
$light: () !default;
|
|
28
38
|
$light: map.merge((
|
|
29
|
-
'
|
|
30
|
-
'border-color': #e6e6e6,
|
|
39
|
+
'border-color': #222,
|
|
31
40
|
|
|
32
41
|
'c-bg': white,
|
|
33
42
|
'c-bg-light': white,
|
|
@@ -38,15 +47,12 @@ $light: map.merge((
|
|
|
38
47
|
|
|
39
48
|
'c-primary-rgb': #{red($c-primary), green($c-primary), blue($c-primary)},
|
|
40
49
|
|
|
41
|
-
'c-link':
|
|
42
|
-
|
|
43
|
-
'sidebar-bg-color': #{get-css-var('c-bg-light')}
|
|
50
|
+
'c-link': get-css-var('c-primary-dark'),
|
|
44
51
|
), $light);
|
|
45
52
|
|
|
46
53
|
$dark: () !default;
|
|
47
54
|
$dark: map.merge((
|
|
48
|
-
'
|
|
49
|
-
'border-color': #222,
|
|
55
|
+
'border-color': #e6e6e6,
|
|
50
56
|
|
|
51
57
|
'c-bg': #1a1a1a,
|
|
52
58
|
'c-bg-light': #22252e,
|
|
@@ -18,22 +18,10 @@ $font: map.merge((
|
|
|
18
18
|
'serif-weight': 900,
|
|
19
19
|
), $font);
|
|
20
20
|
|
|
21
|
-
$z-index: () !default;
|
|
22
|
-
$z-index: map.merge((
|
|
23
|
-
'cloud': 8,
|
|
24
|
-
'go-down': 9,
|
|
25
|
-
'sidebar': 10,
|
|
26
|
-
'fireworks': 11,
|
|
27
|
-
'menu-btn': 20,
|
|
28
|
-
'go-up-btn': 20,
|
|
29
|
-
'search-popup': 30,
|
|
30
|
-
'search-btn': 31,
|
|
31
|
-
), $z-index);
|
|
32
|
-
|
|
33
21
|
$transition: () !default;
|
|
34
22
|
$transition: map.merge((
|
|
35
23
|
'duration-fast': 0.2s,
|
|
36
24
|
'duration': 0.4s,
|
|
37
25
|
'duration-slow': 0.6s,
|
|
38
|
-
'': all var(--
|
|
26
|
+
'': all var(--va-transition-duration-fast) ease-in-out
|
|
39
27
|
), $transition);
|
|
@@ -70,7 +70,7 @@ $char-animation-duration: 0.4s;
|
|
|
70
70
|
|
|
71
71
|
&-left {
|
|
72
72
|
border-left: 1px solid var(--banner-line-color);
|
|
73
|
-
border-right: 0px solid rgba(var(--
|
|
73
|
+
border-right: 0px solid rgba(var(--va-c-primary-rgb), 0.1);
|
|
74
74
|
border-right-width: 0px;
|
|
75
75
|
animation-name: char-move-left;
|
|
76
76
|
animation-duration: $char-animation-duration;
|
|
@@ -80,7 +80,7 @@ $char-animation-duration: 0.4s;
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
&-right {
|
|
83
|
-
border-left: 0px solid rgba(var(--
|
|
83
|
+
border-left: 0px solid rgba(var(--va-c-primary-rgb), 0.1);
|
|
84
84
|
border-right: 1px solid var(--banner-line-color);
|
|
85
85
|
border-left-width: 0px;
|
|
86
86
|
animation-name: char-move-right;
|
package/src/node/build.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { InlineConfig } from 'vite'
|
|
2
2
|
import { mergeConfig, build as viteBuild } from 'vite'
|
|
3
|
+
import { build as viteSsgBuild } from 'vite-ssg/node'
|
|
4
|
+
import generateSitemap from 'vite-ssg-sitemap'
|
|
5
|
+
|
|
3
6
|
import type { ResolvedValaxyOptions } from './options'
|
|
4
7
|
import { createViteConfig } from './vite'
|
|
5
8
|
|
|
@@ -7,6 +10,22 @@ export async function build(
|
|
|
7
10
|
options: ResolvedValaxyOptions,
|
|
8
11
|
viteConfig: InlineConfig = {},
|
|
9
12
|
) {
|
|
10
|
-
const inlineConfig = mergeConfig(
|
|
13
|
+
const inlineConfig = mergeConfig(await createViteConfig(options), viteConfig)
|
|
11
14
|
await viteBuild(inlineConfig)
|
|
12
15
|
}
|
|
16
|
+
|
|
17
|
+
export async function ssgBuild(
|
|
18
|
+
options: ResolvedValaxyOptions,
|
|
19
|
+
viteConfig: InlineConfig = {},
|
|
20
|
+
) {
|
|
21
|
+
const inlineConfig: InlineConfig = mergeConfig(await createViteConfig(options), viteConfig)
|
|
22
|
+
|
|
23
|
+
// https://github.com/antfu/vite-ssg
|
|
24
|
+
inlineConfig.ssgOptions = {
|
|
25
|
+
script: 'async',
|
|
26
|
+
formatting: 'minify',
|
|
27
|
+
onFinished() { generateSitemap() },
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
await viteSsgBuild({}, inlineConfig)
|
|
31
|
+
}
|
package/src/node/cli.ts
CHANGED
|
@@ -6,15 +6,15 @@ import yargs from 'yargs'
|
|
|
6
6
|
import type { InlineConfig, LogLevel } from 'vite'
|
|
7
7
|
import openBrowser from 'open'
|
|
8
8
|
|
|
9
|
-
// @ts-expect-error https://github.com/antfu/vite-ssg/pull/225
|
|
10
|
-
import { build as ssgBuild } from 'vite-ssg/node'
|
|
11
|
-
|
|
12
9
|
import consola from 'consola'
|
|
13
10
|
|
|
14
11
|
import { version } from '../../package.json'
|
|
15
12
|
import { resolveOptions } from './options'
|
|
16
13
|
import { bindShortcut, initServer, printInfo } from './utils/cli'
|
|
17
14
|
|
|
15
|
+
// build
|
|
16
|
+
import { build, ssgBuild } from './build'
|
|
17
|
+
|
|
18
18
|
const cli = yargs.scriptName('valaxy')
|
|
19
19
|
.usage('$0 [args]')
|
|
20
20
|
.version(version)
|
|
@@ -121,22 +121,29 @@ cli.command(
|
|
|
121
121
|
describe: 'output dir',
|
|
122
122
|
}).option('base', {
|
|
123
123
|
type: 'string',
|
|
124
|
+
default: '/',
|
|
124
125
|
describe: 'output base',
|
|
125
126
|
})
|
|
126
127
|
.strict()
|
|
127
128
|
.help(),
|
|
128
129
|
async({ ssg, root, base, output }) => {
|
|
129
|
-
const options = await resolveOptions({ userRoot: root })
|
|
130
|
+
const options = await resolveOptions({ userRoot: root }, 'build')
|
|
130
131
|
printInfo(options)
|
|
131
132
|
|
|
133
|
+
const viteConfig = {
|
|
134
|
+
base,
|
|
135
|
+
build: {
|
|
136
|
+
// make out dir empty, https://vitejs.dev/config/#build-emptyoutdir
|
|
137
|
+
emptyOutDir: true,
|
|
138
|
+
outDir: path.resolve(options.userRoot, output),
|
|
139
|
+
},
|
|
140
|
+
}
|
|
141
|
+
|
|
132
142
|
if (ssg) {
|
|
133
143
|
consola.info('use vite-ssg to do ssg build...')
|
|
144
|
+
|
|
134
145
|
try {
|
|
135
|
-
|
|
136
|
-
// https://github.com/antfu/vite-ssg/issues/226
|
|
137
|
-
await ssgBuild({
|
|
138
|
-
mode: 'production',
|
|
139
|
-
})
|
|
146
|
+
await ssgBuild(options, viteConfig)
|
|
140
147
|
}
|
|
141
148
|
catch (e) {
|
|
142
149
|
consola.error('[vite-ssg] An internal error occurred.')
|
|
@@ -144,17 +151,8 @@ cli.command(
|
|
|
144
151
|
}
|
|
145
152
|
}
|
|
146
153
|
else {
|
|
147
|
-
const { build } = await import('./build')
|
|
148
|
-
|
|
149
154
|
consola.info('use vite do spa build...')
|
|
150
|
-
await build(options,
|
|
151
|
-
base,
|
|
152
|
-
build: {
|
|
153
|
-
// make out dir empty, https://vitejs.dev/config/#build-emptyoutdir
|
|
154
|
-
emptyOutDir: true,
|
|
155
|
-
outDir: path.resolve(options.userRoot, output),
|
|
156
|
-
},
|
|
157
|
-
})
|
|
155
|
+
await build(options, viteConfig)
|
|
158
156
|
}
|
|
159
157
|
},
|
|
160
158
|
)
|
|
@@ -5,6 +5,7 @@ import Emoji from 'markdown-it-emoji'
|
|
|
5
5
|
import Prism from 'markdown-it-prism'
|
|
6
6
|
import LinkAttributes from 'markdown-it-link-attributes'
|
|
7
7
|
import TOC from 'markdown-it-table-of-contents'
|
|
8
|
+
import TaskLists from 'markdown-it-task-lists'
|
|
8
9
|
|
|
9
10
|
import type { KatexOptions } from 'katex'
|
|
10
11
|
import Katex from '../markdown/markdown-it-katex'
|
|
@@ -58,11 +59,12 @@ export function setupMarkdownPlugins(md: MarkdownIt, mdOptions: MarkdownOptions
|
|
|
58
59
|
})
|
|
59
60
|
.use(TOC, {
|
|
60
61
|
slugify,
|
|
61
|
-
includeLevel: [2, 3],
|
|
62
|
+
includeLevel: [2, 3, 4],
|
|
62
63
|
format: parseHeader,
|
|
63
64
|
...mdOptions.toc,
|
|
64
65
|
})
|
|
65
66
|
.use(Emoji)
|
|
67
|
+
.use(TaskLists)
|
|
66
68
|
|
|
67
69
|
const originalRender = md.render
|
|
68
70
|
md.render = (...args) => {
|
|
@@ -41,11 +41,13 @@ function isValidDelim(state: any, pos: number) {
|
|
|
41
41
|
function math_inline(state: any, silent: boolean) {
|
|
42
42
|
let match, token, res, pos
|
|
43
43
|
|
|
44
|
-
if (state.src[state.pos] !== '$')
|
|
44
|
+
if (state.src[state.pos] !== '$')
|
|
45
|
+
return false
|
|
45
46
|
|
|
46
47
|
res = isValidDelim(state, state.pos)
|
|
47
48
|
if (!res.can_open) {
|
|
48
|
-
if (!silent)
|
|
49
|
+
if (!silent)
|
|
50
|
+
state.pending += '$'
|
|
49
51
|
state.pos += 1
|
|
50
52
|
return true
|
|
51
53
|
}
|
|
@@ -64,20 +66,23 @@ function math_inline(state: any, silent: boolean) {
|
|
|
64
66
|
while (state.src[pos] === '\\') pos -= 1
|
|
65
67
|
|
|
66
68
|
// Even number of escapes, potential closing delimiter found
|
|
67
|
-
if (((match - pos) % 2) === 1)
|
|
69
|
+
if (((match - pos) % 2) === 1)
|
|
70
|
+
break
|
|
68
71
|
match += 1
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
// No closing delimter found. Consume $ and continue.
|
|
72
75
|
if (match === -1) {
|
|
73
|
-
if (!silent)
|
|
76
|
+
if (!silent)
|
|
77
|
+
state.pending += '$'
|
|
74
78
|
state.pos = start
|
|
75
79
|
return true
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
// Check if we have empty content, ie: $$. Do not parse.
|
|
79
83
|
if (match - start === 0) {
|
|
80
|
-
if (!silent)
|
|
84
|
+
if (!silent)
|
|
85
|
+
state.pending += '$$'
|
|
81
86
|
state.pos = start + 1
|
|
82
87
|
return true
|
|
83
88
|
}
|
|
@@ -85,7 +90,8 @@ function math_inline(state: any, silent: boolean) {
|
|
|
85
90
|
// Check for valid closing delimiter
|
|
86
91
|
res = isValidDelim(state, match)
|
|
87
92
|
if (!res.can_close) {
|
|
88
|
-
if (!silent)
|
|
93
|
+
if (!silent)
|
|
94
|
+
state.pending += '$'
|
|
89
95
|
state.pos = start
|
|
90
96
|
return true
|
|
91
97
|
}
|
|
@@ -106,13 +112,16 @@ function math_block(state: any, start: number, end: number, silent: boolean) {
|
|
|
106
112
|
let pos = state.bMarks[start] + state.tShift[start]
|
|
107
113
|
let max = state.eMarks[start]
|
|
108
114
|
|
|
109
|
-
if (pos + 2 > max)
|
|
110
|
-
|
|
115
|
+
if (pos + 2 > max)
|
|
116
|
+
return false
|
|
117
|
+
if (state.src.slice(pos, pos + 2) !== '$$')
|
|
118
|
+
return false
|
|
111
119
|
|
|
112
120
|
pos += 2
|
|
113
121
|
firstLine = state.src.slice(pos, max)
|
|
114
122
|
|
|
115
|
-
if (silent)
|
|
123
|
+
if (silent)
|
|
124
|
+
return true
|
|
116
125
|
if (firstLine.trim().slice(-2) === '$$') {
|
|
117
126
|
// Single line expression
|
|
118
127
|
firstLine = firstLine.trim().slice(0, -2)
|
|
@@ -122,7 +131,8 @@ function math_block(state: any, start: number, end: number, silent: boolean) {
|
|
|
122
131
|
for (next = start; !found;) {
|
|
123
132
|
next++
|
|
124
133
|
|
|
125
|
-
if (next >= end)
|
|
134
|
+
if (next >= end)
|
|
135
|
+
break
|
|
126
136
|
|
|
127
137
|
pos = state.bMarks[next] + state.tShift[next]
|
|
128
138
|
max = state.eMarks[next]
|
|
@@ -48,8 +48,10 @@ export const removeNonCodeWrappedHTML = (str: string) => {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const compose = (...processors: ((str: string) => string)[]) => {
|
|
51
|
-
if (processors.length === 0)
|
|
52
|
-
|
|
51
|
+
if (processors.length === 0)
|
|
52
|
+
return (input: string) => input
|
|
53
|
+
if (processors.length === 1)
|
|
54
|
+
return processors[0]
|
|
53
55
|
return processors.reduce((prev, next) => {
|
|
54
56
|
return str => next(prev(str))
|
|
55
57
|
})
|
package/src/node/options.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface ValaxyEntryOptions {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export interface ResolvedValaxyOptions {
|
|
19
|
+
mode: 'dev' | 'build'
|
|
19
20
|
/**
|
|
20
21
|
* Client root path
|
|
21
22
|
* @default 'valaxy/src/client'
|
|
@@ -69,7 +70,7 @@ export function getThemeRoot(name: string, entry: string) {
|
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
// for cli options
|
|
72
|
-
export async function resolveOptions(options: ValaxyEntryOptions) {
|
|
73
|
+
export async function resolveOptions(options: ValaxyEntryOptions, mode: ResolvedValaxyOptions['mode'] = 'dev') {
|
|
73
74
|
const clientRoot = resolve(resolveImportPath('valaxy/package.json'), 'src/client')
|
|
74
75
|
const userRoot = resolve(options.userRoot || process.cwd())
|
|
75
76
|
|
|
@@ -77,6 +78,7 @@ export async function resolveOptions(options: ValaxyEntryOptions) {
|
|
|
77
78
|
const themeRoot = getThemeRoot(theme, userRoot)
|
|
78
79
|
|
|
79
80
|
const valaxyOptions: ResolvedValaxyOptions = {
|
|
81
|
+
mode,
|
|
80
82
|
clientRoot,
|
|
81
83
|
userRoot,
|
|
82
84
|
themeRoot,
|
|
@@ -8,33 +8,58 @@ import type { ResolvedValaxyOptions, ValaxyServerOptions } from '../options'
|
|
|
8
8
|
import { toAtFS } from '../utils'
|
|
9
9
|
import { VALAXY_CONFIG_ID } from './valaxy'
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
/**
|
|
12
|
+
* for /@valaxyjs/styles
|
|
13
|
+
* @param roots
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
function generateStyles(roots: string[]) {
|
|
17
|
+
const imports: string[] = []
|
|
18
|
+
|
|
19
|
+
for (const root of roots) {
|
|
20
|
+
const styles: string[] = []
|
|
21
|
+
|
|
22
|
+
const autoloadNames = ['index', 'css-vars']
|
|
23
|
+
autoloadNames.forEach((name) => {
|
|
24
|
+
styles.push(join(root, 'styles', `${name}.css`))
|
|
25
|
+
styles.push(join(root, 'styles', `${name}.scss`))
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
for (const style of styles) {
|
|
29
|
+
if (fs.existsSync(style))
|
|
30
|
+
imports.push(`import "${toAtFS(style)}"`)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return imports.join('\n')
|
|
34
|
+
}
|
|
15
35
|
|
|
16
|
-
|
|
36
|
+
function generateLocales(roots: string[]) {
|
|
37
|
+
const imports: string[] = [
|
|
38
|
+
'const messages = { "zh-CN": {}, en: {} }',
|
|
39
|
+
]
|
|
40
|
+
const languages = ['zh-CN', 'en']
|
|
41
|
+
|
|
42
|
+
roots.forEach((root, i) => {
|
|
43
|
+
languages.forEach((lang) => {
|
|
44
|
+
const langYml = `${root}/locales/${lang}.yml`
|
|
45
|
+
if (fs.existsSync(langYml)) {
|
|
46
|
+
const varName = lang.replace('-', '') + i
|
|
47
|
+
imports.push(`import ${varName} from "${langYml}"`)
|
|
48
|
+
imports.push(`Object.assign(messages['${lang}'], ${varName})`)
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
})
|
|
17
52
|
|
|
18
|
-
|
|
19
|
-
|
|
53
|
+
imports.push('export default messages')
|
|
54
|
+
return imports.join('\n')
|
|
55
|
+
}
|
|
20
56
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
join(root, 'styles', 'vars.scss'),
|
|
24
|
-
join(root, 'styles', 'index.css'),
|
|
25
|
-
join(root, 'styles', 'index.scss'),
|
|
26
|
-
]
|
|
57
|
+
export function createValaxyPlugin(options: ResolvedValaxyOptions, serverOptions: ValaxyServerOptions = {}): Plugin {
|
|
58
|
+
const valaxyPrefix = '/@valaxy'
|
|
27
59
|
|
|
28
|
-
|
|
29
|
-
if (fs.existsSync(style)) {
|
|
30
|
-
imports.push(`import "${toAtFS(style)}"`)
|
|
31
|
-
continue
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
60
|
+
let valaxyConfig = options.config
|
|
35
61
|
|
|
36
|
-
|
|
37
|
-
}
|
|
62
|
+
const roots = [options.clientRoot, options.themeRoot, options.userRoot]
|
|
38
63
|
|
|
39
64
|
return {
|
|
40
65
|
name: 'Valaxy',
|
|
@@ -60,7 +85,10 @@ export function createValaxyPlugin(options: ResolvedValaxyOptions, serverOptions
|
|
|
60
85
|
|
|
61
86
|
// generate styles
|
|
62
87
|
if (id === '/@valaxyjs/styles')
|
|
63
|
-
return
|
|
88
|
+
return generateStyles(roots)
|
|
89
|
+
|
|
90
|
+
if (id === '/@valaxyjs/locales')
|
|
91
|
+
return generateLocales(roots)
|
|
64
92
|
|
|
65
93
|
if (id.startsWith(valaxyPrefix))
|
|
66
94
|
return ''
|
|
@@ -69,7 +97,8 @@ export function createValaxyPlugin(options: ResolvedValaxyOptions, serverOptions
|
|
|
69
97
|
async handleHotUpdate(ctx) {
|
|
70
98
|
// handle valaxy.config.ts hmr
|
|
71
99
|
const { file, server } = ctx
|
|
72
|
-
if (file !== options.configFile)
|
|
100
|
+
if (file !== options.configFile)
|
|
101
|
+
return
|
|
73
102
|
|
|
74
103
|
const { config } = await resolveConfig()
|
|
75
104
|
|
|
@@ -47,7 +47,7 @@ export function createMarkdownPlugin(options: ResolvedValaxyOptions): Plugin[] {
|
|
|
47
47
|
handleHotUpdate(ctx) {
|
|
48
48
|
const { file, server } = ctx
|
|
49
49
|
// send headers
|
|
50
|
-
if (file.endsWith('.md')) {
|
|
50
|
+
if (file.endsWith('.md') && _md && _md.__data) {
|
|
51
51
|
server.ws.send({
|
|
52
52
|
type: 'custom',
|
|
53
53
|
event: 'valaxy:pageHeaders',
|