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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import fs from 'fs'
|
|
3
2
|
import type { PluginOption } from 'vite'
|
|
4
3
|
|
|
@@ -17,7 +16,6 @@ import Inspect from 'vite-plugin-inspect'
|
|
|
17
16
|
|
|
18
17
|
import chalk from 'chalk'
|
|
19
18
|
import type { ResolvedValaxyOptions, ValaxyServerOptions } from '../options'
|
|
20
|
-
import type { Mode } from '../vite'
|
|
21
19
|
import { setupMarkdownPlugins } from '../markdown'
|
|
22
20
|
import { createMarkdownPlugin, excerpt_separator } from './markdown'
|
|
23
21
|
import { createUnocssPlugin } from './unocss'
|
|
@@ -28,12 +26,11 @@ export interface ValaxyPluginOptions {
|
|
|
28
26
|
components?: Parameters<typeof Components>[0]
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
export function ViteValaxyPlugins(
|
|
29
|
+
export async function ViteValaxyPlugins(
|
|
32
30
|
options: ResolvedValaxyOptions,
|
|
33
31
|
serverOptions: ValaxyServerOptions = {},
|
|
34
32
|
pluginOptions: ValaxyPluginOptions = {},
|
|
35
|
-
|
|
36
|
-
): (PluginOption | PluginOption[])[] | undefined {
|
|
33
|
+
): Promise<(PluginOption | PluginOption[])[] | undefined> {
|
|
37
34
|
const { clientRoot, themeRoot, userRoot } = options
|
|
38
35
|
|
|
39
36
|
const MarkdownPlugin = createMarkdownPlugin(options)
|
|
@@ -46,13 +43,49 @@ export function ViteValaxyPlugins(
|
|
|
46
43
|
|
|
47
44
|
const roots = [clientRoot, themeRoot, userRoot]
|
|
48
45
|
|
|
46
|
+
const { default: ThemePlugin } = await import(`valaxy-theme-${options.theme}`)
|
|
47
|
+
|
|
48
|
+
const customElements = new Set([
|
|
49
|
+
// katex
|
|
50
|
+
'annotation',
|
|
51
|
+
'math',
|
|
52
|
+
'menclose',
|
|
53
|
+
'mfrac',
|
|
54
|
+
'mglyph',
|
|
55
|
+
'mi',
|
|
56
|
+
'mlabeledtr',
|
|
57
|
+
'mn',
|
|
58
|
+
'mo',
|
|
59
|
+
'mover',
|
|
60
|
+
'mpadded',
|
|
61
|
+
'mphantom',
|
|
62
|
+
'mroot',
|
|
63
|
+
'mrow',
|
|
64
|
+
'mspace',
|
|
65
|
+
'msqrt',
|
|
66
|
+
'mstyle',
|
|
67
|
+
'msub',
|
|
68
|
+
'msubsup',
|
|
69
|
+
'msup',
|
|
70
|
+
'mtable',
|
|
71
|
+
'mtd',
|
|
72
|
+
'mtext',
|
|
73
|
+
'mtr',
|
|
74
|
+
'munder',
|
|
75
|
+
'munderover',
|
|
76
|
+
'semantics',
|
|
77
|
+
|
|
78
|
+
// meting
|
|
79
|
+
'meting-js',
|
|
80
|
+
])
|
|
81
|
+
|
|
49
82
|
return [
|
|
50
83
|
Vue({
|
|
51
84
|
include: [/\.vue$/, /\.md$/],
|
|
52
85
|
template: {
|
|
53
86
|
compilerOptions: {
|
|
54
87
|
isCustomElement: (tag) => {
|
|
55
|
-
return
|
|
88
|
+
return customElements.has(tag)
|
|
56
89
|
},
|
|
57
90
|
},
|
|
58
91
|
},
|
|
@@ -62,6 +95,8 @@ export function ViteValaxyPlugins(
|
|
|
62
95
|
MarkdownPlugin,
|
|
63
96
|
createConfigPlugin(options),
|
|
64
97
|
|
|
98
|
+
ThemePlugin(options.config.themeConfig),
|
|
99
|
+
|
|
65
100
|
// https://github.com/hannoeru/vite-plugin-pages
|
|
66
101
|
Pages({
|
|
67
102
|
extensions: ['vue', 'md'],
|
|
@@ -71,7 +106,8 @@ export function ViteValaxyPlugins(
|
|
|
71
106
|
*/
|
|
72
107
|
extendRoute(route) {
|
|
73
108
|
let path = route.component
|
|
74
|
-
if (!route.meta)
|
|
109
|
+
if (!route.meta)
|
|
110
|
+
route.meta = {}
|
|
75
111
|
|
|
76
112
|
if (route.path === '/')
|
|
77
113
|
route.meta.layout = 'home'
|
|
@@ -82,7 +118,7 @@ export function ViteValaxyPlugins(
|
|
|
82
118
|
path = pagePath
|
|
83
119
|
})
|
|
84
120
|
const md = fs.readFileSync(path, 'utf-8')
|
|
85
|
-
const { data, excerpt } = matter(md, { excerpt_separator })
|
|
121
|
+
const { data, excerpt, content } = matter(md, { excerpt_separator })
|
|
86
122
|
|
|
87
123
|
// warn for post frontmatter
|
|
88
124
|
if (route.path.startsWith('/posts/')) {
|
|
@@ -98,7 +134,7 @@ export function ViteValaxyPlugins(
|
|
|
98
134
|
|
|
99
135
|
// to refactor
|
|
100
136
|
// get active header by runtime query head, not render
|
|
101
|
-
mdIt.render(
|
|
137
|
+
mdIt.render(content)
|
|
102
138
|
route.meta.headers = _md.__data?.headers
|
|
103
139
|
|
|
104
140
|
// set default updated
|
|
@@ -124,6 +160,7 @@ export function ViteValaxyPlugins(
|
|
|
124
160
|
|
|
125
161
|
// allow auto import and register components used in markdown
|
|
126
162
|
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
|
|
163
|
+
exclude: [],
|
|
127
164
|
|
|
128
165
|
// allow override
|
|
129
166
|
allowOverrides: true,
|
|
@@ -177,6 +214,6 @@ export function ViteValaxyPlugins(
|
|
|
177
214
|
|
|
178
215
|
// https://github.com/antfu/vite-plugin-inspect
|
|
179
216
|
// Visit http://localhost:3333/__inspect/ to see the inspector
|
|
180
|
-
mode === 'dev' && Inspect(),
|
|
217
|
+
options.mode === 'dev' && Inspect(),
|
|
181
218
|
]
|
|
182
219
|
}
|
|
@@ -54,7 +54,7 @@ export const createUnocssConfig = (options: ResolvedValaxyOptions) => {
|
|
|
54
54
|
['yun-card', 'transition yun-transition shadow hover:shadow-lg'],
|
|
55
55
|
['btn', 'px-4 py-1 rounded inline-block bg-sky-600 text-white cursor-pointer hover:bg-sky-700 disabled:cursor-default disabled:bg-gray-600 disabled:opacity-50'],
|
|
56
56
|
['icon-btn', 'inline-block cursor-pointer select-none opacity-75 transition duration-200 ease-in-out hover:opacity-100 hover:text-sky-600'],
|
|
57
|
-
['
|
|
57
|
+
['va-card', 'transition shadow hover:shadow-lg'],
|
|
58
58
|
],
|
|
59
59
|
presets: [
|
|
60
60
|
presetUno(),
|
|
@@ -66,7 +66,12 @@ export const createUnocssConfig = (options: ResolvedValaxyOptions) => {
|
|
|
66
66
|
presetTypography(),
|
|
67
67
|
presetWebFonts({
|
|
68
68
|
fonts: {
|
|
69
|
-
serif:
|
|
69
|
+
serif: [
|
|
70
|
+
{
|
|
71
|
+
name: 'Noto Serif SC',
|
|
72
|
+
weights: [900],
|
|
73
|
+
},
|
|
74
|
+
],
|
|
70
75
|
// sans: 'DM Sans',
|
|
71
76
|
// mono: 'DM Mono',
|
|
72
77
|
},
|
|
@@ -75,19 +80,19 @@ export const createUnocssConfig = (options: ResolvedValaxyOptions) => {
|
|
|
75
80
|
rules: [
|
|
76
81
|
// more see '~/styles/global/helper.scss'
|
|
77
82
|
['yun-transition', {
|
|
78
|
-
'transition-duration': 'var(--
|
|
83
|
+
'transition-duration': 'var(--va-transition-duration)',
|
|
79
84
|
}],
|
|
80
85
|
['yun-text-light', {
|
|
81
|
-
color: 'var(--
|
|
86
|
+
color: 'var(--va-c-text-light)',
|
|
82
87
|
}],
|
|
83
88
|
['font-serif', {
|
|
84
|
-
'font-family': 'var(--
|
|
89
|
+
'font-family': 'var(--va-font-serif)',
|
|
85
90
|
}],
|
|
86
91
|
['font-sans', {
|
|
87
|
-
'font-family': 'var(--
|
|
92
|
+
'font-family': 'var(--va-font-sans)',
|
|
88
93
|
}],
|
|
89
94
|
['font-mono', {
|
|
90
|
-
'font-family': 'var(--
|
|
95
|
+
'font-family': 'var(--va-font-mono)',
|
|
91
96
|
}],
|
|
92
97
|
],
|
|
93
98
|
transformers: [
|
package/src/node/server.ts
CHANGED
package/src/node/shims.d.ts
CHANGED
package/src/node/utils/cli.ts
CHANGED
package/src/node/vite.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import generateSitemap from 'vite-ssg-sitemap'
|
|
2
1
|
import type { InlineConfig } from 'vite'
|
|
3
2
|
import { searchForWorkspaceRoot } from 'vite'
|
|
4
3
|
import type { ResolvedValaxyOptions, ValaxyServerOptions } from './options'
|
|
@@ -7,7 +6,7 @@ import { ViteValaxyPlugins } from './plugins/preset'
|
|
|
7
6
|
|
|
8
7
|
export type Mode = 'dev' | 'build'
|
|
9
8
|
|
|
10
|
-
export function createViteConfig(options: ResolvedValaxyOptions, serverOptions: ValaxyServerOptions = {}
|
|
9
|
+
export async function createViteConfig(options: ResolvedValaxyOptions, serverOptions: ValaxyServerOptions = {}): Promise<InlineConfig> {
|
|
11
10
|
const viteConfig: InlineConfig = {
|
|
12
11
|
// remove vue-i18n warnings
|
|
13
12
|
// https://vue-i18n.intlify.dev/guide/advanced/optimization.html#reduce-bundle-size-with-feature-build-flags
|
|
@@ -21,31 +20,25 @@ export function createViteConfig(options: ResolvedValaxyOptions, serverOptions:
|
|
|
21
20
|
// __VUE_I18N_LEGACY_API__: 'false',
|
|
22
21
|
// },
|
|
23
22
|
|
|
23
|
+
// always string
|
|
24
|
+
define: {
|
|
25
|
+
__DEV__: options.mode === 'dev' ? 'true' : 'false',
|
|
26
|
+
},
|
|
27
|
+
|
|
24
28
|
root: options.clientRoot,
|
|
25
|
-
// todo user base
|
|
26
|
-
// base: '/',
|
|
27
29
|
|
|
28
|
-
plugins: ViteValaxyPlugins(options, serverOptions, {}
|
|
30
|
+
plugins: await ViteValaxyPlugins(options, serverOptions, {}),
|
|
29
31
|
|
|
30
32
|
server: {
|
|
31
33
|
fs: {
|
|
32
34
|
allow: [
|
|
33
|
-
|
|
35
|
+
// not need to search workspace root
|
|
36
|
+
options.clientRoot,
|
|
37
|
+
options.themeRoot,
|
|
34
38
|
searchForWorkspaceRoot(options.userRoot),
|
|
35
|
-
searchForWorkspaceRoot(options.themeRoot),
|
|
36
39
|
],
|
|
37
40
|
},
|
|
38
41
|
},
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (mode === 'build') {
|
|
43
|
-
// https://github.com/antfu/vite-ssg
|
|
44
|
-
viteConfig.ssgOptions = {
|
|
45
|
-
script: 'async',
|
|
46
|
-
formatting: 'minify',
|
|
47
|
-
onFinished() { generateSitemap() },
|
|
48
|
-
}
|
|
49
42
|
}
|
|
50
43
|
|
|
51
44
|
return viteConfig
|
package/tsup.config.ts
CHANGED
|
@@ -7,8 +7,9 @@ export default defineConfig((options) => {
|
|
|
7
7
|
'src/node/cli.ts',
|
|
8
8
|
'src/index.ts',
|
|
9
9
|
],
|
|
10
|
-
// splitting
|
|
11
|
-
splitting
|
|
10
|
+
// https://tsup.egoist.sh/#code-splitting
|
|
11
|
+
// Code splitting currently only works with the esm output format, and it's enabled by default. If you want code splitting for cjs output format as well, try using --splitting flag which is an experimental feature to get rid of the limitation in esbuild.
|
|
12
|
+
splitting: true,
|
|
12
13
|
clean: true,
|
|
13
14
|
dts: true,
|
|
14
15
|
format: ['cjs', 'esm'],
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
@use "../palette" as *;
|
|
2
|
-
@use "../mixins" as *;
|
|
3
|
-
|
|
4
|
-
::-webkit-input-placeholder {
|
|
5
|
-
color: white;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
html.dark {
|
|
9
|
-
color-scheme: dark;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.dark {
|
|
13
|
-
@include set-css-var-from-map($dark);
|
|
14
|
-
|
|
15
|
-
// star-markdown-css
|
|
16
|
-
--smc-link-color: lighten($colors.primary, 30%);
|
|
17
|
-
}
|