valaxy 0.4.0 → 0.6.1

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 (155) hide show
  1. package/README.md +0 -4
  2. package/{src/client → client}/App.vue +0 -0
  3. package/{src/client/composables/search/index.ts → client/app/data.ts} +0 -0
  4. package/{src/client → client}/components/AppLink.vue +0 -0
  5. package/client/components/PostCard.vue +84 -0
  6. package/{src/client → client}/components/PostList.vue +0 -0
  7. package/{src/client → client}/components/README.md +0 -0
  8. package/{src/client → client}/components/ValaxyBg.vue +0 -0
  9. package/{src/client → client}/components/ValaxyCopyright.vue +0 -0
  10. package/{src/client → client}/components/ValaxyFooter.vue +1 -1
  11. package/{src/client → client}/components/ValaxyHamburger.vue +0 -0
  12. package/client/components/ValaxyMd.vue +74 -0
  13. package/{src/client → client}/components/ValaxyOverlay.vue +0 -0
  14. package/{src/client → client}/components/ValaxyPagination.vue +0 -0
  15. package/{src/client → client}/components/ValaxyRightSidebar.vue +0 -0
  16. package/{src/client → client}/components/ValaxySidebar.vue +0 -0
  17. package/{src/client → client}/components/ValaxyToc.vue +3 -3
  18. package/{src/client → client}/composables/category.ts +0 -0
  19. package/{src/client → client}/composables/comments/index.ts +0 -0
  20. package/{src/client → client}/composables/comments/twikoo.ts +0 -0
  21. package/{src/client → client}/composables/comments/waline.ts +0 -0
  22. package/{src/client → client}/composables/common.ts +0 -0
  23. package/client/composables/copy-code.ts +92 -0
  24. package/{src/client → client}/composables/dark.ts +0 -0
  25. package/client/composables/features/index.ts +0 -0
  26. package/{src/client → client}/composables/helper.ts +0 -0
  27. package/{src/client → client}/composables/index.ts +1 -1
  28. package/{src/client → client}/composables/layout.ts +0 -0
  29. package/client/composables/outline.ts +168 -0
  30. package/{src/client → client}/composables/post.ts +0 -0
  31. package/client/composables/search/index.ts +0 -0
  32. package/{src/client → client}/composables/sidebar.ts +46 -1
  33. package/{src/client → client}/composables/tag.ts +0 -0
  34. package/{src/client → client}/composables/widgets/aplayer.ts +0 -0
  35. package/{src/client → client}/composables/widgets/backToTop.ts +0 -0
  36. package/{src/client → client}/composables/widgets/codepen.ts +0 -0
  37. package/{src/client → client}/composables/widgets/index.ts +0 -0
  38. package/client/config.ts +75 -0
  39. package/{src/client → client}/index.html +0 -0
  40. package/{src/client → client}/index.ts +0 -0
  41. package/{src/client → client}/layouts/404.vue +0 -0
  42. package/{src/client → client}/layouts/README.md +0 -0
  43. package/{src/client → client}/locales/README.md +0 -0
  44. package/{src/client → client}/locales/en.yml +1 -0
  45. package/{src/client → client}/locales/zh-CN.yml +4 -3
  46. package/{src/client → client}/main.ts +4 -1
  47. package/{src/client → client}/modules/README.md +0 -0
  48. package/{src/client → client}/modules/nprogress.ts +0 -0
  49. package/{src/client → client}/modules/pinia.ts +0 -0
  50. package/{src/client → client}/modules/valaxy.ts +19 -7
  51. package/{src/client → client}/pages/README.md +0 -0
  52. package/{src/client → client}/pages/[...all].vue +0 -0
  53. package/{src/client → client}/pages/hi/[name].vue +0 -0
  54. package/{src/client → client}/pages/index.vue +0 -0
  55. package/{src/client → client}/pages/page/[page].vue +0 -0
  56. package/{src/client → client}/shims.d.ts +7 -1
  57. package/{src/client → client}/stores/app.ts +0 -0
  58. package/{src/client → client}/stores/user.ts +0 -0
  59. package/{src/client → client}/styles/common/button.scss +0 -0
  60. package/client/styles/common/code.scss +231 -0
  61. package/{src/client → client}/styles/common/custom-blocks.scss +0 -0
  62. package/{src/client → client}/styles/common/hamburger.scss +0 -0
  63. package/{src/client → client}/styles/common/markdown.scss +0 -2
  64. package/client/styles/common/scrollbar.scss +28 -0
  65. package/{src/client → client}/styles/common/sidebar.scss +0 -0
  66. package/{src/client → client}/styles/common/transition.scss +0 -0
  67. package/client/styles/css-vars.scss +62 -0
  68. package/{src/client → client}/styles/global/helper.scss +0 -0
  69. package/{src/client → client}/styles/global/i18n.scss +0 -0
  70. package/{src/client → client}/styles/global/index.scss +0 -0
  71. package/{src/client → client}/styles/global/nprogress.scss +0 -0
  72. package/{src/client → client}/styles/global/reset.scss +0 -0
  73. package/{src/client → client}/styles/index.scss +0 -0
  74. package/{src/client → client}/styles/mixins/config.scss +0 -0
  75. package/{src/client → client}/styles/mixins/index.scss +0 -0
  76. package/{src/client → client}/styles/mixins/size.scss +0 -0
  77. package/{src/client → client}/styles/mixins/variable.scss +0 -0
  78. package/{src/client → client}/styles/palette.scss +21 -2
  79. package/client/styles/third/katex.scss +3 -0
  80. package/client/styles/vars.scss +41 -0
  81. package/{src/client → client}/styles/widgets/banner.scss +0 -0
  82. package/{src/client → client}/types.ts +0 -0
  83. package/{src/client → client}/utils/helper.ts +22 -0
  84. package/{src/client → client}/utils/index.ts +0 -0
  85. package/client/utils/sidebar.ts +26 -0
  86. package/{src/client → client}/utils/time.ts +0 -0
  87. package/config/index.ts +18 -0
  88. package/dist/chunk-EAN2KU6W.mjs +1 -0
  89. package/dist/chunk-HMUGSKPK.mjs +40 -0
  90. package/dist/chunk-U5OMNIOK.js +1 -0
  91. package/dist/chunk-ZHHNO5RK.js +40 -0
  92. package/dist/{config-de04677b.d.ts → config-112ac884.d.ts} +37 -14
  93. package/dist/index.d.ts +65 -111
  94. package/dist/index.js +1 -1
  95. package/dist/index.mjs +1 -1
  96. package/dist/node/cli.js +7 -11
  97. package/dist/node/cli.mjs +7 -11
  98. package/dist/node/index.d.ts +3 -2
  99. package/dist/node/index.js +1 -1
  100. package/dist/node/index.mjs +1 -1
  101. package/{src/index.ts → index.ts} +1 -0
  102. package/{src/node → node}/build.ts +0 -0
  103. package/{src/node → node}/cli.ts +3 -2
  104. package/node/config.ts +156 -0
  105. package/{src/node → node}/index.ts +0 -0
  106. package/{src/node → node}/markdown/check.ts +0 -0
  107. package/node/markdown/highlight.ts +38 -0
  108. package/{src/node → node}/markdown/index.ts +30 -16
  109. package/{src/node → node}/markdown/markdown-it/container.ts +0 -0
  110. package/{src/node → node}/markdown/markdown-it/headings.ts +0 -0
  111. package/{src/node → node}/markdown/markdown-it/highlightLines.ts +1 -1
  112. package/{src/node → node}/markdown/markdown-it/katex.ts +0 -0
  113. package/{src/node → node}/markdown/markdown-it/parseHeader.ts +0 -0
  114. package/node/markdown/markdownToVue.ts +274 -0
  115. package/{src/node → node}/markdown/slugify.ts +0 -0
  116. package/{src/node → node}/options.ts +18 -2
  117. package/{src/node → node}/plugins/extendConfig.ts +5 -3
  118. package/node/plugins/index.ts +224 -0
  119. package/{src/node → node}/plugins/preset.ts +8 -8
  120. package/{src/node → node}/plugins/unocss.ts +0 -0
  121. package/{src/node → node}/plugins/valaxy.ts +0 -0
  122. package/{src/node → node}/rss.ts +1 -1
  123. package/{src/node → node}/server.ts +0 -0
  124. package/{src/node → node}/shims.d.ts +0 -5
  125. package/{src/node → node}/utils/cli.ts +1 -1
  126. package/node/utils/getGitTimestamp.ts +13 -0
  127. package/node/utils/index.ts +59 -0
  128. package/node/utils/net.ts +20 -0
  129. package/{src/node → node}/vite.ts +5 -1
  130. package/package.json +32 -13
  131. package/shared/index.ts +1 -0
  132. package/tsup.config.ts +7 -4
  133. package/{src/types → types}/config.ts +31 -108
  134. package/types/data.ts +31 -0
  135. package/{src/types → types}/index.ts +1 -0
  136. package/{src/types → types}/posts.ts +6 -1
  137. package/dist/chunk-6LIOFBAA.mjs +0 -1
  138. package/dist/chunk-HRARZPSA.js +0 -83
  139. package/dist/chunk-N6HD5SHF.mjs +0 -83
  140. package/dist/chunk-V3BMKLEW.js +0 -1
  141. package/src/client/components/PostCard.vue +0 -68
  142. package/src/client/components/ValaxyMd.vue +0 -71
  143. package/src/client/composables/features/index.ts +0 -1
  144. package/src/client/composables/features/katex.ts +0 -15
  145. package/src/client/composables/search/algolia.ts +0 -115
  146. package/src/client/config.ts +0 -51
  147. package/src/client/styles/common/code.scss +0 -207
  148. package/src/client/styles/common/scrollbar.scss +0 -34
  149. package/src/client/styles/css-vars.scss +0 -39
  150. package/src/client/styles/vars.scss +0 -27
  151. package/src/node/config.ts +0 -52
  152. package/src/node/markdown/highlight.ts +0 -50
  153. package/src/node/plugins/index.ts +0 -120
  154. package/src/node/plugins/markdown.ts +0 -57
  155. package/src/node/utils/index.ts +0 -26
