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
|
@@ -1,3 +1,58 @@
|
|
|
1
|
+
@use '~/styles/mixins' as *;
|
|
2
|
+
|
|
3
|
+
/* https://github.com/antfu/prism-theme-vars */
|
|
4
|
+
@use 'prism-theme-vars/base.css' as *;
|
|
5
|
+
|
|
6
|
+
@include mobile {
|
|
7
|
+
.markdown-body {
|
|
8
|
+
div[class*='language-'] {
|
|
9
|
+
margin: 0 -1rem;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.markdown-body {
|
|
15
|
+
div[class*='language-'] {
|
|
16
|
+
position: relative;
|
|
17
|
+
padding: 0;
|
|
18
|
+
background-color: var(--smc-code-bg-color);
|
|
19
|
+
|
|
20
|
+
pre {
|
|
21
|
+
position: relative;
|
|
22
|
+
padding: 1rem;
|
|
23
|
+
z-index: 1;
|
|
24
|
+
background: none;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Line highlighting */
|
|
30
|
+
|
|
31
|
+
.highlight-lines {
|
|
32
|
+
position: absolute;
|
|
33
|
+
top: 0;
|
|
34
|
+
bottom: 0;
|
|
35
|
+
left: 0;
|
|
36
|
+
padding: 1.15rem 0;
|
|
37
|
+
width: 100%;
|
|
38
|
+
line-height: var(--prism-line-height);
|
|
39
|
+
// font-family: var(--code-font-family);
|
|
40
|
+
// font-size: var(--code-font-size);
|
|
41
|
+
user-select: none;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.highlight-lines .highlighted {
|
|
46
|
+
background-color: rgba(0, 0, 0, 0.08);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.dark {
|
|
50
|
+
.highlight-lines .highlighted {
|
|
51
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// prism
|
|
1
56
|
html:not(.dark) {
|
|
2
57
|
--prism-foreground: #393a34;
|
|
3
58
|
--prism-background: #f8f8f8;
|
|
@@ -33,3 +88,105 @@ html.dark {
|
|
|
33
88
|
--prism-regex: #ad502b;
|
|
34
89
|
--prism-selector: #C3E88D;
|
|
35
90
|
}
|
|
91
|
+
|
|
92
|
+
/* Language marker */
|
|
93
|
+
// @use 'prism-theme-vars/marker.css' as *; * not div
|
|
94
|
+
div[class*='language-']:before {
|
|
95
|
+
position: absolute;
|
|
96
|
+
top: 0.6em;
|
|
97
|
+
right: 1em;
|
|
98
|
+
z-index: 2;
|
|
99
|
+
font-size: 0.8rem;
|
|
100
|
+
color: #888;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
div[class~='language-html']:before,
|
|
104
|
+
div[class~='language-markup']:before {
|
|
105
|
+
content: 'html';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
div[class~='language-md']:before,
|
|
109
|
+
div[class~='language-markdown']:before {
|
|
110
|
+
content: 'md';
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
div[class~='language-css']:before {
|
|
114
|
+
content: 'css';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
div[class~='language-sass']:before {
|
|
118
|
+
content: 'sass';
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
div[class~='language-scss']:before {
|
|
122
|
+
content: 'scss';
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
div[class~='language-less']:before {
|
|
126
|
+
content: 'less';
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
div[class~='language-stylus']:before {
|
|
130
|
+
content: 'styl';
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
div[class~='language-js']:before,
|
|
134
|
+
div[class~='language-javascript']:before {
|
|
135
|
+
content: 'js';
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
div[class~='language-ts']:before,
|
|
139
|
+
div[class~='language-typescript']:before {
|
|
140
|
+
content: 'ts';
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
div[class~='language-json']:before {
|
|
144
|
+
content: 'json';
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
div[class~='language-rb']:before,
|
|
148
|
+
div[class~='language-ruby']:before {
|
|
149
|
+
content: 'rb';
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
div[class~='language-py']:before,
|
|
153
|
+
div[class~='language-python']:before {
|
|
154
|
+
content: 'py';
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
div[class~='language-sh']:before,
|
|
158
|
+
div[class~='language-bash']:before {
|
|
159
|
+
content: 'sh';
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
div[class~='language-php']:before {
|
|
163
|
+
content: 'php';
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
div[class~='language-go']:before {
|
|
167
|
+
content: 'go';
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
div[class~='language-rust']:before {
|
|
171
|
+
content: 'rust';
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
div[class~='language-java']:before {
|
|
175
|
+
content: 'java';
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
div[class~='language-c']:before {
|
|
179
|
+
content: 'c';
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
div[class~='language-yaml']:before {
|
|
183
|
+
content: 'yaml';
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
div[class~='language-dockerfile']:before {
|
|
187
|
+
content: 'dockerfile';
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
div[class~='language-vue']:before {
|
|
191
|
+
content: 'vue';
|
|
192
|
+
}
|
|
@@ -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
|
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
@use 'prism-theme-vars/base.css' as *;
|
|
3
|
-
@use './code.scss' as *;
|
|
1
|
+
@use 'sass:map';
|
|
4
2
|
|
|
5
3
|
.markdown-body {
|
|
6
|
-
--prism-font-family: var(--
|
|
4
|
+
--prism-font-family: var(--va-font-mono);
|
|
7
5
|
|
|
8
|
-
--smc-
|
|
6
|
+
--smc-font-family: var(--va-font-sans);
|
|
9
7
|
}
|
|
10
8
|
|
|
11
9
|
// for anchor
|
|
@@ -21,6 +19,7 @@ h5:hover .header-anchor,
|
|
|
21
19
|
h5:focus .header-anchor,
|
|
22
20
|
h6:hover .header-anchor,
|
|
23
21
|
h6:focus .header-anchor {
|
|
22
|
+
visibility: visible;
|
|
24
23
|
opacity: 1;
|
|
25
24
|
}
|
|
26
25
|
|
|
@@ -30,7 +29,9 @@ a.header-anchor {
|
|
|
30
29
|
margin-left: -0.87em;
|
|
31
30
|
padding-right: 0.23em;
|
|
32
31
|
font-size: 0.85em;
|
|
32
|
+
visibility: hidden;
|
|
33
33
|
opacity: 0;
|
|
34
|
+
transition: opacity var(--va-transition-duration);
|
|
34
35
|
|
|
35
36
|
&::before {
|
|
36
37
|
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,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
@use "sass:map";
|
|
2
|
+
@use "./mixins" as *;
|
|
3
|
+
@use "./vars" as *;
|
|
4
|
+
|
|
5
|
+
$c-primary: #0078E7 !default;
|
|
6
|
+
|
|
7
|
+
@use "./palette" with (
|
|
8
|
+
$colors: (
|
|
9
|
+
'primary': $c-primary,
|
|
10
|
+
)
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
// common
|
|
14
|
+
:root {
|
|
15
|
+
@include set-css-var-from-map($common);
|
|
16
|
+
@include set-css-var-from-map($border, 'border');
|
|
17
|
+
@include set-css-var-from-map($font, 'font');
|
|
18
|
+
@include set-css-var-from-map($transition, 'transition');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// colors
|
|
22
|
+
:root {
|
|
23
|
+
// palette different with colors
|
|
24
|
+
@include set-css-var-from-map(palette.$palette, 'c');
|
|
25
|
+
// primary
|
|
26
|
+
@include set-css-var-from-map(palette.$colors, 'c');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// light
|
|
30
|
+
:root {
|
|
31
|
+
color-scheme: light;
|
|
32
|
+
@include set-css-var-from-map(palette.$light);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// dark
|
|
36
|
+
html.dark {
|
|
37
|
+
color-scheme: dark;
|
|
38
|
+
@include set-css-var-from-map(palette.$dark);
|
|
39
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
.
|
|
2
|
-
background-color: var(--
|
|
1
|
+
.va-card {
|
|
2
|
+
background-color: var(--va-c-bg-light);
|
|
3
3
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// import common and light/dark css vars in main.ts
|
|
2
2
|
|
|
3
|
+
$c-primary: #0078E7 !default;
|
|
4
|
+
|
|
3
5
|
// global css
|
|
4
6
|
@use './global/reset.scss' as *;
|
|
5
7
|
@use './global/helper.scss' as *;
|
|
@@ -8,11 +10,20 @@
|
|
|
8
10
|
|
|
9
11
|
// common
|
|
10
12
|
@use './common/button.scss' as *;
|
|
13
|
+
@use './common/code.scss' as *;
|
|
11
14
|
@use './common/hamburger.scss' as *;
|
|
12
|
-
|
|
15
|
+
|
|
13
16
|
@use "./common/scrollbar.scss" as *;
|
|
14
17
|
@use "./common/sidebar.scss" as *;
|
|
15
18
|
@use "./common/transition.scss" as *;
|
|
16
19
|
|
|
17
20
|
// banner
|
|
18
21
|
@use './widgets/banner.scss' as *;
|
|
22
|
+
|
|
23
|
+
// markdown
|
|
24
|
+
@use './common/markdown.scss';
|
|
25
|
+
@forward 'star-markdown-css/src/scss/theme/yun.scss' with (
|
|
26
|
+
$colors: (
|
|
27
|
+
'primary': $c-primary,
|
|
28
|
+
)
|
|
29
|
+
);
|
|
@@ -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,18 @@ $colors: map.merge((
|
|
|
16
17
|
'primary': #0078E7,
|
|
17
18
|
), $colors);
|
|
18
19
|
|
|
19
|
-
$c-primary: map.get($colors, 'primary');
|
|
20
|
+
$c-primary: map.get($colors, 'primary') !default;
|
|
20
21
|
|
|
21
22
|
$colors: map.merge((
|
|
22
23
|
'primary-light': lighten($c-primary, 15%),
|
|
23
24
|
'primary-lighter': lighten($c-primary, 30%),
|
|
25
|
+
'primary-dark': darken($c-primary, 5%),
|
|
24
26
|
), $colors);
|
|
25
27
|
|
|
26
28
|
|
|
27
29
|
$light: () !default;
|
|
28
30
|
$light: map.merge((
|
|
29
|
-
'
|
|
30
|
-
'border-color': #e6e6e6,
|
|
31
|
+
'border-color': #222,
|
|
31
32
|
|
|
32
33
|
'c-bg': white,
|
|
33
34
|
'c-bg-light': white,
|
|
@@ -38,15 +39,12 @@ $light: map.merge((
|
|
|
38
39
|
|
|
39
40
|
'c-primary-rgb': #{red($c-primary), green($c-primary), blue($c-primary)},
|
|
40
41
|
|
|
41
|
-
'c-link':
|
|
42
|
-
|
|
43
|
-
'sidebar-bg-color': #{get-css-var('c-bg-light')}
|
|
42
|
+
'c-link': get-css-var('c-primary-dark'),
|
|
44
43
|
), $light);
|
|
45
44
|
|
|
46
45
|
$dark: () !default;
|
|
47
46
|
$dark: map.merge((
|
|
48
|
-
'
|
|
49
|
-
'border-color': #222,
|
|
47
|
+
'border-color': #e6e6e6,
|
|
50
48
|
|
|
51
49
|
'c-bg': #1a1a1a,
|
|
52
50
|
'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,17 @@ 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
|
+
// rss
|
|
18
|
+
import { build as rssBuild } from './rss'
|
|
19
|
+
|
|
18
20
|
const cli = yargs.scriptName('valaxy')
|
|
19
21
|
.usage('$0 [args]')
|
|
20
22
|
.version(version)
|
|
@@ -121,22 +123,29 @@ cli.command(
|
|
|
121
123
|
describe: 'output dir',
|
|
122
124
|
}).option('base', {
|
|
123
125
|
type: 'string',
|
|
126
|
+
default: '/',
|
|
124
127
|
describe: 'output base',
|
|
125
128
|
})
|
|
126
129
|
.strict()
|
|
127
130
|
.help(),
|
|
128
131
|
async({ ssg, root, base, output }) => {
|
|
129
|
-
const options = await resolveOptions({ userRoot: root })
|
|
132
|
+
const options = await resolveOptions({ userRoot: root }, 'build')
|
|
130
133
|
printInfo(options)
|
|
131
134
|
|
|
135
|
+
const viteConfig = {
|
|
136
|
+
base,
|
|
137
|
+
build: {
|
|
138
|
+
// make out dir empty, https://vitejs.dev/config/#build-emptyoutdir
|
|
139
|
+
emptyOutDir: true,
|
|
140
|
+
outDir: path.resolve(options.userRoot, output),
|
|
141
|
+
},
|
|
142
|
+
}
|
|
143
|
+
|
|
132
144
|
if (ssg) {
|
|
133
145
|
consola.info('use vite-ssg to do ssg build...')
|
|
146
|
+
|
|
134
147
|
try {
|
|
135
|
-
|
|
136
|
-
// https://github.com/antfu/vite-ssg/issues/226
|
|
137
|
-
await ssgBuild({
|
|
138
|
-
mode: 'production',
|
|
139
|
-
})
|
|
148
|
+
await ssgBuild(options, viteConfig)
|
|
140
149
|
}
|
|
141
150
|
catch (e) {
|
|
142
151
|
consola.error('[vite-ssg] An internal error occurred.')
|
|
@@ -144,21 +153,25 @@ cli.command(
|
|
|
144
153
|
}
|
|
145
154
|
}
|
|
146
155
|
else {
|
|
147
|
-
const { build } = await import('./build')
|
|
148
|
-
|
|
149
156
|
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
|
-
})
|
|
157
|
+
await build(options, viteConfig)
|
|
158
158
|
}
|
|
159
159
|
},
|
|
160
160
|
)
|
|
161
161
|
|
|
162
|
+
cli.command(
|
|
163
|
+
'rss [root]',
|
|
164
|
+
'generate rss feed',
|
|
165
|
+
args => commonOptions(args)
|
|
166
|
+
.strict()
|
|
167
|
+
.help(),
|
|
168
|
+
async({ root }) => {
|
|
169
|
+
consola.info('Generate RSS ...')
|
|
170
|
+
const options = await resolveOptions({ userRoot: root }, 'build')
|
|
171
|
+
await rssBuild(options)
|
|
172
|
+
},
|
|
173
|
+
)
|
|
174
|
+
|
|
162
175
|
/**
|
|
163
176
|
* set common options for cli
|
|
164
177
|
* @param args
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import consola from 'consola'
|
|
2
|
+
import escapeHtml from 'escape-html'
|
|
3
|
+
import prism from 'prismjs'
|
|
4
|
+
|
|
5
|
+
// prism is listed as actual dep so it's ok to require
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
7
|
+
const loadLanguages = require('prismjs/components/index')
|
|
8
|
+
|
|
9
|
+
// required to make embedded highlighting work...
|
|
10
|
+
loadLanguages(['markup', 'css', 'javascript'])
|
|
11
|
+
|
|
12
|
+
function wrap(code: string, lang: string): string {
|
|
13
|
+
if (lang === 'text')
|
|
14
|
+
code = escapeHtml(code)
|
|
15
|
+
|
|
16
|
+
return `<pre v-pre><code>${code}</code></pre>`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const highlight = (str: string, lang: string) => {
|
|
20
|
+
if (!lang)
|
|
21
|
+
return wrap(str, 'text')
|
|
22
|
+
|
|
23
|
+
lang = lang.toLowerCase()
|
|
24
|
+
const rawLang = lang
|
|
25
|
+
if (lang === 'vue' || lang === 'html')
|
|
26
|
+
lang = 'markup'
|
|
27
|
+
|
|
28
|
+
if (lang === 'md')
|
|
29
|
+
lang = 'markdown'
|
|
30
|
+
|
|
31
|
+
if (lang === 'ts')
|
|
32
|
+
lang = 'typescript'
|
|
33
|
+
|
|
34
|
+
if (lang === 'py')
|
|
35
|
+
lang = 'python'
|
|
36
|
+
|
|
37
|
+
if (!prism.languages[lang]) {
|
|
38
|
+
try {
|
|
39
|
+
loadLanguages([lang])
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
consola.warn(`[valaxy] Syntax highlight for language "${lang}" is not supported.`)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (prism.languages[lang]) {
|
|
46
|
+
const code = prism.highlight(str, prism.languages[lang], lang)
|
|
47
|
+
return wrap(code, rawLang)
|
|
48
|
+
}
|
|
49
|
+
return wrap(str, 'text')
|
|
50
|
+
}
|