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.
Files changed (65) hide show
  1. package/dist/chunk-5D7M5SQP.js +1 -0
  2. package/dist/chunk-CF6MGLH2.mjs +84 -0
  3. package/dist/chunk-L22LX2G6.mjs +1 -0
  4. package/dist/chunk-W5MJCUNY.js +84 -0
  5. package/dist/index.d.ts +9 -5
  6. package/dist/index.js +1 -1
  7. package/dist/index.mjs +1 -1
  8. package/dist/node/cli.js +5 -87
  9. package/dist/node/cli.mjs +5 -87
  10. package/dist/node/index.d.ts +1 -0
  11. package/dist/node/index.js +1 -83
  12. package/dist/node/index.mjs +1 -83
  13. package/package.json +20 -19
  14. package/src/client/components/PostCard.vue +1 -1
  15. package/src/client/components/PostList.vue +5 -5
  16. package/src/client/components/ValaxyCopyright.vue +1 -1
  17. package/src/client/components/ValaxyFooter.vue +1 -1
  18. package/src/client/components/ValaxyOverlay.vue +4 -4
  19. package/src/client/components/ValaxyPagination.vue +16 -14
  20. package/src/client/components/ValaxyRightSidebar.vue +4 -4
  21. package/src/client/components/ValaxySidebar.vue +4 -8
  22. package/src/client/components/ValaxyToc.vue +11 -9
  23. package/src/client/composables/comments/waline.ts +8 -4
  24. package/src/client/composables/common.ts +2 -4
  25. package/src/client/composables/search/algolia.ts +2 -1
  26. package/src/client/composables/sidebar.ts +2 -2
  27. package/src/client/composables/tag.ts +1 -1
  28. package/src/client/composables/widgets/backToTop.ts +10 -4
  29. package/src/client/main.ts +1 -6
  30. package/src/client/modules/valaxy.ts +36 -15
  31. package/src/client/shims.d.ts +5 -0
  32. package/src/client/styles/common/button.scss +3 -5
  33. package/src/client/styles/common/hamburger.scss +2 -2
  34. package/src/client/styles/common/markdown.scss +6 -2
  35. package/src/client/styles/common/sidebar.scss +3 -3
  36. package/src/client/styles/common/transition.scss +2 -2
  37. package/src/client/styles/{css-vars/index.scss → css-vars.scss} +22 -8
  38. package/src/client/styles/global/helper.scss +2 -2
  39. package/src/client/styles/global/index.scss +1 -1
  40. package/src/client/styles/global/nprogress.scss +1 -1
  41. package/src/client/styles/global/reset.scss +2 -1
  42. package/src/client/styles/mixins/config.scss +1 -1
  43. package/src/client/styles/mixins/index.scss +1 -0
  44. package/src/client/styles/palette.scss +14 -8
  45. package/src/client/styles/vars.scss +1 -13
  46. package/src/client/styles/widgets/banner.scss +2 -2
  47. package/src/client/utils/index.ts +0 -2
  48. package/src/node/build.ts +20 -1
  49. package/src/node/cli.ts +17 -19
  50. package/src/node/markdown/index.ts +3 -1
  51. package/src/node/markdown/markdown-it-katex.ts +20 -10
  52. package/src/node/markdown/parseHeader.ts +4 -2
  53. package/src/node/options.ts +3 -1
  54. package/src/node/plugins/index.ts +53 -24
  55. package/src/node/plugins/markdown.ts +1 -1
  56. package/src/node/plugins/preset.ts +47 -10
  57. package/src/node/plugins/unocss.ts +12 -7
  58. package/src/node/server.ts +1 -1
  59. package/src/node/shims.d.ts +5 -0
  60. package/src/node/utils/cli.ts +0 -1
  61. package/src/node/vite.ts +10 -17
  62. package/tsup.config.ts +3 -2
  63. package/src/client/pages/about/index.md +0 -5
  64. package/src/client/styles/css-vars/dark.scss +0 -17
  65. 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
- mode: Mode = 'dev',
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 ['meting-js'].includes(tag)
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) 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(md)
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
- ['val-card', 'transition shadow hover:shadow-lg'],
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: 'Noto Serif SC',
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(--yun-transition-duration)',
83
+ 'transition-duration': 'var(--va-transition-duration)',
79
84
  }],
80
85
  ['yun-text-light', {
81
- color: 'var(--yun-c-text-light)',
86
+ color: 'var(--va-c-text-light)',
82
87
  }],
83
88
  ['font-serif', {
84
- 'font-family': 'var(--yun-font-serif)',
89
+ 'font-family': 'var(--va-font-serif)',
85
90
  }],
86
91
  ['font-sans', {
87
- 'font-family': 'var(--yun-font-sans)',
92
+ 'font-family': 'var(--va-font-sans)',
88
93
  }],
89
94
  ['font-mono', {
90
- 'font-family': 'var(--yun-font-mono)',
95
+ 'font-family': 'var(--va-font-mono)',
91
96
  }],
92
97
  ],
93
98
  transformers: [
@@ -14,7 +14,7 @@ export async function createServer(
14
14
 
15
15
  const server = await createViteServer(mergeConfig(
16
16
  viteConfig,
17
- createViteConfig(options, serverOptions),
17
+ await createViteConfig(options, serverOptions),
18
18
  ))
19
19
 
20
20
  return server
@@ -18,6 +18,11 @@ declare module 'markdown-it-container' {
18
18
  export default def
19
19
  }
20
20
 
21
+ declare module 'markdown-it-task-lists' {
22
+ const def: any
23
+ export default def
24
+ }
25
+
21
26
  declare module 'diacritics' {
22
27
  export const remove: (str: string) => string
23
28
  }
@@ -1,4 +1,3 @@
1
-
2
1
  import * as readline from 'readline'
3
2
  import path from 'path'
4
3
  import os from 'os'
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 = {}, mode: Mode = 'dev'): InlineConfig {
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, {}, mode),
30
+ plugins: await ViteValaxyPlugins(options, serverOptions, {}),
29
31
 
30
32
  server: {
31
33
  fs: {
32
34
  allow: [
33
- searchForWorkspaceRoot(options.clientRoot),
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: true,
11
- splitting: false,
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,5 +0,0 @@
1
- ---
2
- title: About Valaxy
3
- ---
4
-
5
- Check out the [Valaxy | GitHub](https://github.com/YunYouJun/valaxy) for more details.
@@ -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
- }
@@ -1,9 +0,0 @@
1
- @use "../palette" as *;
2
- @use "../mixins" as *;
3
-
4
- :root {
5
- color-scheme: light;
6
-
7
- @include set-css-var-from-map($colors, 'c');
8
- @include set-css-var-from-map($light);
9
- }