@tnotesjs/core 0.0.1 → 0.0.3
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 +84 -84
- package/dist/{chunk-CSSIRO3I.js → chunk-NI5B4S3T.js} +40 -3
- package/dist/cli/index.js +1 -1
- package/dist/vitepress/config/index.js +60 -17
- package/package.json +77 -77
- package/types/config.ts +61 -61
- package/types/index.ts +11 -11
- package/types/note.ts +33 -33
- package/vitepress/assets/icons/icon__check.svg +3 -3
- package/vitepress/assets/icons/icon__clipboard.svg +7 -7
- package/vitepress/assets/icons/icon__close.svg +1 -1
- package/vitepress/assets/icons/icon__collapse.svg +1 -1
- package/vitepress/assets/icons/icon__confirm.svg +1 -1
- package/vitepress/assets/icons/icon__copy.svg +4 -4
- package/vitepress/assets/icons/icon__focus.svg +1 -1
- package/vitepress/assets/icons/icon__fold.svg +3 -3
- package/vitepress/assets/icons/icon__folder.svg +1 -1
- package/vitepress/assets/icons/icon__fullscreen.svg +1 -1
- package/vitepress/assets/icons/icon__fullscreen_exit.svg +1 -1
- package/vitepress/assets/icons/icon__github.svg +3 -3
- package/vitepress/assets/icons/icon__mindmap.svg +1 -1
- package/vitepress/assets/icons/icon__next.svg +1 -1
- package/vitepress/assets/icons/icon__number_gray.svg +1 -1
- package/vitepress/assets/icons/icon__number_purple.svg +1 -1
- package/vitepress/assets/icons/icon__prev.svg +1 -1
- package/vitepress/assets/icons/icon__restore.svg +1 -1
- package/vitepress/assets/icons/icon__rotate.svg +4 -4
- package/vitepress/assets/icons/icon__search.svg +1 -1
- package/vitepress/assets/icons/icon__sidebar_collapsed.svg +1 -1
- package/vitepress/assets/icons/icon__sidebar_opened.svg +1 -1
- package/vitepress/assets/icons/icon__totop.svg +5 -5
- package/vitepress/assets/icons/icon__vscode.svg +5 -5
- package/vitepress/assets/icons/icon__zoom_fit.svg +1 -1
- package/vitepress/assets/icons/icon__zoom_in.svg +1 -1
- package/vitepress/assets/icons/icon__zoom_out.svg +1 -1
- package/vitepress/assets/icons/icon__zoom_reset.svg +1 -1
- package/vitepress/assets/icons/index.ts +38 -38
- package/vitepress/components/BilibiliOutsidePlayer/BilibiliOutsidePlayer.vue +20 -20
- package/vitepress/components/CodeBlockFullscreen/CodeBlockFullscreen.vue +373 -373
- package/vitepress/components/CodeBlockFullscreen/index.ts +115 -115
- package/vitepress/components/CodeBlockFullscreen/styles.css +64 -64
- package/vitepress/components/Discussions/Discussions.module.scss +32 -32
- package/vitepress/components/Discussions/Discussions.vue +211 -211
- package/vitepress/components/EnWordList/EnWordList.module.scss +124 -124
- package/vitepress/components/EnWordList/EnWordList.vue +543 -543
- package/vitepress/components/EnWordList/RightClickMenu.module.scss +22 -22
- package/vitepress/components/EnWordList/RightClickMenu.vue +66 -66
- package/vitepress/components/Footprints/Footprints.module.scss +93 -93
- package/vitepress/components/Footprints/Footprints.vue +377 -377
- package/vitepress/components/Layout/AboutModal.module.scss +233 -233
- package/vitepress/components/Layout/AboutModal.vue +105 -105
- package/vitepress/components/Layout/AboutPanel.vue +266 -266
- package/vitepress/components/Layout/ContentCollapse.vue +603 -603
- package/vitepress/components/Layout/CustomSidebar.vue +605 -605
- package/vitepress/components/Layout/DocBeforeControls.vue +139 -139
- package/vitepress/components/Layout/DocFooter.vue +225 -225
- package/vitepress/components/Layout/ImagePreview.module.scss +201 -201
- package/vitepress/components/Layout/ImagePreview.vue +281 -281
- package/vitepress/components/Layout/Layout.module.scss +661 -661
- package/vitepress/components/Layout/Layout.vue +542 -542
- package/vitepress/components/Layout/NoteStatus.vue +140 -140
- package/vitepress/components/Layout/SidebarItems.vue +263 -263
- package/vitepress/components/Layout/SidebarNavBefore.vue +92 -92
- package/vitepress/components/Layout/Swiper.vue +167 -167
- package/vitepress/components/Layout/ToggleFullContent.module.scss +11 -11
- package/vitepress/components/Layout/ToggleFullContent.vue +34 -34
- package/vitepress/components/Layout/ToggleSidebar.module.scss +11 -11
- package/vitepress/components/Layout/ToggleSidebar.vue +35 -35
- package/vitepress/components/Layout/composables/useCollapseControl.ts +88 -88
- package/vitepress/components/Layout/composables/useNoteConfig.ts +121 -121
- package/vitepress/components/Layout/composables/useNoteSave.ts +173 -173
- package/vitepress/components/Layout/composables/useNoteValidation.ts +85 -85
- package/vitepress/components/Layout/composables/useRedirect.ts +110 -110
- package/vitepress/components/Layout/composables/useVSCodeIntegration.ts +85 -85
- package/vitepress/components/Layout/homeReadme.data.ts +124 -124
- package/vitepress/components/LoadingPage/LoadingPage.vue +192 -192
- package/vitepress/components/MarkMap/MarkMap.module.scss +159 -159
- package/vitepress/components/MarkMap/MarkMap.vue +404 -404
- package/vitepress/components/Mermaid/Mermaid.module.scss +275 -275
- package/vitepress/components/Mermaid/Mermaid.vue +364 -364
- package/vitepress/components/NotesTable/NotesTable.module.scss +77 -77
- package/vitepress/components/NotesTable/NotesTable.vue +98 -98
- package/vitepress/components/NotesTable/README.md +67 -67
- package/vitepress/components/Settings/Settings.module.scss +433 -433
- package/vitepress/components/Settings/Settings.vue +306 -306
- package/vitepress/components/SidebarCard/MindMapView.vue +483 -483
- package/vitepress/components/SidebarCard/NotesTrendChart.vue +108 -108
- package/vitepress/components/SidebarCard/SidebarCard.vue +948 -948
- package/vitepress/components/Tooltip/Tooltip.vue +70 -70
- package/vitepress/components/constants.ts +91 -91
- package/vitepress/components/notesConfig.data.ts +73 -73
- package/vitepress/components/sidebar.data.ts +59 -59
- package/vitepress/components/tnotes-config.data.ts +21 -21
- package/vitepress/components/utils.ts +26 -26
- package/vitepress/config/index.ts +141 -141
- package/vitepress/configs/constants.ts +26 -26
- package/vitepress/configs/head.config.ts +25 -25
- package/vitepress/configs/index.ts +9 -9
- package/vitepress/configs/markdown-it.d.ts +23 -23
- package/vitepress/configs/markdown.config.ts +366 -366
- package/vitepress/configs/theme.config.ts +108 -108
- package/vitepress/plugins/buildProgressPlugin.ts +466 -390
- package/vitepress/plugins/getNoteByConfigIdPlugin.ts +107 -107
- package/vitepress/plugins/renameNotePlugin.ts +60 -60
- package/vitepress/plugins/updateConfigPlugin.ts +63 -63
- package/vitepress/theme/index.ts +95 -95
- package/vitepress/theme/styles/base.scss +50 -50
- package/vitepress/theme/styles/components/404.scss +31 -31
- package/vitepress/theme/styles/components/collapse.scss +175 -175
- package/vitepress/theme/styles/components/markmap.scss +101 -101
- package/vitepress/theme/styles/components/swiper.scss +255 -255
- package/vitepress/theme/styles/index.scss +25 -25
- package/vitepress/theme/styles/layout.scss +62 -62
- package/vitepress/theme/styles/utilities.scss +39 -39
- package/vitepress/theme/styles/vitepress-override.scss +25 -25
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
export const formatDate = (timestamp: number): string => {
|
|
2
|
-
const date = new Date(timestamp)
|
|
3
|
-
const year = date.getFullYear()
|
|
4
|
-
const month = String(date.getMonth() + 1).padStart(2, '0')
|
|
5
|
-
const day = String(date.getDate()).padStart(2, '0')
|
|
6
|
-
const weekDays = ['日', '一', '二', '三', '四', '五', '六']
|
|
7
|
-
const weekDay = weekDays[date.getDay()]
|
|
8
|
-
const hours = String(date.getHours()).padStart(2, '0')
|
|
9
|
-
const minutes = String(date.getMinutes()).padStart(2, '0')
|
|
10
|
-
const seconds = String(date.getSeconds()).padStart(2, '0')
|
|
11
|
-
|
|
12
|
-
const footprintsDay = getFootprintsDay(timestamp)
|
|
13
|
-
// const period = hours < 12 ? '上午' : '下午'
|
|
14
|
-
// const formattedHours = hours % 12 || 12
|
|
15
|
-
|
|
16
|
-
return `👣 ${footprintsDay} | ${year}年${month}月${day}日 周${weekDay} ${hours}:${minutes}:${seconds}`
|
|
17
|
-
// return `${year}-${month}-${day} 周${weekDay} ${period} ${formattedHours}:${minutes}:${seconds}`
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const getFootprintsDay = (timestamp: number = Date.now()): number =>
|
|
21
|
-
Math.floor(
|
|
22
|
-
(timestamp - new Date(1999, 5, 29).getTime()) / (1000 * 60 * 60 * 24)
|
|
23
|
-
) + 1
|
|
24
|
-
|
|
25
|
-
export const scrollToTop = (): void =>
|
|
26
|
-
window.scrollTo({ top: 0, behavior: 'smooth' })
|
|
1
|
+
export const formatDate = (timestamp: number): string => {
|
|
2
|
+
const date = new Date(timestamp)
|
|
3
|
+
const year = date.getFullYear()
|
|
4
|
+
const month = String(date.getMonth() + 1).padStart(2, '0')
|
|
5
|
+
const day = String(date.getDate()).padStart(2, '0')
|
|
6
|
+
const weekDays = ['日', '一', '二', '三', '四', '五', '六']
|
|
7
|
+
const weekDay = weekDays[date.getDay()]
|
|
8
|
+
const hours = String(date.getHours()).padStart(2, '0')
|
|
9
|
+
const minutes = String(date.getMinutes()).padStart(2, '0')
|
|
10
|
+
const seconds = String(date.getSeconds()).padStart(2, '0')
|
|
11
|
+
|
|
12
|
+
const footprintsDay = getFootprintsDay(timestamp)
|
|
13
|
+
// const period = hours < 12 ? '上午' : '下午'
|
|
14
|
+
// const formattedHours = hours % 12 || 12
|
|
15
|
+
|
|
16
|
+
return `👣 ${footprintsDay} | ${year}年${month}月${day}日 周${weekDay} ${hours}:${minutes}:${seconds}`
|
|
17
|
+
// return `${year}-${month}-${day} 周${weekDay} ${period} ${formattedHours}:${minutes}:${seconds}`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const getFootprintsDay = (timestamp: number = Date.now()): number =>
|
|
21
|
+
Math.floor(
|
|
22
|
+
(timestamp - new Date(1999, 5, 29).getTime()) / (1000 * 60 * 60 * 24)
|
|
23
|
+
) + 1
|
|
24
|
+
|
|
25
|
+
export const scrollToTop = (): void =>
|
|
26
|
+
window.scrollTo({ top: 0, behavior: 'smooth' })
|
|
@@ -1,141 +1,141 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* .vitepress/tnotes/vitepress/config/index.ts
|
|
3
|
-
*
|
|
4
|
-
* VitePress 站点配置工厂函数
|
|
5
|
-
*
|
|
6
|
-
* 将所有共享配置封装在 tnotesjs/core 中,外围 config.mts 只需一行调用:
|
|
7
|
-
* import { defineNotesConfig } from './tnotes/vitepress/config'
|
|
8
|
-
* export default defineNotesConfig()
|
|
9
|
-
*/
|
|
10
|
-
import fs from 'fs'
|
|
11
|
-
import path from 'path'
|
|
12
|
-
import { defineConfig, type UserConfig } from 'vitepress'
|
|
13
|
-
import type { TNotesConfig } from '../../types'
|
|
14
|
-
import {
|
|
15
|
-
getIgnoreList,
|
|
16
|
-
getGithubPageUrl,
|
|
17
|
-
getHeadConfig,
|
|
18
|
-
getMarkdownConfig,
|
|
19
|
-
getThemeConfig,
|
|
20
|
-
} from '../configs'
|
|
21
|
-
import { updateConfigPlugin } from '../plugins/updateConfigPlugin'
|
|
22
|
-
import { renameNotePlugin } from '../plugins/renameNotePlugin'
|
|
23
|
-
import { getNoteByConfigIdPlugin } from '../plugins/getNoteByConfigIdPlugin'
|
|
24
|
-
import { buildProgressPlugin } from '../plugins/buildProgressPlugin'
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 读取 .tnotes.json 配置文件
|
|
28
|
-
*/
|
|
29
|
-
function loadTNotesConfig(rootPath: string): TNotesConfig {
|
|
30
|
-
const configPath = path.resolve(rootPath, '.tnotes.json')
|
|
31
|
-
const configContent = fs.readFileSync(configPath, 'utf-8')
|
|
32
|
-
return JSON.parse(configContent) as TNotesConfig
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 创建 VitePress 站点配置
|
|
37
|
-
*
|
|
38
|
-
* @param overrides - 可选的覆盖配置,会与默认配置合并
|
|
39
|
-
* @returns VitePress 配置对象
|
|
40
|
-
*/
|
|
41
|
-
export function defineNotesConfig(overrides: UserConfig = {}) {
|
|
42
|
-
const rootPath = process.cwd()
|
|
43
|
-
const config = loadTNotesConfig(rootPath)
|
|
44
|
-
const { repoName } = config
|
|
45
|
-
|
|
46
|
-
const IGNORE_LIST = getIgnoreList(config)
|
|
47
|
-
const GITHUB_PAGE_URL = getGithubPageUrl(config)
|
|
48
|
-
|
|
49
|
-
const {
|
|
50
|
-
transformPageData: overrideTransformPageData,
|
|
51
|
-
vite: overrideVite,
|
|
52
|
-
...restOverrides
|
|
53
|
-
} = overrides
|
|
54
|
-
|
|
55
|
-
return defineConfig({
|
|
56
|
-
appearance: 'dark',
|
|
57
|
-
base: '/' + repoName + '/',
|
|
58
|
-
cleanUrls: true,
|
|
59
|
-
description: repoName,
|
|
60
|
-
head: getHeadConfig(config, GITHUB_PAGE_URL),
|
|
61
|
-
ignoreDeadLinks: true,
|
|
62
|
-
lang: 'zh-Hans',
|
|
63
|
-
lastUpdated: false,
|
|
64
|
-
markdown: getMarkdownConfig(),
|
|
65
|
-
sitemap: {
|
|
66
|
-
hostname: GITHUB_PAGE_URL,
|
|
67
|
-
lastmodDateOnly: false,
|
|
68
|
-
},
|
|
69
|
-
themeConfig: getThemeConfig(config),
|
|
70
|
-
title: repoName,
|
|
71
|
-
srcExclude: IGNORE_LIST,
|
|
72
|
-
vite: {
|
|
73
|
-
plugins: [
|
|
74
|
-
buildProgressPlugin() as any,
|
|
75
|
-
updateConfigPlugin() as any,
|
|
76
|
-
renameNotePlugin() as any,
|
|
77
|
-
getNoteByConfigIdPlugin() as any,
|
|
78
|
-
...(overrideVite?.plugins || []),
|
|
79
|
-
],
|
|
80
|
-
server: {
|
|
81
|
-
watch: {
|
|
82
|
-
ignored: IGNORE_LIST,
|
|
83
|
-
},
|
|
84
|
-
...overrideVite?.server,
|
|
85
|
-
},
|
|
86
|
-
css: {
|
|
87
|
-
preprocessorOptions: {
|
|
88
|
-
scss: {
|
|
89
|
-
silenceDeprecations: ['legacy-js-api'],
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
...overrideVite?.css,
|
|
93
|
-
},
|
|
94
|
-
build: {
|
|
95
|
-
chunkSizeWarningLimit: 1000,
|
|
96
|
-
...overrideVite?.build,
|
|
97
|
-
},
|
|
98
|
-
define: {
|
|
99
|
-
__TNOTES_REPO_NAME__: JSON.stringify(config.repoName),
|
|
100
|
-
__TNOTES_AUTHOR__: JSON.stringify(config.author),
|
|
101
|
-
__TNOTES_IGNORE_DIRS__: JSON.stringify(config.ignore_dirs),
|
|
102
|
-
__TNOTES_ROOT_ITEM__: JSON.stringify(config.root_item),
|
|
103
|
-
...overrideVite?.define,
|
|
104
|
-
},
|
|
105
|
-
resolve: {
|
|
106
|
-
dedupe: ['vue', 'vitepress'],
|
|
107
|
-
...overrideVite?.resolve,
|
|
108
|
-
},
|
|
109
|
-
optimizeDeps: {
|
|
110
|
-
include: [
|
|
111
|
-
// VitePress 内部 CJS 依赖 —— 需要 Vite 预构建为 ESM
|
|
112
|
-
'vitepress > @vscode/markdown-it-katex',
|
|
113
|
-
'vitepress > @braintree/sanitize-url',
|
|
114
|
-
'vitepress > dayjs',
|
|
115
|
-
'vitepress > dayjs/plugin/utc',
|
|
116
|
-
'vitepress > dayjs/plugin/localizedFormat',
|
|
117
|
-
],
|
|
118
|
-
...overrideVite?.optimizeDeps,
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
transformPageData(pageData, ctx) {
|
|
122
|
-
// 为笔记页面注入原始 Markdown 内容(用于一键复制功能)
|
|
123
|
-
if (/^notes\/\d{4}/.test(pageData.relativePath)) {
|
|
124
|
-
const fullPath = path.resolve(rootPath, pageData.relativePath)
|
|
125
|
-
try {
|
|
126
|
-
pageData.frontmatter.rawContent = fs.readFileSync(fullPath, 'utf-8')
|
|
127
|
-
} catch {
|
|
128
|
-
pageData.frontmatter.rawContent = null
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
// 执行外部覆盖的 transformPageData(如有)
|
|
132
|
-
if (typeof overrideTransformPageData === 'function') {
|
|
133
|
-
return overrideTransformPageData(pageData, ctx)
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
router: {
|
|
137
|
-
prefetchLinks: false,
|
|
138
|
-
},
|
|
139
|
-
...restOverrides,
|
|
140
|
-
})
|
|
141
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* .vitepress/tnotes/vitepress/config/index.ts
|
|
3
|
+
*
|
|
4
|
+
* VitePress 站点配置工厂函数
|
|
5
|
+
*
|
|
6
|
+
* 将所有共享配置封装在 tnotesjs/core 中,外围 config.mts 只需一行调用:
|
|
7
|
+
* import { defineNotesConfig } from './tnotes/vitepress/config'
|
|
8
|
+
* export default defineNotesConfig()
|
|
9
|
+
*/
|
|
10
|
+
import fs from 'fs'
|
|
11
|
+
import path from 'path'
|
|
12
|
+
import { defineConfig, type UserConfig } from 'vitepress'
|
|
13
|
+
import type { TNotesConfig } from '../../types'
|
|
14
|
+
import {
|
|
15
|
+
getIgnoreList,
|
|
16
|
+
getGithubPageUrl,
|
|
17
|
+
getHeadConfig,
|
|
18
|
+
getMarkdownConfig,
|
|
19
|
+
getThemeConfig,
|
|
20
|
+
} from '../configs'
|
|
21
|
+
import { updateConfigPlugin } from '../plugins/updateConfigPlugin'
|
|
22
|
+
import { renameNotePlugin } from '../plugins/renameNotePlugin'
|
|
23
|
+
import { getNoteByConfigIdPlugin } from '../plugins/getNoteByConfigIdPlugin'
|
|
24
|
+
import { buildProgressPlugin } from '../plugins/buildProgressPlugin'
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 读取 .tnotes.json 配置文件
|
|
28
|
+
*/
|
|
29
|
+
function loadTNotesConfig(rootPath: string): TNotesConfig {
|
|
30
|
+
const configPath = path.resolve(rootPath, '.tnotes.json')
|
|
31
|
+
const configContent = fs.readFileSync(configPath, 'utf-8')
|
|
32
|
+
return JSON.parse(configContent) as TNotesConfig
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 创建 VitePress 站点配置
|
|
37
|
+
*
|
|
38
|
+
* @param overrides - 可选的覆盖配置,会与默认配置合并
|
|
39
|
+
* @returns VitePress 配置对象
|
|
40
|
+
*/
|
|
41
|
+
export function defineNotesConfig(overrides: UserConfig = {}) {
|
|
42
|
+
const rootPath = process.cwd()
|
|
43
|
+
const config = loadTNotesConfig(rootPath)
|
|
44
|
+
const { repoName } = config
|
|
45
|
+
|
|
46
|
+
const IGNORE_LIST = getIgnoreList(config)
|
|
47
|
+
const GITHUB_PAGE_URL = getGithubPageUrl(config)
|
|
48
|
+
|
|
49
|
+
const {
|
|
50
|
+
transformPageData: overrideTransformPageData,
|
|
51
|
+
vite: overrideVite,
|
|
52
|
+
...restOverrides
|
|
53
|
+
} = overrides
|
|
54
|
+
|
|
55
|
+
return defineConfig({
|
|
56
|
+
appearance: 'dark',
|
|
57
|
+
base: '/' + repoName + '/',
|
|
58
|
+
cleanUrls: true,
|
|
59
|
+
description: repoName,
|
|
60
|
+
head: getHeadConfig(config, GITHUB_PAGE_URL),
|
|
61
|
+
ignoreDeadLinks: true,
|
|
62
|
+
lang: 'zh-Hans',
|
|
63
|
+
lastUpdated: false,
|
|
64
|
+
markdown: getMarkdownConfig(),
|
|
65
|
+
sitemap: {
|
|
66
|
+
hostname: GITHUB_PAGE_URL,
|
|
67
|
+
lastmodDateOnly: false,
|
|
68
|
+
},
|
|
69
|
+
themeConfig: getThemeConfig(config),
|
|
70
|
+
title: repoName,
|
|
71
|
+
srcExclude: IGNORE_LIST,
|
|
72
|
+
vite: {
|
|
73
|
+
plugins: [
|
|
74
|
+
buildProgressPlugin() as any,
|
|
75
|
+
updateConfigPlugin() as any,
|
|
76
|
+
renameNotePlugin() as any,
|
|
77
|
+
getNoteByConfigIdPlugin() as any,
|
|
78
|
+
...(overrideVite?.plugins || []),
|
|
79
|
+
],
|
|
80
|
+
server: {
|
|
81
|
+
watch: {
|
|
82
|
+
ignored: IGNORE_LIST,
|
|
83
|
+
},
|
|
84
|
+
...overrideVite?.server,
|
|
85
|
+
},
|
|
86
|
+
css: {
|
|
87
|
+
preprocessorOptions: {
|
|
88
|
+
scss: {
|
|
89
|
+
silenceDeprecations: ['legacy-js-api'],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
...overrideVite?.css,
|
|
93
|
+
},
|
|
94
|
+
build: {
|
|
95
|
+
chunkSizeWarningLimit: 1000,
|
|
96
|
+
...overrideVite?.build,
|
|
97
|
+
},
|
|
98
|
+
define: {
|
|
99
|
+
__TNOTES_REPO_NAME__: JSON.stringify(config.repoName),
|
|
100
|
+
__TNOTES_AUTHOR__: JSON.stringify(config.author),
|
|
101
|
+
__TNOTES_IGNORE_DIRS__: JSON.stringify(config.ignore_dirs),
|
|
102
|
+
__TNOTES_ROOT_ITEM__: JSON.stringify(config.root_item),
|
|
103
|
+
...overrideVite?.define,
|
|
104
|
+
},
|
|
105
|
+
resolve: {
|
|
106
|
+
dedupe: ['vue', 'vitepress'],
|
|
107
|
+
...overrideVite?.resolve,
|
|
108
|
+
},
|
|
109
|
+
optimizeDeps: {
|
|
110
|
+
include: [
|
|
111
|
+
// VitePress 内部 CJS 依赖 —— 需要 Vite 预构建为 ESM
|
|
112
|
+
'vitepress > @vscode/markdown-it-katex',
|
|
113
|
+
'vitepress > @braintree/sanitize-url',
|
|
114
|
+
'vitepress > dayjs',
|
|
115
|
+
'vitepress > dayjs/plugin/utc',
|
|
116
|
+
'vitepress > dayjs/plugin/localizedFormat',
|
|
117
|
+
],
|
|
118
|
+
...overrideVite?.optimizeDeps,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
transformPageData(pageData, ctx) {
|
|
122
|
+
// 为笔记页面注入原始 Markdown 内容(用于一键复制功能)
|
|
123
|
+
if (/^notes\/\d{4}/.test(pageData.relativePath)) {
|
|
124
|
+
const fullPath = path.resolve(rootPath, pageData.relativePath)
|
|
125
|
+
try {
|
|
126
|
+
pageData.frontmatter.rawContent = fs.readFileSync(fullPath, 'utf-8')
|
|
127
|
+
} catch {
|
|
128
|
+
pageData.frontmatter.rawContent = null
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// 执行外部覆盖的 transformPageData(如有)
|
|
132
|
+
if (typeof overrideTransformPageData === 'function') {
|
|
133
|
+
return overrideTransformPageData(pageData, ctx)
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
router: {
|
|
137
|
+
prefetchLinks: false,
|
|
138
|
+
},
|
|
139
|
+
...restOverrides,
|
|
140
|
+
})
|
|
141
|
+
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* .vitepress/config/constants.ts
|
|
3
|
-
*
|
|
4
|
-
* 常量配置 - 从运行时配置派生,不再硬编码相对路径 import
|
|
5
|
-
*/
|
|
6
|
-
import type { TNotesConfig } from '../../types'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 获取忽略的文件和目录列表
|
|
10
|
-
*/
|
|
11
|
-
export function getIgnoreList(config: TNotesConfig): string[] {
|
|
12
|
-
return [...config.ignore_dirs.map((dir: string) => `**/${dir}/**`)]
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 获取 GitHub Pages URL
|
|
17
|
-
*/
|
|
18
|
-
export function getGithubPageUrl(config: TNotesConfig): string {
|
|
19
|
-
return (
|
|
20
|
-
'https://' +
|
|
21
|
-
config.author.toLowerCase() +
|
|
22
|
-
'.github.io/' +
|
|
23
|
-
config.repoName +
|
|
24
|
-
'/'
|
|
25
|
-
)
|
|
26
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* .vitepress/config/constants.ts
|
|
3
|
+
*
|
|
4
|
+
* 常量配置 - 从运行时配置派生,不再硬编码相对路径 import
|
|
5
|
+
*/
|
|
6
|
+
import type { TNotesConfig } from '../../types'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 获取忽略的文件和目录列表
|
|
10
|
+
*/
|
|
11
|
+
export function getIgnoreList(config: TNotesConfig): string[] {
|
|
12
|
+
return [...config.ignore_dirs.map((dir: string) => `**/${dir}/**`)]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 获取 GitHub Pages URL
|
|
17
|
+
*/
|
|
18
|
+
export function getGithubPageUrl(config: TNotesConfig): string {
|
|
19
|
+
return (
|
|
20
|
+
'https://' +
|
|
21
|
+
config.author.toLowerCase() +
|
|
22
|
+
'.github.io/' +
|
|
23
|
+
config.repoName +
|
|
24
|
+
'/'
|
|
25
|
+
)
|
|
26
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* .vitepress/config/head.config.ts
|
|
3
|
-
*
|
|
4
|
-
* HTML head 标签配置
|
|
5
|
-
*/
|
|
6
|
-
import { HeadConfig } from 'vitepress'
|
|
7
|
-
import type { TNotesConfig } from '../../types'
|
|
8
|
-
|
|
9
|
-
export function getHeadConfig(config: TNotesConfig, githubPageUrl: string): HeadConfig[] {
|
|
10
|
-
const head: HeadConfig[] = [
|
|
11
|
-
[
|
|
12
|
-
'meta',
|
|
13
|
-
{
|
|
14
|
-
name: 'keywords',
|
|
15
|
-
content: config.keywords.join(', '),
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
['meta', { name: 'author', content: config.author }],
|
|
19
|
-
['link', { rel: 'canonical', href: githubPageUrl }],
|
|
20
|
-
['link', { rel: 'icon', href: githubPageUrl + 'favicon.ico' }],
|
|
21
|
-
['link', { rel: 'preconnect', href: 'https://fonts.googleapis.com' }],
|
|
22
|
-
]
|
|
23
|
-
|
|
24
|
-
return head
|
|
25
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* .vitepress/config/head.config.ts
|
|
3
|
+
*
|
|
4
|
+
* HTML head 标签配置
|
|
5
|
+
*/
|
|
6
|
+
import { HeadConfig } from 'vitepress'
|
|
7
|
+
import type { TNotesConfig } from '../../types'
|
|
8
|
+
|
|
9
|
+
export function getHeadConfig(config: TNotesConfig, githubPageUrl: string): HeadConfig[] {
|
|
10
|
+
const head: HeadConfig[] = [
|
|
11
|
+
[
|
|
12
|
+
'meta',
|
|
13
|
+
{
|
|
14
|
+
name: 'keywords',
|
|
15
|
+
content: config.keywords.join(', '),
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
['meta', { name: 'author', content: config.author }],
|
|
19
|
+
['link', { rel: 'canonical', href: githubPageUrl }],
|
|
20
|
+
['link', { rel: 'icon', href: githubPageUrl + 'favicon.ico' }],
|
|
21
|
+
['link', { rel: 'preconnect', href: 'https://fonts.googleapis.com' }],
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
return head
|
|
25
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* .vitepress/config/_index.ts
|
|
3
|
-
*
|
|
4
|
-
* 配置模块统一导出
|
|
5
|
-
*/
|
|
6
|
-
export { getIgnoreList, getGithubPageUrl } from './constants'
|
|
7
|
-
export { getHeadConfig } from './head.config'
|
|
8
|
-
export { getMarkdownConfig } from './markdown.config'
|
|
9
|
-
export { getThemeConfig } from './theme.config'
|
|
1
|
+
/**
|
|
2
|
+
* .vitepress/config/_index.ts
|
|
3
|
+
*
|
|
4
|
+
* 配置模块统一导出
|
|
5
|
+
*/
|
|
6
|
+
export { getIgnoreList, getGithubPageUrl } from './constants'
|
|
7
|
+
export { getHeadConfig } from './head.config'
|
|
8
|
+
export { getMarkdownConfig } from './markdown.config'
|
|
9
|
+
export { getThemeConfig } from './theme.config'
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* .vitepress/config/markdown-it.d.ts
|
|
3
|
-
*
|
|
4
|
-
* 第三方库类型声明
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
declare module 'markdown-it-container' {
|
|
8
|
-
import { PluginWithOptions } from 'markdown-it'
|
|
9
|
-
const markdownItContainer: PluginWithOptions<any>
|
|
10
|
-
export default markdownItContainer
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
declare module 'markdown-it-link-attributes' {
|
|
14
|
-
import { PluginWithOptions } from 'markdown-it'
|
|
15
|
-
const markdownItLinkAttributes: PluginWithOptions<any>
|
|
16
|
-
export default markdownItLinkAttributes
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
declare module 'markdown-it-task-lists' {
|
|
20
|
-
import { PluginWithOptions } from 'markdown-it'
|
|
21
|
-
const markdownItTaskLists: PluginWithOptions<any>
|
|
22
|
-
export default markdownItTaskLists
|
|
23
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* .vitepress/config/markdown-it.d.ts
|
|
3
|
+
*
|
|
4
|
+
* 第三方库类型声明
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
declare module 'markdown-it-container' {
|
|
8
|
+
import { PluginWithOptions } from 'markdown-it'
|
|
9
|
+
const markdownItContainer: PluginWithOptions<any>
|
|
10
|
+
export default markdownItContainer
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare module 'markdown-it-link-attributes' {
|
|
14
|
+
import { PluginWithOptions } from 'markdown-it'
|
|
15
|
+
const markdownItLinkAttributes: PluginWithOptions<any>
|
|
16
|
+
export default markdownItLinkAttributes
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module 'markdown-it-task-lists' {
|
|
20
|
+
import { PluginWithOptions } from 'markdown-it'
|
|
21
|
+
const markdownItTaskLists: PluginWithOptions<any>
|
|
22
|
+
export default markdownItTaskLists
|
|
23
|
+
}
|