@@ -1,50 +0,0 @@
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
- }
@@ -1,120 +0,0 @@
1
- import fs from 'fs'
2
-
3
- import { join } from 'path'
4
- import type { Plugin } from 'vite'
5
- // import consola from 'consola'
6
- import { resolveConfig } from '../config'
7
- import type { ResolvedValaxyOptions, ValaxyServerOptions } from '../options'
8
- import { toAtFS } from '../utils'
9
- import { VALAXY_CONFIG_ID } from './valaxy'
10
-
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
- }
35
-
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) && fs.readFileSync(langYml, 'utf-8')) {
46
- const varName = lang.replace('-', '') + i
47
- imports.push(`import ${varName} from "${toAtFS(langYml)}"`)
48
- imports.push(`Object.assign(messages['${lang}'], ${varName})`)
49
- }
50
- })
51
- })
52
-
53
- imports.push('export default messages')
54
- return imports.join('\n')
55
- }
56
-
57
- export function createValaxyPlugin(options: ResolvedValaxyOptions, serverOptions: ValaxyServerOptions = {}): Plugin {
58
- const valaxyPrefix = '/@valaxy'
59
-
60
- let valaxyConfig = options.config
61
-
62
- const roots = [options.clientRoot, options.themeRoot, options.userRoot]
63
-
64
- return {
65
- name: 'Valaxy',
66
-
67
- configureServer(server) {
68
- server.watcher.add([
69
- options.configFile,
70
- options.userRoot,
71
- options.themeRoot,
72
- ])
73
- },
74
-
75
- resolveId(id) {
76
- if (id.startsWith(valaxyPrefix))
77
- return id
78
- return null
79
- },
80
-
81
- load(id) {
82
- if (id === `/${VALAXY_CONFIG_ID}`)
83
- // stringify twice for \"
84
- return `export default ${JSON.stringify(JSON.stringify(valaxyConfig))}`
85
-
86
- // generate styles
87
- if (id === '/@valaxyjs/styles')
88
- return generateStyles(roots)
89
-
90
- if (id === '/@valaxyjs/locales')
91
- return generateLocales(roots)
92
-
93
- if (id.startsWith(valaxyPrefix))
94
- return ''
95
- },
96
-
97
- async handleHotUpdate(ctx) {
98
- // handle valaxy.config.ts hmr
99
- const { file, server } = ctx
100
- if (file !== options.configFile)
101
- return
102
-
103
- const { config } = await resolveConfig()
104
-
105
- serverOptions.onConfigReload?.(config, options.config)
106
- Object.assign(options.config, config)
107
-
108
- // if (config.base !== options.config.base)
109
- // consola.warn('[valaxy]: config.base has changed. Please restart the dev server.')
110
- valaxyConfig = config
111
-
112
- const moduleIds = [`/${VALAXY_CONFIG_ID}`]
113
- const moduleEntries = [
114
- ...Array.from(moduleIds).map(id => server.moduleGraph.getModuleById(id)),
115
- ].filter(<T>(item: T): item is NonNullable<T> => !!item)
116
-
117
- return moduleEntries
118
- },
119
- }
120
- }
@@ -1,57 +0,0 @@
1
- import Markdown from 'vite-plugin-md'
2
-
3
- import type { Plugin } from 'vite'
4
- import type { ResolvedValaxyOptions } from '../options'
5
-
6
- import { setupMarkdownPlugins } from '../markdown'
7
- import { checkMd } from '../markdown/check'
8
-
9
- export type ViteMdOptions = Parameters<typeof Markdown>[0]
10
-
11
- export const excerpt_separator = '<!-- more -->'
12
-
13
- // https://github.com/antfu/vite-plugin-md
14
-
15
- export function createMarkdownPlugin(options: ResolvedValaxyOptions): Plugin[] {
16
- const mdOptions = options.config.markdownIt
17
-
18
- const defaultOptions: ViteMdOptions = {
19
- wrapperComponent: 'ValaxyMd',
20
- wrapperClasses: '',
21
-
22
- headEnabled: true,
23
- frontmatter: true,
24
- excerpt: excerpt_separator,
25
-
26
- markdownItSetup(md) {
27
- if (mdOptions.config)
28
- mdOptions.config(md)
29
-
30
- setupMarkdownPlugins(md, mdOptions)
31
- },
32
-
33
- transforms: {
34
- before: (code, id) => {
35
- checkMd(code, id)
36
-
37
- code.replace('{%', '\{\%')
38
- code.replace('%}', '\%\}')
39
- return code
40
- },
41
- },
42
- }
43
-
44
- return [Markdown(Object.assign(defaultOptions, options.config.markdown)), {
45
- name: 'valaxy:md',
46
- handleHotUpdate(ctx) {
47
- const { file, server } = ctx
48
- // send headers
49
- if (file.endsWith('.md')) {
50
- server.ws.send({
51
- type: 'custom',
52
- event: 'valaxy:md-update',
53
- })
54
- }
55
- },
56
- }]
57
- }
@@ -1,26 +0,0 @@
1
- import { dirname } from 'path'
2
- import consola from 'consola'
3
-
4
- export function slash(str: string) {
5
- return str.replace(/\\/g, '/')
6
- }
7
-
8
- export function ensurePrefix(prefix: string, str: string) {
9
- if (!str.startsWith(prefix))
10
- return prefix + str
11
- return str
12
- }
13
-
14
- export function toAtFS(path: string) {
15
- return `/@fs${ensurePrefix('/', slash(path))}`
16
- }
17
-
18
- export function resolveImportPath(importName: string) {
19
- try {
20
- return dirname(require.resolve(importName))
21
- }
22
- catch { }
23
-
24
- consola.error(`Failed to resolve package ${importName}`)
25
- throw new Error(`Failed to resolve package ${importName}`)
26
- }