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.
- package/README.md +0 -4
- package/{src/client → client}/App.vue +0 -0
- package/{src/client/composables/search/index.ts → client/app/data.ts} +0 -0
- package/{src/client → client}/components/AppLink.vue +0 -0
- package/client/components/PostCard.vue +84 -0
- package/{src/client → client}/components/PostList.vue +0 -0
- package/{src/client → client}/components/README.md +0 -0
- package/{src/client → client}/components/ValaxyBg.vue +0 -0
- package/{src/client → client}/components/ValaxyCopyright.vue +0 -0
- package/{src/client → client}/components/ValaxyFooter.vue +1 -1
- package/{src/client → client}/components/ValaxyHamburger.vue +0 -0
- package/client/components/ValaxyMd.vue +74 -0
- package/{src/client → client}/components/ValaxyOverlay.vue +0 -0
- package/{src/client → client}/components/ValaxyPagination.vue +0 -0
- package/{src/client → client}/components/ValaxyRightSidebar.vue +0 -0
- package/{src/client → client}/components/ValaxySidebar.vue +0 -0
- package/{src/client → client}/components/ValaxyToc.vue +3 -3
- package/{src/client → client}/composables/category.ts +0 -0
- package/{src/client → client}/composables/comments/index.ts +0 -0
- package/{src/client → client}/composables/comments/twikoo.ts +0 -0
- package/{src/client → client}/composables/comments/waline.ts +0 -0
- package/{src/client → client}/composables/common.ts +0 -0
- package/client/composables/copy-code.ts +92 -0
- package/{src/client → client}/composables/dark.ts +0 -0
- package/client/composables/features/index.ts +0 -0
- package/{src/client → client}/composables/helper.ts +0 -0
- package/{src/client → client}/composables/index.ts +1 -1
- package/{src/client → client}/composables/layout.ts +0 -0
- package/client/composables/outline.ts +168 -0
- package/{src/client → client}/composables/post.ts +0 -0
- package/client/composables/search/index.ts +0 -0
- package/{src/client → client}/composables/sidebar.ts +46 -1
- package/{src/client → client}/composables/tag.ts +0 -0
- package/{src/client → client}/composables/widgets/aplayer.ts +0 -0
- package/{src/client → client}/composables/widgets/backToTop.ts +0 -0
- package/{src/client → client}/composables/widgets/codepen.ts +0 -0
- package/{src/client → client}/composables/widgets/index.ts +0 -0
- package/client/config.ts +75 -0
- package/{src/client → client}/index.html +0 -0
- package/{src/client → client}/index.ts +0 -0
- package/{src/client → client}/layouts/404.vue +0 -0
- package/{src/client → client}/layouts/README.md +0 -0
- package/{src/client → client}/locales/README.md +0 -0
- package/{src/client → client}/locales/en.yml +1 -0
- package/{src/client → client}/locales/zh-CN.yml +4 -3
- package/{src/client → client}/main.ts +4 -1
- package/{src/client → client}/modules/README.md +0 -0
- package/{src/client → client}/modules/nprogress.ts +0 -0
- package/{src/client → client}/modules/pinia.ts +0 -0
- package/{src/client → client}/modules/valaxy.ts +19 -7
- package/{src/client → client}/pages/README.md +0 -0
- package/{src/client → client}/pages/[...all].vue +0 -0
- package/{src/client → client}/pages/hi/[name].vue +0 -0
- package/{src/client → client}/pages/index.vue +0 -0
- package/{src/client → client}/pages/page/[page].vue +0 -0
- package/{src/client → client}/shims.d.ts +7 -1
- package/{src/client → client}/stores/app.ts +0 -0
- package/{src/client → client}/stores/user.ts +0 -0
- package/{src/client → client}/styles/common/button.scss +0 -0
- package/client/styles/common/code.scss +231 -0
- package/{src/client → client}/styles/common/custom-blocks.scss +0 -0
- package/{src/client → client}/styles/common/hamburger.scss +0 -0
- package/{src/client → client}/styles/common/markdown.scss +0 -2
- package/client/styles/common/scrollbar.scss +28 -0
- package/{src/client → client}/styles/common/sidebar.scss +0 -0
- package/{src/client → client}/styles/common/transition.scss +0 -0
- package/client/styles/css-vars.scss +62 -0
- package/{src/client → client}/styles/global/helper.scss +0 -0
- package/{src/client → client}/styles/global/i18n.scss +0 -0
- package/{src/client → client}/styles/global/index.scss +0 -0
- package/{src/client → client}/styles/global/nprogress.scss +0 -0
- package/{src/client → client}/styles/global/reset.scss +0 -0
- package/{src/client → client}/styles/index.scss +0 -0
- package/{src/client → client}/styles/mixins/config.scss +0 -0
- package/{src/client → client}/styles/mixins/index.scss +0 -0
- package/{src/client → client}/styles/mixins/size.scss +0 -0
- package/{src/client → client}/styles/mixins/variable.scss +0 -0
- package/{src/client → client}/styles/palette.scss +21 -2
- package/client/styles/third/katex.scss +3 -0
- package/client/styles/vars.scss +41 -0
- package/{src/client → client}/styles/widgets/banner.scss +0 -0
- package/{src/client → client}/types.ts +0 -0
- package/{src/client → client}/utils/helper.ts +22 -0
- package/{src/client → client}/utils/index.ts +0 -0
- package/client/utils/sidebar.ts +26 -0
- package/{src/client → client}/utils/time.ts +0 -0
- package/config/index.ts +18 -0
- package/dist/chunk-EAN2KU6W.mjs +1 -0
- package/dist/chunk-HMUGSKPK.mjs +40 -0
- package/dist/chunk-U5OMNIOK.js +1 -0
- package/dist/chunk-ZHHNO5RK.js +40 -0
- package/dist/{config-de04677b.d.ts → config-112ac884.d.ts} +37 -14
- package/dist/index.d.ts +65 -111
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/node/cli.js +7 -11
- package/dist/node/cli.mjs +7 -11
- package/dist/node/index.d.ts +3 -2
- package/dist/node/index.js +1 -1
- package/dist/node/index.mjs +1 -1
- package/{src/index.ts → index.ts} +1 -0
- package/{src/node → node}/build.ts +0 -0
- package/{src/node → node}/cli.ts +3 -2
- package/node/config.ts +156 -0
- package/{src/node → node}/index.ts +0 -0
- package/{src/node → node}/markdown/check.ts +0 -0
- package/node/markdown/highlight.ts +38 -0
- package/{src/node → node}/markdown/index.ts +30 -16
- package/{src/node → node}/markdown/markdown-it/container.ts +0 -0
- package/{src/node → node}/markdown/markdown-it/headings.ts +0 -0
- package/{src/node → node}/markdown/markdown-it/highlightLines.ts +1 -1
- package/{src/node → node}/markdown/markdown-it/katex.ts +0 -0
- package/{src/node → node}/markdown/markdown-it/parseHeader.ts +0 -0
- package/node/markdown/markdownToVue.ts +274 -0
- package/{src/node → node}/markdown/slugify.ts +0 -0
- package/{src/node → node}/options.ts +18 -2
- package/{src/node → node}/plugins/extendConfig.ts +5 -3
- package/node/plugins/index.ts +224 -0
- package/{src/node → node}/plugins/preset.ts +8 -8
- package/{src/node → node}/plugins/unocss.ts +0 -0
- package/{src/node → node}/plugins/valaxy.ts +0 -0
- package/{src/node → node}/rss.ts +1 -1
- package/{src/node → node}/server.ts +0 -0
- package/{src/node → node}/shims.d.ts +0 -5
- package/{src/node → node}/utils/cli.ts +1 -1
- package/node/utils/getGitTimestamp.ts +13 -0
- package/node/utils/index.ts +59 -0
- package/node/utils/net.ts +20 -0
- package/{src/node → node}/vite.ts +5 -1
- package/package.json +32 -13
- package/shared/index.ts +1 -0
- package/tsup.config.ts +7 -4
- package/{src/types → types}/config.ts +31 -108
- package/types/data.ts +31 -0
- package/{src/types → types}/index.ts +1 -0
- package/{src/types → types}/posts.ts +6 -1
- package/dist/chunk-6LIOFBAA.mjs +0 -1
- package/dist/chunk-HRARZPSA.js +0 -83
- package/dist/chunk-N6HD5SHF.mjs +0 -83
- package/dist/chunk-V3BMKLEW.js +0 -1
- package/src/client/components/PostCard.vue +0 -68
- package/src/client/components/ValaxyMd.vue +0 -71
- package/src/client/composables/features/index.ts +0 -1
- package/src/client/composables/features/katex.ts +0 -15
- package/src/client/composables/search/algolia.ts +0 -115
- package/src/client/config.ts +0 -51
- package/src/client/styles/common/code.scss +0 -207
- package/src/client/styles/common/scrollbar.scss +0 -34
- package/src/client/styles/css-vars.scss +0 -39
- package/src/client/styles/vars.scss +0 -27
- package/src/node/config.ts +0 -52
- package/src/node/markdown/highlight.ts +0 -50
- package/src/node/plugins/index.ts +0 -120
- package/src/node/plugins/markdown.ts +0 -57
- 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
|
-
}
|
package/src/node/utils/index.ts
DELETED
|
@@ -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
|
-
}
|