valaxy 0.1.1 → 0.2.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/bin/valaxy.js +1 -1
- package/dist/chunk-B2JVVNA4.js +88 -0
- package/dist/chunk-FH6NMGNX.mjs +88 -0
- package/dist/chunk-TSLYS2VY.js +1 -0
- package/dist/chunk-U4ZDCBEC.mjs +1 -0
- package/dist/config-24b4f209.d.ts +188 -0
- package/dist/index.d.ts +337 -150
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{cli.d.ts → node/cli.d.ts} +0 -0
- package/dist/node/cli.js +45 -0
- package/dist/node/cli.mjs +45 -0
- package/dist/node/index.d.ts +46 -0
- package/dist/node/index.js +1 -0
- package/dist/node/index.mjs +1 -0
- package/package.json +23 -20
- package/src/client/components/PostCard.vue +16 -17
- package/src/client/components/PostList.vue +3 -3
- package/src/client/components/ValaxyCopyright.vue +1 -1
- package/src/client/components/ValaxyFooter.vue +1 -1
- package/src/client/components/ValaxyMd.vue +1 -1
- package/src/client/components/ValaxyOverlay.vue +4 -4
- package/src/client/components/ValaxyPagination.vue +14 -11
- package/src/client/components/ValaxyRightSidebar.vue +2 -2
- package/src/client/components/ValaxySidebar.vue +4 -10
- package/src/client/components/ValaxyToc.vue +12 -10
- package/src/client/composables/category.ts +24 -5
- package/src/client/composables/comments/index.ts +1 -0
- package/src/client/composables/comments/twikoo.ts +37 -0
- package/src/client/composables/comments/waline.ts +8 -5
- package/src/client/composables/common.ts +3 -4
- package/src/client/composables/post.ts +26 -1
- package/src/client/composables/search/algolia.ts +2 -1
- package/src/client/composables/sidebar.ts +2 -2
- package/src/client/composables/tag.ts +9 -2
- package/src/client/composables/widgets/backToTop.ts +10 -4
- package/src/client/index.html +5 -0
- package/src/client/layouts/404.vue +5 -1
- package/src/client/main.ts +2 -9
- package/src/client/modules/valaxy.ts +31 -13
- package/src/client/shims.d.ts +5 -5
- package/src/client/styles/common/button.scss +3 -5
- package/src/client/styles/common/code.scss +181 -9
- package/src/client/styles/common/custom-blocks.scss +84 -0
- package/src/client/styles/common/hamburger.scss +2 -2
- package/src/client/styles/common/markdown.scss +4 -6
- package/src/client/styles/common/sidebar.scss +3 -3
- package/src/client/styles/common/transition.scss +2 -2
- package/src/client/styles/css-vars.scss +39 -0
- package/src/client/styles/global/helper.scss +2 -2
- package/src/client/styles/global/i18n.scss +20 -0
- 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 +1 -1
- package/src/client/styles/index.scss +21 -8
- package/src/client/styles/mixins/config.scss +1 -1
- package/src/client/styles/mixins/index.scss +1 -0
- package/src/client/styles/palette.scss +58 -44
- 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 +32 -19
- package/src/node/markdown/headings.ts +3 -2
- package/src/node/markdown/highlight.ts +50 -0
- package/src/node/markdown/highlightLines.ts +96 -0
- package/src/node/markdown/index.ts +23 -12
- package/src/node/markdown/markdown-it-container.ts +9 -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 +46 -10
- package/src/node/plugins/unocss.ts +21 -19
- package/src/node/rss.ts +127 -0
- package/src/node/server.ts +1 -1
- package/src/node/shims.d.ts +15 -0
- package/src/node/utils/cli.ts +0 -1
- package/src/node/vite.ts +7 -15
- package/src/types/config.ts +28 -2
- package/src/types/posts.ts +6 -1
- package/tsup.config.ts +1 -0
- package/dist/build-VGAF4K5S.js +0 -1
- package/dist/build-Y5F7AZ2V.mjs +0 -1
- package/dist/chunk-5KQ3UFYI.js +0 -1
- package/dist/chunk-ESCOXVP6.mjs +0 -83
- package/dist/chunk-JWA76JND.mjs +0 -1
- package/dist/chunk-WYCH73X6.js +0 -83
- package/dist/cli.js +0 -6
- package/dist/cli.mjs +0 -6
- package/src/client/pages/about/index.md +0 -5
- package/src/client/pages/posts/index.md +0 -5
- package/src/client/styles/css-vars/dark.scss +0 -17
- package/src/client/styles/css-vars/index.scss +0 -18
- 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,22 +43,60 @@ 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
|
},
|
|
59
|
-
})
|
|
92
|
+
}),
|
|
60
93
|
|
|
61
94
|
ValaxyPlugin,
|
|
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'
|
|
@@ -174,10 +210,10 @@ export function ViteValaxyPlugins(
|
|
|
174
210
|
runtimeOnly: true,
|
|
175
211
|
compositionOnly: true,
|
|
176
212
|
include: roots.map(root => `${root}/locales/**`),
|
|
177
|
-
})
|
|
213
|
+
}),
|
|
178
214
|
|
|
179
215
|
// https://github.com/antfu/vite-plugin-inspect
|
|
180
216
|
// Visit http://localhost:3333/__inspect/ to see the inspector
|
|
181
|
-
mode === 'dev' && Inspect(),
|
|
217
|
+
options.mode === 'dev' && Inspect(),
|
|
182
218
|
]
|
|
183
219
|
}
|
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
transformerVariantGroup,
|
|
13
13
|
} from 'unocss'
|
|
14
14
|
import type { ValaxyConfig } from 'valaxy'
|
|
15
|
-
import type { ThemeUserConfig } from 'valaxy-theme-yun
|
|
15
|
+
import type { ThemeUserConfig } from 'valaxy-theme-yun'
|
|
16
|
+
import { generateSafelist } from 'valaxy-theme-yun'
|
|
16
17
|
import type { ResolvedValaxyOptions } from '../options'
|
|
17
18
|
|
|
18
19
|
export const createSafelist = (config: ValaxyConfig<ThemeUserConfig>) => {
|
|
@@ -24,26 +25,22 @@ export const createSafelist = (config: ValaxyConfig<ThemeUserConfig>) => {
|
|
|
24
25
|
'i-ri-cloud-line',
|
|
25
26
|
]
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
let themeSafelist: string[] = []
|
|
29
|
+
if (typeof generateSafelist === 'function')
|
|
30
|
+
themeSafelist = generateSafelist(config.themeConfig)
|
|
31
|
+
|
|
32
|
+
const safelist = 'animate-fade-in m-auto text-left'.split(' ').concat([
|
|
28
33
|
'rotate-y-180',
|
|
29
|
-
]).concat(safeIcons)
|
|
34
|
+
]).concat(safeIcons).concat(themeSafelist)
|
|
35
|
+
|
|
30
36
|
// generate icon safelist
|
|
31
37
|
if (config.social.length)
|
|
32
38
|
config.social.forEach(item => safelist.push(item.icon))
|
|
33
39
|
|
|
34
|
-
if (config.themeConfig.footer?.icon?.name)
|
|
35
|
-
safelist.push(config.themeConfig.footer?.icon?.name)
|
|
36
|
-
|
|
37
40
|
// sponsor icon
|
|
38
41
|
if (config.sponsor.methods.length)
|
|
39
42
|
config.sponsor.methods.forEach(item => safelist.push(item.icon))
|
|
40
43
|
|
|
41
|
-
const types = config.themeConfig.types
|
|
42
|
-
if (types) {
|
|
43
|
-
for (const type in types)
|
|
44
|
-
safelist.push(types[type].icon)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
44
|
return safelist
|
|
48
45
|
}
|
|
49
46
|
|
|
@@ -54,7 +51,7 @@ export const createUnocssConfig = (options: ResolvedValaxyOptions) => {
|
|
|
54
51
|
['yun-card', 'transition yun-transition shadow hover:shadow-lg'],
|
|
55
52
|
['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
53
|
['icon-btn', 'inline-block cursor-pointer select-none opacity-75 transition duration-200 ease-in-out hover:opacity-100 hover:text-sky-600'],
|
|
57
|
-
['
|
|
54
|
+
['va-card', 'transition shadow hover:shadow-lg'],
|
|
58
55
|
],
|
|
59
56
|
presets: [
|
|
60
57
|
presetUno(),
|
|
@@ -66,7 +63,12 @@ export const createUnocssConfig = (options: ResolvedValaxyOptions) => {
|
|
|
66
63
|
presetTypography(),
|
|
67
64
|
presetWebFonts({
|
|
68
65
|
fonts: {
|
|
69
|
-
serif:
|
|
66
|
+
serif: [
|
|
67
|
+
{
|
|
68
|
+
name: 'Noto Serif SC',
|
|
69
|
+
weights: [900],
|
|
70
|
+
},
|
|
71
|
+
],
|
|
70
72
|
// sans: 'DM Sans',
|
|
71
73
|
// mono: 'DM Mono',
|
|
72
74
|
},
|
|
@@ -75,19 +77,19 @@ export const createUnocssConfig = (options: ResolvedValaxyOptions) => {
|
|
|
75
77
|
rules: [
|
|
76
78
|
// more see '~/styles/global/helper.scss'
|
|
77
79
|
['yun-transition', {
|
|
78
|
-
'transition-duration': 'var(--
|
|
80
|
+
'transition-duration': 'var(--va-transition-duration)',
|
|
79
81
|
}],
|
|
80
82
|
['yun-text-light', {
|
|
81
|
-
color: 'var(--
|
|
83
|
+
color: 'var(--va-c-text-light)',
|
|
82
84
|
}],
|
|
83
85
|
['font-serif', {
|
|
84
|
-
'font-family': 'var(--
|
|
86
|
+
'font-family': 'var(--va-font-serif)',
|
|
85
87
|
}],
|
|
86
88
|
['font-sans', {
|
|
87
|
-
'font-family': 'var(--
|
|
89
|
+
'font-family': 'var(--va-font-sans)',
|
|
88
90
|
}],
|
|
89
91
|
['font-mono', {
|
|
90
|
-
'font-family': 'var(--
|
|
92
|
+
'font-family': 'var(--va-font-mono)',
|
|
91
93
|
}],
|
|
92
94
|
],
|
|
93
95
|
transformers: [
|
package/src/node/rss.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { dirname } from 'path'
|
|
2
|
+
import chalk from 'chalk'
|
|
3
|
+
|
|
4
|
+
import fg from 'fast-glob'
|
|
5
|
+
import fs from 'fs-extra'
|
|
6
|
+
import matter from 'gray-matter'
|
|
7
|
+
import MarkdownIt from 'markdown-it'
|
|
8
|
+
import type { Author, FeedOptions, Item } from 'feed'
|
|
9
|
+
import { Feed } from 'feed'
|
|
10
|
+
import consola from 'consola'
|
|
11
|
+
import type { ResolvedValaxyOptions } from './options'
|
|
12
|
+
|
|
13
|
+
const markdown = MarkdownIt({
|
|
14
|
+
html: true,
|
|
15
|
+
breaks: true,
|
|
16
|
+
linkify: true,
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* generate rss
|
|
21
|
+
* @param options
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
export async function build(options: ResolvedValaxyOptions) {
|
|
25
|
+
const { config } = options
|
|
26
|
+
|
|
27
|
+
if (!config.url) {
|
|
28
|
+
consola.error('You must set "config.url" to generate rss.')
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const siteUrl = config.url.endsWith('/') ? config.url : `${config.url}/`
|
|
33
|
+
const DOMAIN = config.url.endsWith('/') ? config.url.slice(0, -1) : config.url
|
|
34
|
+
const author: Author = {
|
|
35
|
+
name: options.config.author.name,
|
|
36
|
+
email: options.config.author.email,
|
|
37
|
+
link: options.config.author.link,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
consola.info(`RSS Site Url: ${chalk.cyan(siteUrl)}`)
|
|
41
|
+
|
|
42
|
+
const ccVersion = (config.license.type === 'zero') ? '1.0' : '4.0'
|
|
43
|
+
const feedOptions: FeedOptions = {
|
|
44
|
+
title: config.title,
|
|
45
|
+
description: config.description,
|
|
46
|
+
id: siteUrl || 'valaxy',
|
|
47
|
+
link: siteUrl,
|
|
48
|
+
copyright: `CC ${config.license.type.toUpperCase()} ${ccVersion} ${new Date().getFullYear()} © ${config.author.name}`,
|
|
49
|
+
feedLinks: {
|
|
50
|
+
json: `${siteUrl}feed.json`,
|
|
51
|
+
atom: `${siteUrl}feed.atom`,
|
|
52
|
+
rss: `${siteUrl}feed.xml`,
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// generate
|
|
57
|
+
const files = await fg(`${options.userRoot}/pages/posts/**/*.md`)
|
|
58
|
+
|
|
59
|
+
const posts: Item[] = []
|
|
60
|
+
files
|
|
61
|
+
.forEach((i) => {
|
|
62
|
+
const raw = fs.readFileSync(i, 'utf-8')
|
|
63
|
+
const { data, content, excerpt } = matter(raw)
|
|
64
|
+
|
|
65
|
+
// not add to posts
|
|
66
|
+
if (!data.date) {
|
|
67
|
+
consola.warn(`Do you forget to write date for ${chalk.dim(i)}`)
|
|
68
|
+
return false
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (data.draft) {
|
|
72
|
+
consola.warn(`Ignore draft post: ${chalk.dim(i)}`)
|
|
73
|
+
return false
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// todo i18n
|
|
77
|
+
|
|
78
|
+
// render excerpt
|
|
79
|
+
const html = markdown.render(excerpt || content)
|
|
80
|
+
.replace('src="/', `src="${DOMAIN}/`)
|
|
81
|
+
|
|
82
|
+
if (data.image?.startsWith('/'))
|
|
83
|
+
data.image = DOMAIN + data.image
|
|
84
|
+
|
|
85
|
+
posts.push({
|
|
86
|
+
title: '',
|
|
87
|
+
...data,
|
|
88
|
+
id: (data.id || '').toString(),
|
|
89
|
+
date: new Date(data.date),
|
|
90
|
+
published: new Date(data.updated || data.date),
|
|
91
|
+
content: html,
|
|
92
|
+
author: [author],
|
|
93
|
+
link: DOMAIN + i.replace(`${options.userRoot}/pages`, '').replace(/\.md$/, ''),
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
// sort by updated
|
|
98
|
+
posts.sort((a, b) => +new Date(b.published || b.date) - +new Date(a.published || a.date))
|
|
99
|
+
// await writeFeed('feed', feedOptions, posts)
|
|
100
|
+
|
|
101
|
+
// write
|
|
102
|
+
feedOptions.author = author
|
|
103
|
+
feedOptions.image = config.author.avatar.startsWith('http') ? config.author.avatar : `${DOMAIN}${config.author.avatar}`
|
|
104
|
+
feedOptions.favicon = `${DOMAIN}/${config.feed.favicon}`
|
|
105
|
+
|
|
106
|
+
const feed = new Feed(feedOptions)
|
|
107
|
+
posts.forEach(item => feed.addItem(item))
|
|
108
|
+
// items.forEach(i=> console.log(i.title, i.date))
|
|
109
|
+
|
|
110
|
+
await fs.ensureDir(dirname(`./dist/${config.feed.name}`))
|
|
111
|
+
const path = './dist'
|
|
112
|
+
|
|
113
|
+
const types = ['xml', 'atom', 'json']
|
|
114
|
+
types.forEach((type) => {
|
|
115
|
+
let data = ''
|
|
116
|
+
let name = `${path}/${config.feed.name || 'feed'}.${type}`
|
|
117
|
+
if (type === 'xml') { data = feed.rss2() }
|
|
118
|
+
else if (type === 'atom') {
|
|
119
|
+
if (!config.feed.name)
|
|
120
|
+
name = `${path}/atom.xml`
|
|
121
|
+
data = feed.atom1()
|
|
122
|
+
}
|
|
123
|
+
else if (type === 'json') { data = feed.json1() }
|
|
124
|
+
fs.writeFileSync(name, data, 'utf-8')
|
|
125
|
+
consola.info(`${type}: ${name}`)
|
|
126
|
+
})
|
|
127
|
+
}
|
package/src/node/server.ts
CHANGED
package/src/node/shims.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
declare module 'escape-html' {
|
|
2
|
+
const def: (str: string) => string
|
|
3
|
+
export default def
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare module 'prismjs' {
|
|
7
|
+
const def: any
|
|
8
|
+
export default def
|
|
9
|
+
}
|
|
10
|
+
|
|
1
11
|
declare module 'markdown-it-attrs' {
|
|
2
12
|
const def: any
|
|
3
13
|
export default def
|
|
@@ -18,6 +28,11 @@ declare module 'markdown-it-container' {
|
|
|
18
28
|
export default def
|
|
19
29
|
}
|
|
20
30
|
|
|
31
|
+
declare module 'markdown-it-task-lists' {
|
|
32
|
+
const def: any
|
|
33
|
+
export default def
|
|
34
|
+
}
|
|
35
|
+
|
|
21
36
|
declare module 'diacritics' {
|
|
22
37
|
export const remove: (str: string) => string
|
|
23
38
|
}
|
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,11 +20,14 @@ 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: {
|
|
@@ -37,16 +39,6 @@ export function createViteConfig(options: ResolvedValaxyOptions, serverOptions:
|
|
|
37
39
|
],
|
|
38
40
|
},
|
|
39
41
|
},
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (mode === 'build') {
|
|
44
|
-
// https://github.com/antfu/vite-ssg
|
|
45
|
-
viteConfig.ssgOptions = {
|
|
46
|
-
script: 'async',
|
|
47
|
-
formatting: 'minify',
|
|
48
|
-
onFinished() { generateSitemap() },
|
|
49
|
-
}
|
|
50
42
|
}
|
|
51
43
|
|
|
52
44
|
return viteConfig
|
package/src/types/config.ts
CHANGED
|
@@ -27,8 +27,8 @@ export interface ValaxyConfig<T = ValaxyThemeConfig> {
|
|
|
27
27
|
*/
|
|
28
28
|
lang: string
|
|
29
29
|
/**
|
|
30
|
-
* You site url in web, required for ssg
|
|
31
|
-
* @description 站点的 URL,SSG
|
|
30
|
+
* You site url in web, required for ssg & rss
|
|
31
|
+
* @description 站点的 URL,SSG & RSS 需要(譬如生成版权处文章永久链接)
|
|
32
32
|
*/
|
|
33
33
|
url: string
|
|
34
34
|
/**
|
|
@@ -54,6 +54,8 @@ export interface ValaxyConfig<T = ValaxyThemeConfig> {
|
|
|
54
54
|
* @description 你的名字
|
|
55
55
|
*/
|
|
56
56
|
name: string
|
|
57
|
+
email: string
|
|
58
|
+
link: string
|
|
57
59
|
avatar: string
|
|
58
60
|
/**
|
|
59
61
|
* The status of you
|
|
@@ -69,6 +71,15 @@ export interface ValaxyConfig<T = ValaxyThemeConfig> {
|
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
|
|
74
|
+
feed: {
|
|
75
|
+
/**
|
|
76
|
+
* name: feed -> feed.xml / feed.atom / feed.json
|
|
77
|
+
* @default '' -> feed.xml / atom.xml / feed.json
|
|
78
|
+
*/
|
|
79
|
+
name: string
|
|
80
|
+
favicon: string
|
|
81
|
+
}
|
|
82
|
+
|
|
72
83
|
/**
|
|
73
84
|
* 社交链接
|
|
74
85
|
*/
|
|
@@ -95,6 +106,10 @@ export interface ValaxyConfig<T = ValaxyThemeConfig> {
|
|
|
95
106
|
enable: boolean
|
|
96
107
|
serverURL: string
|
|
97
108
|
}
|
|
109
|
+
twikoo: {
|
|
110
|
+
enable: boolean
|
|
111
|
+
envId: string
|
|
112
|
+
}
|
|
98
113
|
}
|
|
99
114
|
|
|
100
115
|
/**
|
|
@@ -175,12 +190,18 @@ export const defaultValaxyConfig: ValaxyConfig = {
|
|
|
175
190
|
subtitle: 'Next Generation Static Blog Framework.',
|
|
176
191
|
author: {
|
|
177
192
|
avatar: 'https://cdn.jsdelivr.net/gh/YunYouJun/yun/images/meme/yun-good-with-bg.jpg',
|
|
193
|
+
email: 'me@yunyoujun.cn',
|
|
194
|
+
link: 'https://www.yunyoujun.cn',
|
|
178
195
|
name: 'YunYouJun',
|
|
179
196
|
status: {
|
|
180
197
|
emoji: '😊',
|
|
181
198
|
message: 'All at sea.',
|
|
182
199
|
},
|
|
183
200
|
},
|
|
201
|
+
feed: {
|
|
202
|
+
name: '',
|
|
203
|
+
favicon: 'favicon.png',
|
|
204
|
+
},
|
|
184
205
|
social: [],
|
|
185
206
|
description: 'A blog generated by Valaxy.',
|
|
186
207
|
|
|
@@ -231,6 +252,10 @@ export const defaultValaxyConfig: ValaxyConfig = {
|
|
|
231
252
|
enable: false,
|
|
232
253
|
serverURL: '',
|
|
233
254
|
},
|
|
255
|
+
twikoo: {
|
|
256
|
+
enable: false,
|
|
257
|
+
envId: 'https://twikoo.vercel.app',
|
|
258
|
+
},
|
|
234
259
|
},
|
|
235
260
|
|
|
236
261
|
theme: 'yun',
|
|
@@ -243,6 +268,7 @@ export const defaultValaxyConfig: ValaxyConfig = {
|
|
|
243
268
|
},
|
|
244
269
|
markdownIt: {
|
|
245
270
|
toc: {
|
|
271
|
+
includeLevel: [1, 2, 3, 4],
|
|
246
272
|
listType: 'ol',
|
|
247
273
|
},
|
|
248
274
|
katex: {},
|
package/src/types/posts.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface Post {
|
|
1
|
+
export interface Post extends Record<string, any> {
|
|
2
2
|
/**
|
|
3
3
|
* Path of post
|
|
4
4
|
* route.path
|
|
@@ -104,4 +104,9 @@ export interface Post {
|
|
|
104
104
|
* @description 是否显示目录
|
|
105
105
|
*/
|
|
106
106
|
toc?: boolean
|
|
107
|
+
/**
|
|
108
|
+
* is draft
|
|
109
|
+
* @description 是否为草稿
|
|
110
|
+
*/
|
|
111
|
+
draft?: boolean
|
|
107
112
|
}
|
package/tsup.config.ts
CHANGED
|
@@ -5,6 +5,7 @@ export default defineConfig((options) => {
|
|
|
5
5
|
entry: [
|
|
6
6
|
'src/node/index.ts',
|
|
7
7
|
'src/node/cli.ts',
|
|
8
|
+
'src/index.ts',
|
|
8
9
|
],
|
|
9
10
|
// https://tsup.egoist.sh/#code-splitting
|
|
10
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.
|
package/dist/build-VGAF4K5S.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkWYCH73X6js = require('./chunk-WYCH73X6.js');_chunkWYCH73X6js.d.call(void 0, );var _vite = require('vite');async function a(n,e={}){let t=_vite.mergeConfig.call(void 0, e,_chunkWYCH73X6js.j.call(void 0, n));await _vite.build.call(void 0, t)}exports.build = a;
|
package/dist/build-Y5F7AZ2V.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as i,j as o}from"./chunk-ESCOXVP6.mjs";i();import{mergeConfig as r,build as f}from"vite";async function a(n,e={}){let t=r(e,o(n));await f(t)}export{a as build};
|
package/dist/chunk-5KQ3UFYI.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkWYCH73X6js = require('./chunk-WYCH73X6.js');_chunkWYCH73X6js.d.call(void 0, );var _vite = require('vite');async function c(o,t={},i={}){return process.env.EDITOR=process.env.EDITOR||"code",await _vite.createServer.call(void 0, _vite.mergeConfig.call(void 0, t,_chunkWYCH73X6js.j.call(void 0, o,i)))}exports.a = c;
|