valaxy 0.3.1 → 0.3.4
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 +4 -0
- package/dist/chunk-32YG63VM.js +83 -0
- package/dist/chunk-QIXBXHEK.js +1 -0
- package/dist/chunk-REH4P5X4.mjs +83 -0
- package/dist/chunk-T3K5KZOK.mjs +1 -0
- package/dist/{config-408070e9.d.ts → config-97204b79.d.ts} +4 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/node/cli.js +10 -10
- package/dist/node/cli.mjs +10 -10
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.mjs +1 -1
- package/package.json +37 -36
- package/src/client/components/ValaxyToc.vue +50 -4
- package/src/client/locales/en.yml +9 -9
- package/src/client/locales/zh-CN.yml +9 -9
- package/src/client/pages/index.vue +5 -0
- package/src/client/styles/palette.scss +1 -1
- package/src/node/cli.ts +2 -1
- package/src/node/markdown/check.ts +14 -0
- package/src/node/markdown/index.ts +12 -7
- package/src/node/markdown/{markdown-it-container.ts → markdown-it/container.ts} +0 -0
- package/src/node/markdown/{headings.ts → markdown-it/headings.ts} +4 -3
- package/src/node/markdown/{highlightLines.ts → markdown-it/highlightLines.ts} +0 -0
- package/src/node/markdown/{markdown-it-katex.ts → markdown-it/katex.ts} +0 -0
- package/src/node/markdown/{parseHeader.ts → markdown-it/parseHeader.ts} +0 -0
- package/src/node/plugins/extendConfig.ts +0 -8
- package/src/node/plugins/markdown.ts +17 -20
- package/src/node/plugins/preset.ts +7 -14
- package/src/node/plugins/unocss.ts +1 -0
- package/src/node/rss.ts +4 -4
- package/src/node/utils/cli.ts +8 -8
- package/src/node/vite.ts +1 -2
- package/tsup.config.ts +1 -1
- package/dist/chunk-F4NM2FOU.mjs +0 -88
- package/dist/chunk-PQWGL22E.js +0 -88
- package/dist/chunk-R2IXLA5A.mjs +0 -1
- package/dist/chunk-WNLPZSAR.js +0 -1
package/dist/node/index.d.ts
CHANGED
package/dist/node/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk32YG63VMjs = require('../chunk-32YG63VM.js');var _chunkQIXBXHEKjs = require('../chunk-QIXBXHEK.js');_chunkQIXBXHEKjs.i.call(void 0, );exports.createServer = _chunk32YG63VMjs.g;
|
package/dist/node/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{g as r}from"../chunk-REH4P5X4.mjs";import{i as o}from"../chunk-T3K5KZOK.mjs";o();export{r as createServer};
|
package/package.json
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valaxy",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "📄 Vite & Vue powered static blog generator.",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
5
|
"keywords": [
|
|
8
6
|
"vite",
|
|
9
7
|
"vue",
|
|
10
8
|
"blog"
|
|
11
9
|
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"author": {
|
|
12
|
+
"email": "me@yunyoujun.cn",
|
|
13
|
+
"name": "YunYouJun",
|
|
14
|
+
"url": "https://www.yunyoujun.cn"
|
|
15
|
+
},
|
|
16
|
+
"repository": "https://github.com/YunYouJun/valaxy",
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"types": "dist/index.d.ts",
|
|
12
19
|
"exports": {
|
|
13
20
|
".": "./src/index.ts",
|
|
14
21
|
"./*": "./*"
|
|
@@ -17,44 +24,25 @@
|
|
|
17
24
|
"vala": "./bin/valaxy.js",
|
|
18
25
|
"valaxy": "./bin/valaxy.js"
|
|
19
26
|
},
|
|
20
|
-
"author": {
|
|
21
|
-
"email": "me@yunyoujun.cn",
|
|
22
|
-
"name": "YunYouJun",
|
|
23
|
-
"url": "https://www.yunyoujun.cn"
|
|
24
|
-
},
|
|
25
|
-
"license": "MIT",
|
|
26
27
|
"homepage": "https://valaxy.yyj.moe",
|
|
27
|
-
"repository": "https://github.com/YunYouJun/valaxy",
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"@types/katex": "^0.14.0",
|
|
30
|
-
"@types/markdown-it-link-attributes": "^3.0.1",
|
|
31
|
-
"@types/nprogress": "^0.2.0",
|
|
32
|
-
"@types/yargs": "^17.0.10",
|
|
33
|
-
"chalk": "4",
|
|
34
|
-
"cross-env": "^7.0.3",
|
|
35
|
-
"debug": "^4.3.4",
|
|
36
|
-
"diacritics": "^1.3.0",
|
|
37
|
-
"https-localhost": "^4.7.1",
|
|
38
|
-
"markdown-it-attrs": "^4.1.3",
|
|
39
|
-
"type-fest": "^2.12.2",
|
|
40
|
-
"vue-tsc": "^0.34.11"
|
|
41
|
-
},
|
|
42
28
|
"dependencies": {
|
|
43
29
|
"@ctrl/tinycolor": "^3.4.1",
|
|
44
30
|
"@iconify-json/carbon": "^1.1.4",
|
|
45
31
|
"@iconify-json/ri": "^1.1.1",
|
|
46
32
|
"@intlify/vite-plugin-vue-i18n": "^3.4.0",
|
|
47
|
-
"@vitejs/plugin-vue": "^2.3.
|
|
48
|
-
"@vueuse/core": "^8.4.
|
|
33
|
+
"@vitejs/plugin-vue": "^2.3.3",
|
|
34
|
+
"@vueuse/core": "^8.4.2",
|
|
49
35
|
"@vueuse/head": "^0.7.6",
|
|
50
36
|
"consola": "^2.15.3",
|
|
51
37
|
"critters": "^0.0.16",
|
|
52
|
-
"dayjs": "^1.11.
|
|
38
|
+
"dayjs": "^1.11.2",
|
|
53
39
|
"escape-html": "^1.0.3",
|
|
54
40
|
"fast-deep-equal": "^3.1.3",
|
|
55
41
|
"feed": "^4.2.2",
|
|
56
42
|
"katex": "^0.15.3",
|
|
57
|
-
"
|
|
43
|
+
"kolorist": "^1.5.1",
|
|
44
|
+
"markdown-it-anchor": "^8.6.4",
|
|
45
|
+
"markdown-it-attrs": "^4.1.4",
|
|
58
46
|
"markdown-it-container": "^3.0.0",
|
|
59
47
|
"markdown-it-emoji": "^2.0.2",
|
|
60
48
|
"markdown-it-link-attributes": "^4.0.0",
|
|
@@ -68,24 +56,37 @@
|
|
|
68
56
|
"sass": "^1.51.0",
|
|
69
57
|
"star-markdown-css": "^0.3.3",
|
|
70
58
|
"unconfig": "^0.3.4",
|
|
71
|
-
"unocss": "^0.
|
|
72
|
-
"unplugin-vue-components": "^0.19.
|
|
73
|
-
"vite": "^2.9.
|
|
59
|
+
"unocss": "^0.33.4",
|
|
60
|
+
"unplugin-vue-components": "^0.19.5",
|
|
61
|
+
"vite": "^2.9.9",
|
|
74
62
|
"vite-plugin-inspect": "^0.5.0",
|
|
75
|
-
"vite-plugin-md": "^0.13.
|
|
63
|
+
"vite-plugin-md": "^0.13.1",
|
|
76
64
|
"vite-plugin-pages": "^0.23.0",
|
|
77
65
|
"vite-plugin-pwa": "^0.12.0",
|
|
78
66
|
"vite-plugin-vue-layouts": "^0.6.0",
|
|
79
|
-
"vite-ssg": "
|
|
67
|
+
"vite-ssg": "0.19.2",
|
|
80
68
|
"vite-ssg-sitemap": "0.2.6",
|
|
81
69
|
"vue": "^3.2.33",
|
|
82
|
-
"vue-demi": "^0.12.5",
|
|
83
70
|
"vue-i18n": "^9.1.10",
|
|
84
71
|
"vue-router": "^4.0.15",
|
|
85
|
-
"yargs": "^17.
|
|
72
|
+
"yargs": "^17.5.0"
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@types/katex": "^0.14.0",
|
|
76
|
+
"@types/markdown-it-link-attributes": "^3.0.1",
|
|
77
|
+
"@types/nprogress": "^0.2.0",
|
|
78
|
+
"@types/yargs": "^17.0.10",
|
|
79
|
+
"debug": "^4.3.4",
|
|
80
|
+
"diacritics": "^1.3.0",
|
|
81
|
+
"https-localhost": "^4.7.1",
|
|
82
|
+
"type-fest": "^2.12.2",
|
|
83
|
+
"vue-tsc": "^0.34.13"
|
|
84
|
+
},
|
|
85
|
+
"engines": {
|
|
86
|
+
"node": ">=14.0.0"
|
|
86
87
|
},
|
|
87
88
|
"scripts": {
|
|
88
|
-
"build": "tsup --splitting",
|
|
89
|
+
"build": "rimraf dist && tsup --splitting",
|
|
89
90
|
"dev": "tsup --watch --splitting",
|
|
90
91
|
"lint": "eslint \"**/*.{vue,ts,js}\"",
|
|
91
92
|
"preview": "vite preview",
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
2
|
+
import { onMounted, ref, watch } from 'vue'
|
|
3
3
|
import { useI18n } from 'vue-i18n'
|
|
4
4
|
import { useRoute } from 'vue-router'
|
|
5
5
|
|
|
6
|
+
import type { Header } from '../../node/markdown'
|
|
6
7
|
import { useActiveSidebarLinks } from '~/composables'
|
|
7
|
-
|
|
8
|
-
const route = useRoute()
|
|
9
|
-
const headers = computed(() => route.meta.headers)
|
|
8
|
+
import { useConfig } from '~/config'
|
|
10
9
|
|
|
11
10
|
const container = ref()
|
|
12
11
|
const marker = ref()
|
|
@@ -21,6 +20,53 @@ function getStylesByLevel(level: number) {
|
|
|
21
20
|
|
|
22
21
|
const { locale } = useI18n()
|
|
23
22
|
|
|
23
|
+
const config = useConfig()
|
|
24
|
+
|
|
25
|
+
function useHeaders() {
|
|
26
|
+
const headers = ref<Header[]>([])
|
|
27
|
+
const route = useRoute()
|
|
28
|
+
|
|
29
|
+
function generateHeaders() {
|
|
30
|
+
headers.value = []
|
|
31
|
+
|
|
32
|
+
const content = document.querySelector('.markdown-body')
|
|
33
|
+
const levels = config.value.markdownIt.toc!.includeLevel!.map(level => `h${level}`)
|
|
34
|
+
|
|
35
|
+
content?.querySelectorAll(levels as any).forEach((header) => {
|
|
36
|
+
headers.value.push({
|
|
37
|
+
level: header.tagName.toLowerCase().replace('h', ''),
|
|
38
|
+
title: header.textContent.replace('#', ''),
|
|
39
|
+
slug: header.id,
|
|
40
|
+
lang: header.lang || locale.value,
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
watch(() => route.path, () => {
|
|
46
|
+
generateHeaders()
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
onMounted(() => {
|
|
50
|
+
generateHeaders()
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
headers,
|
|
55
|
+
generateHeaders,
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const { headers, generateHeaders } = useHeaders()
|
|
60
|
+
|
|
61
|
+
if (import.meta.hot) {
|
|
62
|
+
import.meta.hot.on('valaxy:md-update', () => {
|
|
63
|
+
setTimeout(() => {
|
|
64
|
+
generateHeaders()
|
|
65
|
+
// 400ms transition
|
|
66
|
+
}, 600)
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
24
70
|
// todo mobile toc widget
|
|
25
71
|
</script>
|
|
26
72
|
|
|
@@ -47,14 +47,14 @@ post:
|
|
|
47
47
|
author: Post author
|
|
48
48
|
link: Post link
|
|
49
49
|
license_title: Copyright Notice
|
|
50
|
-
license_content:
|
|
50
|
+
license_content: 'All articles in this blog are licensed under {0} unless otherwise stated.'
|
|
51
51
|
|
|
52
52
|
# page:
|
|
53
53
|
# totally: Totally
|
|
54
54
|
# tags: tags
|
|
55
55
|
|
|
56
56
|
footer:
|
|
57
|
-
powered:
|
|
57
|
+
powered: 'Powered by {0}'
|
|
58
58
|
theme: Theme
|
|
59
59
|
total_views: Total Views
|
|
60
60
|
total_visitors: Total Visitors
|
|
@@ -66,24 +66,24 @@ counter:
|
|
|
66
66
|
albums:
|
|
67
67
|
zero: No album
|
|
68
68
|
one: 1 album in total
|
|
69
|
-
other:
|
|
69
|
+
other: '%d albums in total'
|
|
70
70
|
photos:
|
|
71
71
|
zero: No photo
|
|
72
72
|
one: 1 photo in total
|
|
73
|
-
other:
|
|
73
|
+
other: '%d photos in total'
|
|
74
74
|
|
|
75
75
|
category:
|
|
76
76
|
uncategorized: Uncategorized
|
|
77
77
|
|
|
78
78
|
search:
|
|
79
79
|
placeholder: Searching...
|
|
80
|
-
empty:
|
|
81
|
-
hits_time:
|
|
80
|
+
empty: 'We didn''t find any results for the search: {query}.'
|
|
81
|
+
hits_time: '{hits} results found in {time} ms'
|
|
82
82
|
|
|
83
83
|
symbol:
|
|
84
|
-
comma:
|
|
85
|
-
period:
|
|
86
|
-
colon:
|
|
84
|
+
comma: ', '
|
|
85
|
+
period: '. '
|
|
86
|
+
colon: ': '
|
|
87
87
|
|
|
88
88
|
reward:
|
|
89
89
|
donate: Donate
|
|
@@ -47,13 +47,13 @@ post:
|
|
|
47
47
|
author: 本文作者
|
|
48
48
|
link: 本文链接
|
|
49
49
|
license_title: 版权声明
|
|
50
|
-
license_content:
|
|
50
|
+
license_content: '本博客所有文章除特别声明外,均默认采用 {0} 许可协议。'
|
|
51
51
|
|
|
52
52
|
# page:
|
|
53
53
|
# totally: 共有
|
|
54
54
|
# tags: 标签
|
|
55
55
|
footer:
|
|
56
|
-
powered:
|
|
56
|
+
powered: '由 {0} 驱动'
|
|
57
57
|
theme: 主题
|
|
58
58
|
total_views: 总访问量
|
|
59
59
|
total_visitors: 总访客量
|
|
@@ -65,24 +65,24 @@ counter:
|
|
|
65
65
|
albums:
|
|
66
66
|
zero: 暂无相册
|
|
67
67
|
one: 共计 1 个相册
|
|
68
|
-
other:
|
|
68
|
+
other: '共计 %d 个相册'
|
|
69
69
|
photos:
|
|
70
70
|
zero: 暂无照片
|
|
71
71
|
one: 共计 1 张照片
|
|
72
|
-
other:
|
|
72
|
+
other: '共计 %d 张照片'
|
|
73
73
|
|
|
74
74
|
category:
|
|
75
75
|
uncategorized: 未分类
|
|
76
76
|
|
|
77
77
|
search:
|
|
78
78
|
placeholder: 搜索...
|
|
79
|
-
empty:
|
|
80
|
-
hits_time:
|
|
79
|
+
empty: '找不到您查询的内容: {query}'
|
|
80
|
+
hits_time: '找到 {hits} 条结果(用时 {time} 毫秒)'
|
|
81
81
|
|
|
82
82
|
symbol:
|
|
83
|
-
comma:
|
|
84
|
-
period:
|
|
85
|
-
colon:
|
|
83
|
+
comma: ,
|
|
84
|
+
period: 。
|
|
85
|
+
colon: :
|
|
86
86
|
|
|
87
87
|
reward:
|
|
88
88
|
donate: 打赏
|
package/src/node/cli.ts
CHANGED
|
@@ -8,6 +8,7 @@ import openBrowser from 'open'
|
|
|
8
8
|
|
|
9
9
|
import consola from 'consola'
|
|
10
10
|
|
|
11
|
+
import { yellow } from 'kolorist'
|
|
11
12
|
import { version } from '../../package.json'
|
|
12
13
|
import { resolveOptions } from './options'
|
|
13
14
|
import { bindShortcut, initServer, printInfo } from './utils/cli'
|
|
@@ -142,7 +143,7 @@ cli.command(
|
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
if (ssg) {
|
|
145
|
-
consola.info(
|
|
146
|
+
consola.info(`use ${yellow('vite-ssg')} to do ssg build...`)
|
|
146
147
|
|
|
147
148
|
try {
|
|
148
149
|
await ssgBuild(options, viteConfig)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { cyan, red, yellow } from 'kolorist'
|
|
2
|
+
import consola from 'consola'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* check Markdown content
|
|
6
|
+
* @param content
|
|
7
|
+
*/
|
|
8
|
+
export function checkMd(content: string, path: string) {
|
|
9
|
+
if (content.includes('{%') && content.includes('%}')) {
|
|
10
|
+
consola.error(
|
|
11
|
+
`${`${path}\n`} Please ${red('remove')} ${cyan('{% %}')}, because it conflicts with ${yellow('markdown-it-attrs')}.`,
|
|
12
|
+
)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -8,13 +8,13 @@ import TaskLists from 'markdown-it-task-lists'
|
|
|
8
8
|
import attrs from 'markdown-it-attrs'
|
|
9
9
|
|
|
10
10
|
import type { KatexOptions } from 'katex'
|
|
11
|
-
import Katex from '
|
|
12
|
-
import { containerPlugin } from '
|
|
13
|
-
import { headingPlugin } from '
|
|
11
|
+
import Katex from './markdown-it/katex'
|
|
12
|
+
import { containerPlugin } from './markdown-it/container'
|
|
13
|
+
// import { headingPlugin } from './markdown-it/headings'
|
|
14
14
|
import { slugify } from './slugify'
|
|
15
|
-
import { parseHeader } from './parseHeader'
|
|
15
|
+
import { parseHeader } from './markdown-it/parseHeader'
|
|
16
16
|
import { highlight } from './highlight'
|
|
17
|
-
import { highlightLinePlugin, preWrapperPlugin } from './highlightLines'
|
|
17
|
+
import { highlightLinePlugin, preWrapperPlugin } from './markdown-it/highlightLines'
|
|
18
18
|
|
|
19
19
|
export interface Header {
|
|
20
20
|
level: number
|
|
@@ -41,7 +41,10 @@ export interface MarkdownOptions extends MarkdownIt.Options {
|
|
|
41
41
|
permalink?: Anchor.AnchorOptions['permalink']
|
|
42
42
|
}
|
|
43
43
|
// https://github.com/Oktavilla/markdown-it-table-of-contents
|
|
44
|
-
toc?:
|
|
44
|
+
toc?: {
|
|
45
|
+
includeLevel?: number[]
|
|
46
|
+
[key: string]: any
|
|
47
|
+
}
|
|
45
48
|
katex?: KatexOptions
|
|
46
49
|
}
|
|
47
50
|
|
|
@@ -53,8 +56,10 @@ export function setupMarkdownPlugins(md: MarkdownIt, mdOptions: MarkdownOptions
|
|
|
53
56
|
.use(highlightLinePlugin)
|
|
54
57
|
.use(preWrapperPlugin)
|
|
55
58
|
.use(containerPlugin)
|
|
59
|
+
// conflict with {% %}
|
|
56
60
|
.use(attrs)
|
|
57
|
-
|
|
61
|
+
// generate toc in client
|
|
62
|
+
// .use(headingPlugin, mdOptions?.toc?.includeLevel)
|
|
58
63
|
// .use(lineNumberPlugin)
|
|
59
64
|
// https://github.com/arve0/markdown-it-attrs
|
|
60
65
|
// add classes
|
|
File without changes
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// ref vitepress
|
|
2
2
|
import type MarkdownIt from 'markdown-it'
|
|
3
|
-
import type { MarkdownRenderer } from '
|
|
3
|
+
import type { MarkdownRenderer } from '..'
|
|
4
|
+
import { slugify } from '../slugify'
|
|
4
5
|
import { deeplyParseHeader } from './parseHeader'
|
|
5
|
-
import { slugify } from './slugify'
|
|
6
6
|
|
|
7
7
|
export const headingPlugin = (md: MarkdownIt, include = [1, 2, 3, 4]) => {
|
|
8
8
|
md.renderer.rules.heading_open = (tokens, i, options, env, self) => {
|
|
@@ -16,7 +16,8 @@ export const headingPlugin = (md: MarkdownIt, include = [1, 2, 3, 4]) => {
|
|
|
16
16
|
const headers = data.headers || (data.headers = [])
|
|
17
17
|
// remove {} after head
|
|
18
18
|
const leftDeli = content.indexOf('{')
|
|
19
|
-
const title = content.slice(0, leftDeli).trim()
|
|
19
|
+
const title = leftDeli === -1 ? content : content.slice(0, leftDeli).trim()
|
|
20
|
+
|
|
20
21
|
const matched = content.match(/\{lang=\"(.*)\"\}/)
|
|
21
22
|
const lang = matched ? matched[1] : ''
|
|
22
23
|
headers.push({
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -27,15 +27,7 @@ export function createConfigPlugin(options: ResolvedValaxyOptions): Plugin {
|
|
|
27
27
|
entries: [resolve(options.clientRoot, 'main.ts'), options.configFile],
|
|
28
28
|
|
|
29
29
|
include: [
|
|
30
|
-
'vue',
|
|
31
|
-
'vue-router',
|
|
32
|
-
'@vueuse/core',
|
|
33
|
-
'@vueuse/head',
|
|
34
30
|
'dayjs',
|
|
35
|
-
'nprogress',
|
|
36
|
-
],
|
|
37
|
-
exclude: [
|
|
38
|
-
'vue-demi',
|
|
39
31
|
],
|
|
40
32
|
},
|
|
41
33
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Markdown from 'vite-plugin-md'
|
|
1
|
+
import Markdown, { meta } from 'vite-plugin-md'
|
|
3
2
|
|
|
4
3
|
import type { Plugin } from 'vite'
|
|
5
4
|
import type { ResolvedValaxyOptions } from '../options'
|
|
6
5
|
|
|
7
|
-
import type { MarkdownRenderer } from '../markdown'
|
|
8
6
|
import { setupMarkdownPlugins } from '../markdown'
|
|
9
|
-
import {
|
|
10
|
-
// import { useRoute } from 'vue-router'
|
|
7
|
+
import { checkMd } from '../markdown/check'
|
|
11
8
|
|
|
12
9
|
export type ViteMdOptions = Parameters<typeof Markdown>[0]
|
|
13
10
|
|
|
@@ -16,8 +13,6 @@ export const excerpt_separator = '<!-- more -->'
|
|
|
16
13
|
// https://github.com/antfu/vite-plugin-md
|
|
17
14
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18
15
|
export function createMarkdownPlugin(options: ResolvedValaxyOptions): Plugin[] {
|
|
19
|
-
let _md: MarkdownRenderer
|
|
20
|
-
|
|
21
16
|
const mdOptions = options.config.markdownIt
|
|
22
17
|
|
|
23
18
|
const defaultOptions: ViteMdOptions = {
|
|
@@ -29,33 +24,35 @@ export function createMarkdownPlugin(options: ResolvedValaxyOptions): Plugin[] {
|
|
|
29
24
|
|
|
30
25
|
excerpt: excerpt_separator,
|
|
31
26
|
|
|
32
|
-
|
|
33
|
-
// avoid conflict with markdown-it-anchor link
|
|
34
|
-
// link(),
|
|
35
|
-
// seems bug, override frontmatter
|
|
36
|
-
// meta(),
|
|
37
|
-
],
|
|
27
|
+
frontmatterPreprocess: meta() as any,
|
|
38
28
|
|
|
39
29
|
markdownItSetup(md) {
|
|
40
30
|
if (mdOptions.config)
|
|
41
31
|
mdOptions.config(md)
|
|
42
32
|
|
|
43
|
-
|
|
33
|
+
setupMarkdownPlugins(md, mdOptions)
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
transforms: {
|
|
37
|
+
before: (code, id) => {
|
|
38
|
+
checkMd(code, id)
|
|
39
|
+
|
|
40
|
+
code.replace('{%', '\{\%')
|
|
41
|
+
code.replace('%}', '\%\}')
|
|
42
|
+
return code
|
|
43
|
+
},
|
|
44
44
|
},
|
|
45
45
|
}
|
|
46
|
+
|
|
46
47
|
return [Markdown(Object.assign(defaultOptions, options.config.markdown)), {
|
|
47
48
|
name: 'valaxy:md',
|
|
48
49
|
handleHotUpdate(ctx) {
|
|
49
50
|
const { file, server } = ctx
|
|
50
51
|
// send headers
|
|
51
|
-
if (file.endsWith('.md')
|
|
52
|
+
if (file.endsWith('.md')) {
|
|
52
53
|
server.ws.send({
|
|
53
54
|
type: 'custom',
|
|
54
|
-
event: 'valaxy:
|
|
55
|
-
data: {
|
|
56
|
-
path: `/${slash(path.relative(`${options.userRoot}/pages`, file))}`,
|
|
57
|
-
pageHeaders: _md.__data.headers,
|
|
58
|
-
},
|
|
55
|
+
event: 'valaxy:md-update',
|
|
59
56
|
})
|
|
60
57
|
}
|
|
61
58
|
},
|
|
@@ -14,7 +14,7 @@ import { VitePWA } from 'vite-plugin-pwa'
|
|
|
14
14
|
import VueI18n from '@intlify/vite-plugin-vue-i18n'
|
|
15
15
|
import Inspect from 'vite-plugin-inspect'
|
|
16
16
|
|
|
17
|
-
import
|
|
17
|
+
import { dim, yellow } from 'kolorist'
|
|
18
18
|
import type { ResolvedValaxyOptions, ValaxyServerOptions } from '../options'
|
|
19
19
|
import { setupMarkdownPlugins } from '../markdown'
|
|
20
20
|
import { createMarkdownPlugin, excerpt_separator } from './markdown'
|
|
@@ -39,7 +39,7 @@ export async function ViteValaxyPlugins(
|
|
|
39
39
|
const ValaxyPlugin = createValaxyPlugin(options, serverOptions)
|
|
40
40
|
|
|
41
41
|
const mdIt = new MarkdownIt({ html: true })
|
|
42
|
-
|
|
42
|
+
setupMarkdownPlugins(mdIt, options.config.markdownIt)
|
|
43
43
|
|
|
44
44
|
const roots = [clientRoot, themeRoot, userRoot]
|
|
45
45
|
|
|
@@ -92,7 +92,6 @@ export async function ViteValaxyPlugins(
|
|
|
92
92
|
}),
|
|
93
93
|
|
|
94
94
|
ValaxyPlugin,
|
|
95
|
-
MarkdownPlugin,
|
|
96
95
|
createConfigPlugin(options),
|
|
97
96
|
|
|
98
97
|
ThemePlugin(options.config.themeConfig),
|
|
@@ -109,22 +108,20 @@ export async function ViteValaxyPlugins(
|
|
|
109
108
|
if (!route.meta)
|
|
110
109
|
route.meta = {}
|
|
111
110
|
|
|
112
|
-
if (route.path === '/')
|
|
113
|
-
route.meta.layout = 'home'
|
|
114
|
-
|
|
115
111
|
roots.forEach((root) => {
|
|
116
112
|
const pagePath = root + route.component
|
|
117
113
|
if (fs.existsSync(pagePath))
|
|
118
114
|
path = pagePath
|
|
119
115
|
})
|
|
116
|
+
|
|
120
117
|
const md = fs.readFileSync(path, 'utf-8')
|
|
121
|
-
const { data, excerpt
|
|
118
|
+
const { data, excerpt } = matter(md, { excerpt_separator })
|
|
122
119
|
|
|
123
120
|
// warn for post frontmatter
|
|
124
121
|
if (route.path.startsWith('/posts/')) {
|
|
125
122
|
route.meta.layout = 'post'
|
|
126
123
|
if (!data.date)
|
|
127
|
-
consola.warn(`You forgot to write ${
|
|
124
|
+
consola.warn(`You forgot to write ${yellow('date')} for post: ${dim(`${route.component}`)}`)
|
|
128
125
|
}
|
|
129
126
|
|
|
130
127
|
route.meta = Object.assign(route.meta, {
|
|
@@ -132,11 +129,6 @@ export async function ViteValaxyPlugins(
|
|
|
132
129
|
excerpt: excerpt ? mdIt.render(excerpt) : '',
|
|
133
130
|
})
|
|
134
131
|
|
|
135
|
-
// to refactor
|
|
136
|
-
// get active header by runtime query head, not render
|
|
137
|
-
mdIt.render(content)
|
|
138
|
-
route.meta.headers = _md.__data?.headers
|
|
139
|
-
|
|
140
132
|
// set default updated
|
|
141
133
|
if (route.meta.frontmatter.updated)
|
|
142
134
|
route.meta.frontmatter.updated = route.meta.frontmatter.date
|
|
@@ -148,7 +140,6 @@ export async function ViteValaxyPlugins(
|
|
|
148
140
|
return route
|
|
149
141
|
},
|
|
150
142
|
}),
|
|
151
|
-
|
|
152
143
|
// https://github.com/JohnCampionJr/vite-plugin-vue-layouts
|
|
153
144
|
Layouts({
|
|
154
145
|
layoutsDirs: roots.map(root => `${root}/layouts`),
|
|
@@ -176,6 +167,8 @@ export async function ViteValaxyPlugins(
|
|
|
176
167
|
// UnocssPlugin,
|
|
177
168
|
UnocssPlugin,
|
|
178
169
|
|
|
170
|
+
...MarkdownPlugin,
|
|
171
|
+
|
|
179
172
|
// https://github.com/antfu/vite-plugin-pwa
|
|
180
173
|
VitePWA({
|
|
181
174
|
registerType: 'autoUpdate',
|
package/src/node/rss.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dirname } from 'path'
|
|
2
|
-
import
|
|
2
|
+
import { cyan, dim } from 'kolorist'
|
|
3
3
|
|
|
4
4
|
import fg from 'fast-glob'
|
|
5
5
|
import fs from 'fs-extra'
|
|
@@ -37,7 +37,7 @@ export async function build(options: ResolvedValaxyOptions) {
|
|
|
37
37
|
link: options.config.author.link,
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
consola.info(`RSS Site Url: ${
|
|
40
|
+
consola.info(`RSS Site Url: ${cyan(siteUrl)}`)
|
|
41
41
|
|
|
42
42
|
const ccVersion = (config.license.type === 'zero') ? '1.0' : '4.0'
|
|
43
43
|
const feedOptions: FeedOptions = {
|
|
@@ -64,12 +64,12 @@ export async function build(options: ResolvedValaxyOptions) {
|
|
|
64
64
|
|
|
65
65
|
// not add to posts
|
|
66
66
|
if (!data.date) {
|
|
67
|
-
consola.warn(`Do you forget to write date for ${
|
|
67
|
+
consola.warn(`Do you forget to write date for ${dim(i)}`)
|
|
68
68
|
return false
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
if (data.draft) {
|
|
72
|
-
consola.warn(`Ignore draft post: ${
|
|
72
|
+
consola.warn(`Ignore draft post: ${dim(i)}`)
|
|
73
73
|
return false
|
|
74
74
|
}
|
|
75
75
|
|