valaxy 0.5.0 → 0.6.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/README.md +0 -4
- package/{dist/types/index.mjs → client/app/data.ts} +0 -0
- package/client/components/PostCard.vue +4 -2
- package/client/components/ValaxyBg.vue +1 -1
- package/client/components/ValaxyFooter.vue +1 -1
- package/client/components/ValaxyMd.vue +34 -27
- package/client/components/ValaxyToc.vue +3 -3
- package/client/composables/copy-code.ts +92 -0
- package/client/composables/outline.ts +168 -0
- package/client/composables/sidebar.ts +46 -1
- package/client/config.ts +30 -7
- package/client/main.ts +4 -1
- package/client/modules/valaxy.ts +19 -7
- package/client/shims.d.ts +6 -1
- package/client/styles/common/code.scss +191 -167
- package/client/styles/common/markdown.scss +0 -2
- package/client/styles/css-vars.scss +30 -7
- package/client/styles/palette.scss +21 -2
- package/client/styles/vars.scss +32 -18
- package/client/utils/helper.ts +22 -0
- package/client/utils/sidebar.ts +26 -0
- package/config/index.ts +18 -0
- package/dist/chunk-23IW567G.mjs +40 -0
- package/dist/chunk-YUC5WP5Y.js +40 -0
- package/dist/{config-7bd43d41.d.ts → config-112ac884.d.ts} +15 -4
- package/dist/index.d.ts +361 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- 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/index.ts +3 -0
- package/node/config.ts +9 -23
- package/node/markdown/highlight.ts +27 -39
- package/node/markdown/index.ts +30 -16
- package/node/markdown/markdown-it/highlightLines.ts +1 -1
- package/node/markdown/markdownToVue.ts +275 -0
- package/node/options.ts +16 -0
- package/node/plugins/extendConfig.ts +4 -3
- package/node/plugins/index.ts +104 -7
- package/node/plugins/preset.ts +8 -8
- package/node/rss.ts +1 -1
- package/node/shims.d.ts +0 -5
- package/node/utils/getGitTimestamp.ts +13 -0
- package/node/utils/index.ts +11 -0
- package/package.json +20 -9
- package/shared/index.ts +1 -0
- package/tsup.config.ts +5 -3
- package/types/config.ts +7 -4
- package/types/data.ts +31 -0
- package/types/index.ts +1 -0
- package/types/posts.ts +1 -1
- package/dist/chunk-RSQONJW3.mjs +0 -86
- package/dist/chunk-XQIGHIAX.js +0 -86
- package/dist/client/index.d.ts +0 -188
- package/dist/client/index.js +0 -1
- package/dist/client/index.mjs +0 -1
- package/dist/posts-32f55e33.d.ts +0 -117
- package/dist/types/index.d.ts +0 -8
- package/dist/types/index.js +0 -1
- package/index.d.ts +0 -3
- package/node/plugins/markdown.ts +0 -54
package/node/plugins/index.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
2
|
|
|
3
|
-
import { join } from 'path'
|
|
4
|
-
import type { Plugin } from 'vite'
|
|
3
|
+
import { join, relative } from 'path'
|
|
4
|
+
import type { Plugin, ResolvedConfig } from 'vite'
|
|
5
5
|
// import consola from 'consola'
|
|
6
6
|
import { resolveConfig } from '../config'
|
|
7
7
|
import type { ResolvedValaxyOptions, ValaxyServerOptions } from '../options'
|
|
8
|
-
import { resolveImportPath, toAtFS } from '../utils'
|
|
8
|
+
import { resolveImportPath, slash, toAtFS } from '../utils'
|
|
9
|
+
import { createMarkdownToVueRenderFn } from '../markdown/markdownToVue'
|
|
10
|
+
import type { PageDataPayload } from '../../types'
|
|
11
|
+
import { checkMd } from '../markdown/check'
|
|
9
12
|
import { VALAXY_CONFIG_ID } from './valaxy'
|
|
10
13
|
|
|
11
14
|
/**
|
|
@@ -19,7 +22,7 @@ function generateStyles(roots: string[], options: ResolvedValaxyOptions) {
|
|
|
19
22
|
// katex
|
|
20
23
|
if (options.config.features.katex) {
|
|
21
24
|
imports.push(`import "${toAtFS(resolveImportPath('katex/dist/katex.min.css', true))}"`)
|
|
22
|
-
imports.push(`import "${join(options.clientRoot, 'styles/third/katex.scss')}"`)
|
|
25
|
+
imports.push(`import "${toAtFS(join(options.clientRoot, 'styles/third/katex.scss'))}"`)
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
for (const root of roots) {
|
|
@@ -68,8 +71,26 @@ export function createValaxyPlugin(options: ResolvedValaxyOptions, serverOptions
|
|
|
68
71
|
|
|
69
72
|
const roots = [options.clientRoot, options.themeRoot, options.userRoot]
|
|
70
73
|
|
|
74
|
+
let markdownToVue: Awaited<ReturnType<typeof createMarkdownToVueRenderFn>>
|
|
75
|
+
let hasDeadLinks = false
|
|
76
|
+
let config: ResolvedConfig
|
|
77
|
+
|
|
71
78
|
return {
|
|
72
|
-
name: '
|
|
79
|
+
name: 'valaxy',
|
|
80
|
+
enforce: 'pre',
|
|
81
|
+
|
|
82
|
+
async configResolved(resolvedConfig) {
|
|
83
|
+
config = resolvedConfig
|
|
84
|
+
markdownToVue = await createMarkdownToVueRenderFn(
|
|
85
|
+
options.userRoot,
|
|
86
|
+
options.config.markdownIt,
|
|
87
|
+
options.pages,
|
|
88
|
+
config.define,
|
|
89
|
+
config.command === 'build',
|
|
90
|
+
config.base,
|
|
91
|
+
options.config.lastUpdated,
|
|
92
|
+
)
|
|
93
|
+
},
|
|
73
94
|
|
|
74
95
|
configureServer(server) {
|
|
75
96
|
server.watcher.add([
|
|
@@ -90,6 +111,13 @@ export function createValaxyPlugin(options: ResolvedValaxyOptions, serverOptions
|
|
|
90
111
|
// stringify twice for \"
|
|
91
112
|
return `export default ${JSON.stringify(JSON.stringify(valaxyConfig))}`
|
|
92
113
|
|
|
114
|
+
if (id === '/@valaxyjs/context') {
|
|
115
|
+
return `export default ${JSON.stringify(JSON.stringify({
|
|
116
|
+
userRoot: options.userRoot,
|
|
117
|
+
// clientRoot: options.clientRoot,
|
|
118
|
+
}))}`
|
|
119
|
+
}
|
|
120
|
+
|
|
93
121
|
// generate styles
|
|
94
122
|
if (id === '/@valaxyjs/styles')
|
|
95
123
|
return generateStyles(roots, options)
|
|
@@ -101,12 +129,81 @@ export function createValaxyPlugin(options: ResolvedValaxyOptions, serverOptions
|
|
|
101
129
|
return ''
|
|
102
130
|
},
|
|
103
131
|
|
|
132
|
+
async transform(code, id) {
|
|
133
|
+
if (id.endsWith('.md')) {
|
|
134
|
+
checkMd(code, id)
|
|
135
|
+
code.replace('{%', '\{\%')
|
|
136
|
+
code.replace('%}', '\%\}')
|
|
137
|
+
|
|
138
|
+
// const scripts = [
|
|
139
|
+
// '<script setup>',
|
|
140
|
+
// 'import { useRoute } from "vue-router"',
|
|
141
|
+
// 'const route = useRoute()',
|
|
142
|
+
// `route.meta.headers = ${JSON.stringify(_md.__data)}`,
|
|
143
|
+
// `export const data = JSON.parse(${JSON.stringify(JSON.stringify(pageData))})`,
|
|
144
|
+
// `frontmatter.data = JSON.parse(${JSON.stringify(JSON.stringify(pageData))})`,
|
|
145
|
+
// '</script>',
|
|
146
|
+
// ]
|
|
147
|
+
|
|
148
|
+
// const li = code.lastIndexOf('</script>')
|
|
149
|
+
// code = code.slice(0, li) + scripts.join('\n') + code.slice(li + 9)
|
|
150
|
+
|
|
151
|
+
// transform .md files into vueSrc so plugin-vue can handle it
|
|
152
|
+
const { vueSrc, deadLinks, includes } = await markdownToVue(
|
|
153
|
+
code,
|
|
154
|
+
id,
|
|
155
|
+
config.publicDir,
|
|
156
|
+
)
|
|
157
|
+
if (deadLinks.length)
|
|
158
|
+
hasDeadLinks = true
|
|
159
|
+
|
|
160
|
+
if (includes.length) {
|
|
161
|
+
includes.forEach((i) => {
|
|
162
|
+
this.addWatchFile(i)
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return vueSrc
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
renderStart() {
|
|
171
|
+
if (hasDeadLinks)
|
|
172
|
+
throw new Error('One or more pages contain dead links.')
|
|
173
|
+
},
|
|
174
|
+
|
|
104
175
|
async handleHotUpdate(ctx) {
|
|
105
176
|
// handle valaxy.config.ts hmr
|
|
106
|
-
const { file, server } = ctx
|
|
177
|
+
const { file, server, read } = ctx
|
|
107
178
|
if (file !== options.configFile)
|
|
108
179
|
return
|
|
109
180
|
|
|
181
|
+
// send headers
|
|
182
|
+
if (file.endsWith('.md')) {
|
|
183
|
+
const content = await read()
|
|
184
|
+
const { pageData, vueSrc } = await markdownToVue(
|
|
185
|
+
content,
|
|
186
|
+
file,
|
|
187
|
+
join(options.userRoot, 'public'),
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
const path = `/${slash(relative(`${options.userRoot}/pages`, file))}`
|
|
191
|
+
const payload: PageDataPayload = {
|
|
192
|
+
// path: `/${slash(relative(srcDir, file))}`,
|
|
193
|
+
path,
|
|
194
|
+
pageData,
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
server.ws.send({
|
|
198
|
+
type: 'custom',
|
|
199
|
+
event: 'valaxy:pageData',
|
|
200
|
+
data: payload,
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
// overwrite src so vue plugin can handle the HMR
|
|
204
|
+
ctx.read = () => vueSrc
|
|
205
|
+
}
|
|
206
|
+
|
|
110
207
|
const { config } = await resolveConfig()
|
|
111
208
|
|
|
112
209
|
serverOptions.onConfigReload?.(config, options.config)
|
|
@@ -116,7 +213,7 @@ export function createValaxyPlugin(options: ResolvedValaxyOptions, serverOptions
|
|
|
116
213
|
// consola.warn('[valaxy]: config.base has changed. Please restart the dev server.')
|
|
117
214
|
valaxyConfig = config
|
|
118
215
|
|
|
119
|
-
const moduleIds = [`/${VALAXY_CONFIG_ID}
|
|
216
|
+
const moduleIds = [`/${VALAXY_CONFIG_ID}`, '/@valaxyjs/context']
|
|
120
217
|
const moduleEntries = [
|
|
121
218
|
...Array.from(moduleIds).map(id => server.moduleGraph.getModuleById(id)),
|
|
122
219
|
].filter(<T>(item: T): item is NonNullable<T> => !!item)
|
package/node/plugins/preset.ts
CHANGED
|
@@ -16,7 +16,7 @@ import Inspect from 'vite-plugin-inspect'
|
|
|
16
16
|
import { dim, yellow } from 'kolorist'
|
|
17
17
|
import type { ResolvedValaxyOptions, ValaxyServerOptions } from '../options'
|
|
18
18
|
import { setupMarkdownPlugins } from '../markdown'
|
|
19
|
-
import { createMarkdownPlugin, excerpt_separator } from './markdown'
|
|
19
|
+
// import { createMarkdownPlugin, excerpt_separator } from './markdown'
|
|
20
20
|
import { createUnocssPlugin } from './unocss'
|
|
21
21
|
import { createConfigPlugin } from './extendConfig'
|
|
22
22
|
import { createValaxyPlugin } from '.'
|
|
@@ -32,17 +32,17 @@ export async function ViteValaxyPlugins(
|
|
|
32
32
|
): Promise<(PluginOption | PluginOption[])[] | undefined> {
|
|
33
33
|
const { clientRoot, themeRoot, userRoot } = options
|
|
34
34
|
|
|
35
|
-
const MarkdownPlugin = createMarkdownPlugin(options)
|
|
35
|
+
// const MarkdownPlugin = createMarkdownPlugin(options)
|
|
36
36
|
const UnocssPlugin = await createUnocssPlugin(options)
|
|
37
37
|
|
|
38
38
|
const ValaxyPlugin = createValaxyPlugin(options, serverOptions)
|
|
39
39
|
|
|
40
40
|
const mdIt = new MarkdownIt({ html: true })
|
|
41
|
-
setupMarkdownPlugins(mdIt, options.config.markdownIt)
|
|
41
|
+
await setupMarkdownPlugins(mdIt, options.config.markdownIt)
|
|
42
42
|
|
|
43
43
|
const roots = [clientRoot, themeRoot, userRoot]
|
|
44
44
|
|
|
45
|
-
const { default: ThemePlugin } = await import(`valaxy-theme-${options.theme}`)
|
|
45
|
+
const { default: ThemePlugin } = (await import(`valaxy-theme-${options.theme}`))
|
|
46
46
|
|
|
47
47
|
const customElements = new Set([
|
|
48
48
|
// katex
|
|
@@ -90,8 +90,8 @@ export async function ViteValaxyPlugins(
|
|
|
90
90
|
},
|
|
91
91
|
}),
|
|
92
92
|
|
|
93
|
-
ValaxyPlugin,
|
|
94
93
|
createConfigPlugin(options),
|
|
94
|
+
ValaxyPlugin,
|
|
95
95
|
|
|
96
96
|
ThemePlugin(options.config.themeConfig),
|
|
97
97
|
|
|
@@ -118,7 +118,7 @@ export async function ViteValaxyPlugins(
|
|
|
118
118
|
})
|
|
119
119
|
|
|
120
120
|
const md = fs.readFileSync(path, 'utf-8')
|
|
121
|
-
const { data, excerpt } = matter(md, { excerpt_separator })
|
|
121
|
+
const { data, excerpt } = matter(md, { excerpt_separator: '<!-- more -->' })
|
|
122
122
|
|
|
123
123
|
// warn for post frontmatter
|
|
124
124
|
if (route.path.startsWith('/posts/')) {
|
|
@@ -160,7 +160,7 @@ export async function ViteValaxyPlugins(
|
|
|
160
160
|
allowOverrides: true,
|
|
161
161
|
// override: user -> theme -> client
|
|
162
162
|
// latter override former
|
|
163
|
-
dirs: roots.map(root => `${root}/components`).concat(['src/components', 'components']),
|
|
163
|
+
dirs: roots.map(root => `${root}/components`).concat(roots.map(root => `${root}/layouts`)).concat(['src/components', 'components']),
|
|
164
164
|
dts: `${options.userRoot}/components.d.ts`,
|
|
165
165
|
|
|
166
166
|
...pluginOptions,
|
|
@@ -170,7 +170,7 @@ export async function ViteValaxyPlugins(
|
|
|
170
170
|
// UnocssPlugin,
|
|
171
171
|
UnocssPlugin,
|
|
172
172
|
|
|
173
|
-
...MarkdownPlugin,
|
|
173
|
+
// ...MarkdownPlugin,
|
|
174
174
|
|
|
175
175
|
// https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n
|
|
176
176
|
VueI18n({
|
package/node/rss.ts
CHANGED
|
@@ -24,7 +24,7 @@ const markdown = MarkdownIt({
|
|
|
24
24
|
export async function build(options: ResolvedValaxyOptions) {
|
|
25
25
|
const { config } = options
|
|
26
26
|
|
|
27
|
-
if (!config.url) {
|
|
27
|
+
if (!config.url || config.url === '/') {
|
|
28
28
|
consola.error('You must set "config.url" to generate rss.')
|
|
29
29
|
return
|
|
30
30
|
}
|
package/node/shims.d.ts
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { spawn } from 'cross-spawn'
|
|
2
|
+
|
|
3
|
+
export function getGitTimestamp(file: string) {
|
|
4
|
+
return new Promise<number>((resolve, reject) => {
|
|
5
|
+
const child = spawn('git', ['log', '-1', '--pretty="%ci"', file])
|
|
6
|
+
let output = ''
|
|
7
|
+
child.stdout.on('data', d => (output += String(d)))
|
|
8
|
+
child.on('close', () => {
|
|
9
|
+
resolve(+new Date(output))
|
|
10
|
+
})
|
|
11
|
+
child.on('error', reject)
|
|
12
|
+
})
|
|
13
|
+
}
|
package/node/utils/index.ts
CHANGED
|
@@ -4,6 +4,17 @@ import globalDirs from 'global-dirs'
|
|
|
4
4
|
import { sync as resolve } from 'resolve'
|
|
5
5
|
import consola from 'consola'
|
|
6
6
|
|
|
7
|
+
export * from './getGitTimestamp'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* transform obj for vite cde
|
|
11
|
+
* @param obj
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export const transformObject = (obj: any) => {
|
|
15
|
+
return `JSON.parse(${JSON.stringify(JSON.stringify(obj))})`
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
export function slash(str: string) {
|
|
8
19
|
return str.replace(/\\/g, '/')
|
|
9
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valaxy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "📄 Vite & Vue powered static blog generator.",
|
|
5
5
|
"author": {
|
|
6
6
|
"email": "me@yunyoujun.cn",
|
|
@@ -17,16 +17,22 @@
|
|
|
17
17
|
],
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
|
-
"types": "./index.d.ts",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
21
|
"require": "./dist/index.js",
|
|
22
22
|
"import": "./dist/index.mjs"
|
|
23
23
|
},
|
|
24
24
|
"./client": "./dist/client.d.ts",
|
|
25
25
|
"./client/*": "./client/*",
|
|
26
|
+
"./node": {
|
|
27
|
+
"types": "./dist/node/index.d.ts",
|
|
28
|
+
"require": "./dist/node/index.js",
|
|
29
|
+
"import": "./dist/node/index.mjs"
|
|
30
|
+
},
|
|
26
31
|
"./*": "./*"
|
|
27
32
|
},
|
|
28
33
|
"main": "dist/index.js",
|
|
29
|
-
"
|
|
34
|
+
"module": "dist/index.mjs",
|
|
35
|
+
"types": "dist/index.d.ts",
|
|
30
36
|
"bin": {
|
|
31
37
|
"vala": "./bin/valaxy.js",
|
|
32
38
|
"valaxy": "./bin/valaxy.js"
|
|
@@ -35,6 +41,7 @@
|
|
|
35
41
|
"node": ">=14.0.0"
|
|
36
42
|
},
|
|
37
43
|
"dependencies": {
|
|
44
|
+
"@antfu/utils": "^0.5.2",
|
|
38
45
|
"@ctrl/tinycolor": "^3.4.1",
|
|
39
46
|
"@docsearch/css": "^3.1.0",
|
|
40
47
|
"@docsearch/js": "^3.1.0",
|
|
@@ -42,15 +49,19 @@
|
|
|
42
49
|
"@iconify-json/ri": "^1.1.2",
|
|
43
50
|
"@intlify/vite-plugin-vue-i18n": "^3.4.0",
|
|
44
51
|
"@vitejs/plugin-vue": "^2.3.3",
|
|
45
|
-
"@vueuse/core": "^8.7.
|
|
52
|
+
"@vueuse/core": "^8.7.4",
|
|
46
53
|
"@vueuse/head": "^0.7.6",
|
|
47
54
|
"consola": "^2.15.3",
|
|
48
55
|
"critters": "^0.0.16",
|
|
56
|
+
"cross-spawn": "^7.0.3",
|
|
49
57
|
"dayjs": "^1.11.3",
|
|
50
58
|
"escape-html": "^1.0.3",
|
|
51
59
|
"feed": "^4.2.2",
|
|
60
|
+
"gray-matter": "^4.0.3",
|
|
52
61
|
"katex": "^0.16.0",
|
|
53
62
|
"kolorist": "^1.5.1",
|
|
63
|
+
"lru-cache": "^7.10.1",
|
|
64
|
+
"markdown-it": "^13.0.1",
|
|
54
65
|
"markdown-it-anchor": "^8.6.4",
|
|
55
66
|
"markdown-it-attrs": "^4.1.4",
|
|
56
67
|
"markdown-it-container": "^3.0.0",
|
|
@@ -61,16 +72,14 @@
|
|
|
61
72
|
"nprogress": "^0.2.0",
|
|
62
73
|
"open": "^8.4.0",
|
|
63
74
|
"pinia": "^2.0.14",
|
|
64
|
-
"prism-theme-vars": "^0.2.3",
|
|
65
|
-
"prismjs": "^1.28.0",
|
|
66
75
|
"sass": "^1.52.3",
|
|
76
|
+
"shiki": "^0.10.1",
|
|
67
77
|
"star-markdown-css": "^0.3.3",
|
|
68
78
|
"unconfig": "^0.3.4",
|
|
69
|
-
"unocss": "^0.39.
|
|
79
|
+
"unocss": "^0.39.3",
|
|
70
80
|
"unplugin-vue-components": "^0.19.6",
|
|
71
81
|
"vite": "^2.9.12",
|
|
72
82
|
"vite-plugin-inspect": "^0.5.0",
|
|
73
|
-
"vite-plugin-md": "^0.13.1",
|
|
74
83
|
"vite-plugin-pages": "^0.24.2",
|
|
75
84
|
"vite-plugin-vue-layouts": "^0.6.0",
|
|
76
85
|
"vite-ssg": "0.19.2",
|
|
@@ -81,7 +90,9 @@
|
|
|
81
90
|
"yargs": "^17.5.1"
|
|
82
91
|
},
|
|
83
92
|
"devDependencies": {
|
|
93
|
+
"@types/cross-spawn": "^6.0.2",
|
|
84
94
|
"@types/katex": "^0.14.0",
|
|
95
|
+
"@types/lru-cache": "^7.10.10",
|
|
85
96
|
"@types/markdown-it-link-attributes": "^3.0.1",
|
|
86
97
|
"@types/nprogress": "^0.2.0",
|
|
87
98
|
"@types/yargs": "^17.0.10",
|
|
@@ -92,7 +103,7 @@
|
|
|
92
103
|
},
|
|
93
104
|
"scripts": {
|
|
94
105
|
"build": "rimraf dist && tsup --splitting",
|
|
95
|
-
"dev": "tsup --
|
|
106
|
+
"dev": "tsup --splitting --watch",
|
|
96
107
|
"lint": "eslint \"**/*.{vue,ts,js}\"",
|
|
97
108
|
"preview": "vite preview",
|
|
98
109
|
"preview-https": "serve dist"
|
package/shared/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const EXTERNAL_URL_RE = /^https?:/i
|
package/tsup.config.ts
CHANGED
|
@@ -3,20 +3,22 @@ import { defineConfig } from 'tsup'
|
|
|
3
3
|
export default defineConfig((options) => {
|
|
4
4
|
return {
|
|
5
5
|
entry: [
|
|
6
|
-
'
|
|
6
|
+
'index.ts',
|
|
7
|
+
// 'client/index.ts',
|
|
7
8
|
'node/index.ts',
|
|
8
9
|
'node/cli.ts',
|
|
9
|
-
'types/index.ts',
|
|
10
|
+
// 'types/index.ts',
|
|
10
11
|
],
|
|
11
12
|
// https://tsup.egoist.sh/#code-splitting
|
|
12
13
|
// 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.
|
|
13
|
-
splitting: true,
|
|
14
|
+
// splitting: true,
|
|
14
15
|
clean: true,
|
|
15
16
|
dts: true,
|
|
16
17
|
format: ['cjs', 'esm'],
|
|
17
18
|
minify: !options.watch,
|
|
18
19
|
external: [
|
|
19
20
|
'@valaxyjs/config',
|
|
21
|
+
'@valaxyjs/context',
|
|
20
22
|
'valaxy-theme-yun',
|
|
21
23
|
],
|
|
22
24
|
}
|
package/types/config.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import type { PartialDeep } from 'type-fest'
|
|
2
2
|
import type { VitePluginConfig } from 'unocss/vite'
|
|
3
|
-
import type Markdown from 'vite-plugin-md'
|
|
4
3
|
import type { MarkdownOptions } from '../node/markdown'
|
|
5
4
|
|
|
6
|
-
export type ViteMdOptions = Parameters<typeof Markdown>[0]
|
|
7
|
-
|
|
8
5
|
export type ValaxyThemeConfig = Record<string, any>
|
|
9
6
|
|
|
10
7
|
export interface SocialLink {
|
|
@@ -32,6 +29,7 @@ export interface AlgoliaSearchOptions {
|
|
|
32
29
|
initialQuery?: string
|
|
33
30
|
}
|
|
34
31
|
|
|
32
|
+
// packages/valaxy/node/config.ts
|
|
35
33
|
export interface ValaxyConfig<T = ValaxyThemeConfig> {
|
|
36
34
|
/**
|
|
37
35
|
* Default language
|
|
@@ -42,6 +40,7 @@ export interface ValaxyConfig<T = ValaxyThemeConfig> {
|
|
|
42
40
|
/**
|
|
43
41
|
* You site url in web, required for ssg & rss
|
|
44
42
|
* @description 站点的 URL,SSG & RSS 需要(譬如生成版权处文章永久链接)
|
|
43
|
+
* @default '/'
|
|
45
44
|
*/
|
|
46
45
|
url: string
|
|
47
46
|
/**
|
|
@@ -84,6 +83,11 @@ export interface ValaxyConfig<T = ValaxyThemeConfig> {
|
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
85
|
|
|
86
|
+
/**
|
|
87
|
+
* show last updated time by git
|
|
88
|
+
*/
|
|
89
|
+
lastUpdated: boolean
|
|
90
|
+
|
|
87
91
|
/**
|
|
88
92
|
* icon for your website
|
|
89
93
|
*/
|
|
@@ -203,7 +207,6 @@ export interface ValaxyConfig<T = ValaxyThemeConfig> {
|
|
|
203
207
|
/**
|
|
204
208
|
* for markdown
|
|
205
209
|
*/
|
|
206
|
-
markdown: ViteMdOptions
|
|
207
210
|
markdownIt: MarkdownOptions
|
|
208
211
|
}
|
|
209
212
|
|
package/types/data.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Post } from './posts'
|
|
2
|
+
|
|
3
|
+
export interface Header {
|
|
4
|
+
level: number
|
|
5
|
+
title: string
|
|
6
|
+
slug: string
|
|
7
|
+
/**
|
|
8
|
+
* i18n
|
|
9
|
+
*/
|
|
10
|
+
lang?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface PageData {
|
|
14
|
+
path: string
|
|
15
|
+
relativePath: string
|
|
16
|
+
title: string
|
|
17
|
+
titleTemplate?: string
|
|
18
|
+
description: string
|
|
19
|
+
headers: Header[]
|
|
20
|
+
frontmatter: Post
|
|
21
|
+
lastUpdated?: number
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface PageDataPayload {
|
|
25
|
+
path: string
|
|
26
|
+
pageData: PageData
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type HeadConfig =
|
|
30
|
+
| [string, Record<string, string>]
|
|
31
|
+
| [string, Record<string, string>, string]
|
package/types/index.ts
CHANGED
package/types/posts.ts
CHANGED