valaxy 0.0.6 → 0.0.9
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/config-d6527c8c.d.ts +174 -0
- package/dist/index.d.ts +305 -152
- 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 +88 -0
- package/dist/node/cli.mjs +88 -0
- package/dist/node/index.d.ts +45 -0
- package/dist/node/index.js +83 -0
- package/dist/node/index.mjs +83 -0
- package/package.json +9 -5
- package/src/client/components/ValaxyCopyright.vue +1 -1
- package/src/client/composables/category.ts +2 -2
- package/src/client/composables/common.ts +3 -2
- package/src/client/composables/post.ts +2 -2
- package/src/client/composables/tag.ts +2 -1
- package/src/{core → client}/config.ts +1 -1
- package/src/client/index.ts +4 -0
- package/src/client/modules/valaxy.ts +1 -1
- package/src/client/utils/index.ts +2 -0
- package/src/client/utils/time.ts +7 -1
- package/src/index.ts +1 -1
- package/src/node/plugins/extendConfig.ts +45 -0
- package/src/node/plugins/preset.ts +12 -1
- package/src/node/vite.ts +1 -32
- package/tsup.config.ts +9 -5
- package/dist/build-ONY2EY5P.js +0 -1
- package/dist/build-WOTUPDVZ.mjs +0 -1
- package/dist/chunk-KVMOYEI7.mjs +0 -78
- package/dist/chunk-L2JFIGW6.js +0 -1
- package/dist/chunk-LYQNUAIB.mjs +0 -1
- package/dist/chunk-Y7N6QN4A.js +0 -78
- package/dist/cli.js +0 -6
- package/dist/cli.mjs +0 -6
- package/src/core/index.ts +0 -5
- package/src/core/utils.ts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valaxy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "📄 Vite & Vue powered static blog generator.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,6 +9,14 @@
|
|
|
9
9
|
"vue",
|
|
10
10
|
"blog"
|
|
11
11
|
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./src/index.ts",
|
|
14
|
+
"./*": "./*"
|
|
15
|
+
},
|
|
16
|
+
"bin": {
|
|
17
|
+
"vala": "./bin/valaxy.js",
|
|
18
|
+
"valaxy": "./bin/valaxy.js"
|
|
19
|
+
},
|
|
12
20
|
"author": {
|
|
13
21
|
"email": "me@yunyoujun.cn",
|
|
14
22
|
"name": "YunYouJun",
|
|
@@ -17,10 +25,6 @@
|
|
|
17
25
|
"license": "MIT",
|
|
18
26
|
"homepage": "https://valaxy.yyj.moe",
|
|
19
27
|
"repository": "https://github.com/YunYouJun/valaxy",
|
|
20
|
-
"bin": {
|
|
21
|
-
"vala": "./bin/valaxy.js",
|
|
22
|
-
"valaxy": "./bin/valaxy.js"
|
|
23
|
-
},
|
|
24
28
|
"devDependencies": {
|
|
25
29
|
"@types/katex": "^0.14.0",
|
|
26
30
|
"@types/markdown-it-link-attributes": "^3.0.1",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Post } from '
|
|
1
|
+
import type { Post } from '../../types'
|
|
2
2
|
import { usePostList } from './post'
|
|
3
3
|
|
|
4
4
|
export interface ParentCategory {
|
|
@@ -32,7 +32,7 @@ export function useCategory() {
|
|
|
32
32
|
|
|
33
33
|
const uncategorized = categoryMap.children.get('Uncategorized') as PostCategory
|
|
34
34
|
|
|
35
|
-
posts.value.forEach((post) => {
|
|
35
|
+
posts.value.forEach((post: Post) => {
|
|
36
36
|
if (post.categories) {
|
|
37
37
|
if (Array.isArray(post.categories)) {
|
|
38
38
|
const len = post.categories.length
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { useRoute } from 'vue-router'
|
|
2
|
-
import type { Post } from 'valaxy'
|
|
3
2
|
import { computed } from 'vue'
|
|
4
3
|
|
|
5
|
-
import { isDev
|
|
4
|
+
import { isDev } from '../..'
|
|
5
|
+
import type { Post } from '../../types'
|
|
6
|
+
import { useConfig } from '../config'
|
|
6
7
|
|
|
7
8
|
export function useFrontmatter() {
|
|
8
9
|
const route = useRoute()
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { sortByDate } from 'valaxy'
|
|
2
1
|
import type { StyleValue } from 'vue'
|
|
3
2
|
import { computed } from 'vue'
|
|
4
3
|
import { useRoute, useRouter } from 'vue-router'
|
|
5
|
-
import { useThemeConfig } from '
|
|
4
|
+
import { useThemeConfig } from '../config'
|
|
5
|
+
import { sortByDate } from '../utils'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* get post list
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TinyColor } from '@ctrl/tinycolor'
|
|
2
|
+
import type { Post } from '../../types'
|
|
2
3
|
import { usePostList } from './post'
|
|
3
4
|
|
|
4
5
|
export type Tags = Map<string, {
|
|
@@ -41,7 +42,7 @@ export function useTag() {
|
|
|
41
42
|
|
|
42
43
|
const tagMap: Tags = new Map()
|
|
43
44
|
|
|
44
|
-
posts.value.forEach((post) => {
|
|
45
|
+
posts.value.forEach((post: Post) => {
|
|
45
46
|
if (post.tags) {
|
|
46
47
|
let tags: string[]
|
|
47
48
|
if (typeof post.tags === 'string')
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import valaxyConfig from '@valaxyjs/config'
|
|
3
3
|
import type { ComputedRef, InjectionKey } from 'vue'
|
|
4
4
|
import { computed, inject, readonly, shallowRef } from 'vue'
|
|
5
|
-
import type { ThemeConfig } from 'valaxy-theme-yun'
|
|
5
|
+
import type { ThemeConfig } from '../../../valaxy-theme-yun'
|
|
6
6
|
import type { ValaxyConfig } from '../types'
|
|
7
7
|
|
|
8
8
|
/**
|
package/src/client/utils/time.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import dayjs from 'dayjs'
|
|
2
|
-
import type { Post } from '
|
|
2
|
+
import type { Post } from '../../types'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* use dayjs format date
|
|
6
|
+
* @param date
|
|
7
|
+
* @param template
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
4
10
|
export function formatDate(date: string | number | Date, template = 'YYYY-MM-DD') {
|
|
5
11
|
const today = dayjs(date)
|
|
6
12
|
return today.format(template)
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './client'
|
|
2
2
|
export * from './types'
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { resolve } from 'path'
|
|
2
|
+
import type { InlineConfig, Plugin } from 'vite'
|
|
3
|
+
import { mergeConfig } from 'vite'
|
|
4
|
+
import type { ResolvedValaxyOptions } from '../options'
|
|
5
|
+
import { toAtFS } from '../utils'
|
|
6
|
+
|
|
7
|
+
export function createConfigPlugin(options: ResolvedValaxyOptions): Plugin {
|
|
8
|
+
return {
|
|
9
|
+
name: 'valaxy:config',
|
|
10
|
+
config(config) {
|
|
11
|
+
const injection: InlineConfig = {
|
|
12
|
+
resolve: {
|
|
13
|
+
alias: {
|
|
14
|
+
'@/': `${toAtFS(options.userRoot)}/`,
|
|
15
|
+
'~/': `${toAtFS(options.clientRoot)}/`,
|
|
16
|
+
'@valaxyjs/client': `${toAtFS(options.clientRoot)}/`,
|
|
17
|
+
'@valaxyjs/config': '/@valaxyjs/config',
|
|
18
|
+
'valaxy/package.json': toAtFS(resolve(options.clientRoot, '../../package.json')),
|
|
19
|
+
'valaxy/': `${toAtFS(resolve(options.clientRoot, '../..'))}/`,
|
|
20
|
+
'valaxy': toAtFS(resolve(options.clientRoot, '../index.ts')),
|
|
21
|
+
[`valaxy-theme-${options.theme}/`]: `${toAtFS(resolve(options.themeRoot))}/`,
|
|
22
|
+
[`valaxy-theme-${options.theme}`]: `${toAtFS(resolve(options.themeRoot))}`,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
optimizeDeps: {
|
|
27
|
+
entries: [resolve(options.clientRoot, 'main.ts'), options.configFile],
|
|
28
|
+
|
|
29
|
+
include: [
|
|
30
|
+
'vue',
|
|
31
|
+
'vue-router',
|
|
32
|
+
'@vueuse/core',
|
|
33
|
+
'@vueuse/head',
|
|
34
|
+
'dayjs',
|
|
35
|
+
'nprogress',
|
|
36
|
+
],
|
|
37
|
+
exclude: [
|
|
38
|
+
'vue-demi',
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
return mergeConfig(config, injection)
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -21,11 +21,17 @@ import type { Mode } from '../vite'
|
|
|
21
21
|
import { setupMarkdownPlugins } from '../markdown'
|
|
22
22
|
import { createMarkdownPlugin, excerpt_separator } from './markdown'
|
|
23
23
|
import { createUnocssPlugin } from './unocss'
|
|
24
|
+
import { createConfigPlugin } from './extendConfig'
|
|
24
25
|
import { createValaxyPlugin } from '.'
|
|
25
26
|
|
|
27
|
+
export interface ValaxyPluginOptions {
|
|
28
|
+
components?: Parameters<typeof Components>[0]
|
|
29
|
+
}
|
|
30
|
+
|
|
26
31
|
export function ViteValaxyPlugins(
|
|
27
32
|
options: ResolvedValaxyOptions,
|
|
28
33
|
serverOptions: ValaxyServerOptions = {},
|
|
34
|
+
pluginOptions: ValaxyPluginOptions = {},
|
|
29
35
|
mode: Mode = 'dev',
|
|
30
36
|
): (PluginOption | PluginOption[])[] | undefined {
|
|
31
37
|
const { clientRoot, themeRoot, userRoot } = options
|
|
@@ -39,6 +45,7 @@ export function ViteValaxyPlugins(
|
|
|
39
45
|
const _md = setupMarkdownPlugins(mdIt, options.config.markdownIt)
|
|
40
46
|
|
|
41
47
|
const roots = [clientRoot, themeRoot, userRoot]
|
|
48
|
+
|
|
42
49
|
return [
|
|
43
50
|
Vue({
|
|
44
51
|
include: [/\.vue$/, /\.md$/],
|
|
@@ -53,6 +60,7 @@ export function ViteValaxyPlugins(
|
|
|
53
60
|
|
|
54
61
|
ValaxyPlugin,
|
|
55
62
|
MarkdownPlugin,
|
|
63
|
+
createConfigPlugin(options),
|
|
56
64
|
|
|
57
65
|
// https://github.com/hannoeru/vite-plugin-pages
|
|
58
66
|
Pages({
|
|
@@ -121,7 +129,10 @@ export function ViteValaxyPlugins(
|
|
|
121
129
|
allowOverrides: true,
|
|
122
130
|
// override: user -> theme -> client
|
|
123
131
|
// latter override former
|
|
124
|
-
dirs: roots.map(root => `${root}/components`),
|
|
132
|
+
dirs: roots.map(root => `${root}/components`).concat(['src/components', 'components']),
|
|
133
|
+
dts: `${options.userRoot}/components.d.ts`,
|
|
134
|
+
|
|
135
|
+
...pluginOptions,
|
|
125
136
|
}),
|
|
126
137
|
|
|
127
138
|
// https://github.com/antfu/unocss
|
package/src/node/vite.ts
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
|
|
3
1
|
import generateSitemap from 'vite-ssg-sitemap'
|
|
4
2
|
import type { InlineConfig } from 'vite'
|
|
5
3
|
import { searchForWorkspaceRoot } from 'vite'
|
|
6
4
|
import type { ResolvedValaxyOptions, ValaxyServerOptions } from './options'
|
|
7
5
|
|
|
8
6
|
import { ViteValaxyPlugins } from './plugins/preset'
|
|
9
|
-
import { VALAXY_CONFIG_ID } from './plugins/valaxy'
|
|
10
7
|
|
|
11
8
|
export type Mode = 'dev' | 'build'
|
|
12
9
|
|
|
13
10
|
export function createViteConfig(options: ResolvedValaxyOptions, serverOptions: ValaxyServerOptions = {}, mode: Mode = 'dev'): InlineConfig {
|
|
14
|
-
const { configFile } = options
|
|
15
|
-
|
|
16
11
|
const viteConfig: InlineConfig = {
|
|
17
12
|
// remove vue-i18n warnings
|
|
18
13
|
// https://vue-i18n.intlify.dev/guide/advanced/optimization.html#reduce-bundle-size-with-feature-build-flags
|
|
@@ -26,24 +21,11 @@ export function createViteConfig(options: ResolvedValaxyOptions, serverOptions:
|
|
|
26
21
|
// __VUE_I18N_LEGACY_API__: 'false',
|
|
27
22
|
// },
|
|
28
23
|
|
|
29
|
-
resolve: {
|
|
30
|
-
alias: {
|
|
31
|
-
'@/': `${options.userRoot}/`,
|
|
32
|
-
'~/': `${options.clientRoot}/`,
|
|
33
|
-
'@valaxyjs/client': `${options.clientRoot}/`,
|
|
34
|
-
'valaxy/package.json': `${path.resolve(options.clientRoot, '../../package.json')}`,
|
|
35
|
-
'valaxy': `${path.resolve(options.clientRoot, '..')}`,
|
|
36
|
-
[VALAXY_CONFIG_ID]: `/${VALAXY_CONFIG_ID}`,
|
|
37
|
-
'@valaxyjs/core': `${path.resolve(options.clientRoot, '../core')}`,
|
|
38
|
-
[`valaxy-theme-${options.theme}`]: `${path.resolve(options.themeRoot)}/`,
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
|
|
42
24
|
root: options.clientRoot,
|
|
43
25
|
// todo user base
|
|
44
26
|
// base: '/',
|
|
45
27
|
|
|
46
|
-
plugins: ViteValaxyPlugins(options, serverOptions, mode),
|
|
28
|
+
plugins: ViteValaxyPlugins(options, serverOptions, {}, mode),
|
|
47
29
|
|
|
48
30
|
server: {
|
|
49
31
|
fs: {
|
|
@@ -55,19 +37,6 @@ export function createViteConfig(options: ResolvedValaxyOptions, serverOptions:
|
|
|
55
37
|
},
|
|
56
38
|
},
|
|
57
39
|
|
|
58
|
-
optimizeDeps: {
|
|
59
|
-
entries: [path.resolve(options.clientRoot, 'main.ts'), configFile],
|
|
60
|
-
|
|
61
|
-
include: [
|
|
62
|
-
'vue',
|
|
63
|
-
'vue-router',
|
|
64
|
-
'@vueuse/core',
|
|
65
|
-
'@vueuse/head',
|
|
66
|
-
],
|
|
67
|
-
exclude: [
|
|
68
|
-
'vue-demi',
|
|
69
|
-
],
|
|
70
|
-
},
|
|
71
40
|
}
|
|
72
41
|
|
|
73
42
|
if (mode === 'build') {
|
package/tsup.config.ts
CHANGED
|
@@ -2,16 +2,20 @@ import { defineConfig } from 'tsup'
|
|
|
2
2
|
|
|
3
3
|
export default defineConfig((options) => {
|
|
4
4
|
return {
|
|
5
|
-
entry: [
|
|
6
|
-
|
|
5
|
+
entry: [
|
|
6
|
+
'src/node/index.ts',
|
|
7
|
+
'src/node/cli.ts',
|
|
8
|
+
'src/index.ts',
|
|
9
|
+
],
|
|
10
|
+
// splitting: true,
|
|
11
|
+
splitting: false,
|
|
7
12
|
clean: true,
|
|
8
13
|
dts: true,
|
|
9
14
|
format: ['cjs', 'esm'],
|
|
10
15
|
minify: !options.watch,
|
|
11
16
|
external: [
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'chalk',
|
|
17
|
+
'@valaxyjs/config',
|
|
18
|
+
'valaxy-theme-yun',
|
|
15
19
|
],
|
|
16
20
|
}
|
|
17
21
|
})
|
package/dist/build-ONY2EY5P.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkY7N6QN4Ajs = require('./chunk-Y7N6QN4A.js');_chunkY7N6QN4Ajs.d.call(void 0, );var _vite = require('vite');async function a(n,e={}){let t=_vite.mergeConfig.call(void 0, e,_chunkY7N6QN4Ajs.h.call(void 0, n));await _vite.build.call(void 0, t)}exports.build = a;
|
package/dist/build-WOTUPDVZ.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as i,h as o}from"./chunk-KVMOYEI7.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};
|