@tnotesjs/core 0.0.6 → 0.0.8

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.
Files changed (116) hide show
  1. package/README.md +87 -84
  2. package/dist/{chunk-JDVN2QYW.js → chunk-JUMVJKWV.js} +615 -614
  3. package/dist/cli/index.js +125 -125
  4. package/dist/vitepress/config/index.js +184 -210
  5. package/package.json +15 -3
  6. package/types/config.ts +61 -61
  7. package/types/index.ts +11 -11
  8. package/types/note.ts +33 -33
  9. package/types/shims.d.ts +3 -4
  10. package/vitepress/assets/icons/icon__check.svg +3 -3
  11. package/vitepress/assets/icons/icon__clipboard.svg +7 -7
  12. package/vitepress/assets/icons/icon__close.svg +1 -1
  13. package/vitepress/assets/icons/icon__collapse.svg +1 -1
  14. package/vitepress/assets/icons/icon__confirm.svg +1 -1
  15. package/vitepress/assets/icons/icon__copy.svg +4 -4
  16. package/vitepress/assets/icons/icon__focus.svg +1 -1
  17. package/vitepress/assets/icons/icon__fold.svg +3 -3
  18. package/vitepress/assets/icons/icon__folder.svg +1 -1
  19. package/vitepress/assets/icons/icon__fullscreen.svg +1 -1
  20. package/vitepress/assets/icons/icon__fullscreen_exit.svg +1 -1
  21. package/vitepress/assets/icons/icon__github.svg +3 -3
  22. package/vitepress/assets/icons/icon__mindmap.svg +1 -1
  23. package/vitepress/assets/icons/icon__next.svg +1 -1
  24. package/vitepress/assets/icons/icon__number_gray.svg +1 -1
  25. package/vitepress/assets/icons/icon__number_purple.svg +1 -1
  26. package/vitepress/assets/icons/icon__prev.svg +1 -1
  27. package/vitepress/assets/icons/icon__restore.svg +1 -1
  28. package/vitepress/assets/icons/icon__rotate.svg +4 -4
  29. package/vitepress/assets/icons/icon__search.svg +1 -1
  30. package/vitepress/assets/icons/icon__sidebar_collapsed.svg +1 -1
  31. package/vitepress/assets/icons/icon__sidebar_opened.svg +1 -1
  32. package/vitepress/assets/icons/icon__totop.svg +5 -5
  33. package/vitepress/assets/icons/icon__vscode.svg +5 -5
  34. package/vitepress/assets/icons/icon__zoom_fit.svg +1 -1
  35. package/vitepress/assets/icons/icon__zoom_in.svg +1 -1
  36. package/vitepress/assets/icons/icon__zoom_out.svg +1 -1
  37. package/vitepress/assets/icons/icon__zoom_reset.svg +1 -1
  38. package/vitepress/assets/icons/index.ts +38 -38
  39. package/vitepress/components/BilibiliOutsidePlayer/BilibiliOutsidePlayer.vue +20 -20
  40. package/vitepress/components/CodeBlockFullscreen/CodeBlockFullscreen.vue +373 -372
  41. package/vitepress/components/CodeBlockFullscreen/index.ts +115 -114
  42. package/vitepress/components/CodeBlockFullscreen/styles.css +64 -64
  43. package/vitepress/components/Discussions/Discussions.module.scss +32 -32
  44. package/vitepress/components/Discussions/Discussions.vue +211 -210
  45. package/vitepress/components/EnWordList/EnWordList.module.scss +124 -124
  46. package/vitepress/components/EnWordList/EnWordList.vue +543 -542
  47. package/vitepress/components/EnWordList/RightClickMenu.module.scss +22 -22
  48. package/vitepress/components/EnWordList/RightClickMenu.vue +66 -66
  49. package/vitepress/components/Footprints/Footprints.module.scss +93 -93
  50. package/vitepress/components/Footprints/Footprints.vue +377 -377
  51. package/vitepress/components/Layout/AboutModal.module.scss +233 -233
  52. package/vitepress/components/Layout/AboutModal.vue +105 -105
  53. package/vitepress/components/Layout/AboutPanel.vue +270 -265
  54. package/vitepress/components/Layout/ContentCollapse.vue +603 -602
  55. package/vitepress/components/Layout/CustomSidebar.vue +608 -605
  56. package/vitepress/components/Layout/DocBeforeControls.vue +149 -139
  57. package/vitepress/components/Layout/DocFooter.vue +233 -232
  58. package/vitepress/components/Layout/ImagePreview.module.scss +201 -201
  59. package/vitepress/components/Layout/ImagePreview.vue +281 -280
  60. package/vitepress/components/Layout/Layout.module.scss +661 -661
  61. package/vitepress/components/Layout/Layout.vue +539 -542
  62. package/vitepress/components/Layout/NoteStatus.vue +140 -139
  63. package/vitepress/components/Layout/SidebarItems.vue +267 -262
  64. package/vitepress/components/Layout/SidebarNavBefore.vue +92 -92
  65. package/vitepress/components/Layout/Swiper.vue +167 -167
  66. package/vitepress/components/Layout/ToggleFullContent.module.scss +11 -11
  67. package/vitepress/components/Layout/ToggleFullContent.vue +35 -34
  68. package/vitepress/components/Layout/ToggleSidebar.module.scss +11 -11
  69. package/vitepress/components/Layout/ToggleSidebar.vue +36 -35
  70. package/vitepress/components/Layout/composables/useCollapseControl.ts +88 -88
  71. package/vitepress/components/Layout/composables/useNoteConfig.ts +119 -121
  72. package/vitepress/components/Layout/composables/useNoteSave.ts +173 -172
  73. package/vitepress/components/Layout/composables/useNoteValidation.ts +85 -85
  74. package/vitepress/components/Layout/composables/useRedirect.ts +113 -110
  75. package/vitepress/components/Layout/composables/useVSCodeIntegration.ts +86 -83
  76. package/vitepress/components/Layout/homeReadme.data.ts +124 -124
  77. package/vitepress/components/LoadingPage/LoadingPage.vue +192 -192
  78. package/vitepress/components/MarkMap/MarkMap.module.scss +159 -159
  79. package/vitepress/components/MarkMap/MarkMap.vue +405 -404
  80. package/vitepress/components/Mermaid/Mermaid.module.scss +275 -275
  81. package/vitepress/components/Mermaid/Mermaid.vue +365 -363
  82. package/vitepress/components/NotesTable/NotesTable.module.scss +77 -77
  83. package/vitepress/components/NotesTable/NotesTable.vue +98 -97
  84. package/vitepress/components/NotesTable/README.md +67 -67
  85. package/vitepress/components/Settings/Settings.module.scss +433 -433
  86. package/vitepress/components/Settings/Settings.vue +306 -305
  87. package/vitepress/components/SidebarCard/MindMapView.vue +484 -483
  88. package/vitepress/components/SidebarCard/NotesTrendChart.vue +108 -108
  89. package/vitepress/components/SidebarCard/SidebarCard.vue +946 -948
  90. package/vitepress/components/Tooltip/Tooltip.vue +70 -70
  91. package/vitepress/components/constants.ts +91 -91
  92. package/vitepress/components/notesConfig.data.ts +73 -73
  93. package/vitepress/components/sidebar.data.ts +59 -59
  94. package/vitepress/components/tnotes-config.data.ts +21 -21
  95. package/vitepress/components/utils.ts +26 -26
  96. package/vitepress/config/index.ts +160 -146
  97. package/vitepress/configs/constants.ts +26 -26
  98. package/vitepress/configs/head.config.ts +25 -24
  99. package/vitepress/configs/index.ts +9 -9
  100. package/vitepress/configs/markdown-it.d.ts +23 -20
  101. package/vitepress/configs/markdown.config.ts +366 -365
  102. package/vitepress/configs/theme.config.ts +108 -108
  103. package/vitepress/plugins/buildProgressPlugin.ts +434 -470
  104. package/vitepress/plugins/getNoteByConfigIdPlugin.ts +107 -106
  105. package/vitepress/plugins/renameNotePlugin.ts +60 -59
  106. package/vitepress/plugins/updateConfigPlugin.ts +63 -62
  107. package/vitepress/theme/index.ts +95 -93
  108. package/vitepress/theme/styles/base.scss +50 -50
  109. package/vitepress/theme/styles/components/404.scss +31 -31
  110. package/vitepress/theme/styles/components/collapse.scss +175 -175
  111. package/vitepress/theme/styles/components/markmap.scss +101 -101
  112. package/vitepress/theme/styles/components/swiper.scss +255 -255
  113. package/vitepress/theme/styles/index.scss +25 -25
  114. package/vitepress/theme/styles/layout.scss +62 -62
  115. package/vitepress/theme/styles/utilities.scss +39 -39
  116. 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,148 +1,162 @@
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'
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
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'
13
+
14
+ import {
15
+ getIgnoreList,
16
+ getGithubPageUrl,
17
+ getHeadConfig,
18
+ getMarkdownConfig,
19
+ getThemeConfig,
20
+ } from '../configs'
24
21
  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
- const raw = fs.readFileSync(fullPath, 'utf-8')
127
- // 防止 raw 中的 `</script>` 字面量在被 JSON.stringify 后注入到
128
- // `<script>…</script>` 块时提前闭合脚本块(导致 Vue SFC 解析报
129
- // "Invalid end tag")。在源串里把 `</` 拆开即可,复制时仍是原文。
130
- pageData.frontmatter.rawContent = raw.replace(
131
- /<\/(script)/gi,
132
- '<\\/$1',
133
- )
134
- } catch {
135
- pageData.frontmatter.rawContent = null
136
- }
137
- }
138
- // 执行外部覆盖的 transformPageData(如有)
139
- if (typeof overrideTransformPageData === 'function') {
140
- return overrideTransformPageData(pageData, ctx)
141
- }
142
- },
143
- router: {
144
- prefetchLinks: false,
145
- },
146
- ...restOverrides,
147
- })
148
- }
22
+ import { getNoteByConfigIdPlugin } from '../plugins/getNoteByConfigIdPlugin'
23
+ import { renameNotePlugin } from '../plugins/renameNotePlugin'
24
+ import { updateConfigPlugin } from '../plugins/updateConfigPlugin'
25
+
26
+ import type { TNotesConfig } from '../../types'
27
+
28
+ /**
29
+ * 读取 .tnotes.json 配置文件
30
+ */
31
+ function loadTNotesConfig(rootPath: string): TNotesConfig {
32
+ const configPath = path.resolve(rootPath, '.tnotes.json')
33
+ const configContent = fs.readFileSync(configPath, 'utf-8')
34
+ return JSON.parse(configContent) as TNotesConfig
35
+ }
36
+
37
+ /**
38
+ * 创建 VitePress 站点配置
39
+ *
40
+ * @param overrides - 可选的覆盖配置,会与默认配置合并
41
+ * @returns VitePress 配置对象
42
+ */
43
+ export function defineNotesConfig(overrides: UserConfig = {}) {
44
+ const rootPath = process.cwd()
45
+ const config = loadTNotesConfig(rootPath)
46
+ const { repoName } = config
47
+
48
+ const IGNORE_LIST = getIgnoreList(config)
49
+ const GITHUB_PAGE_URL = getGithubPageUrl(config)
50
+
51
+ const {
52
+ transformPageData: overrideTransformPageData,
53
+ vite: overrideVite,
54
+ ...restOverrides
55
+ } = overrides
56
+
57
+ return defineConfig({
58
+ appearance: 'dark',
59
+ base: '/' + repoName + '/',
60
+ cleanUrls: true,
61
+ description: repoName,
62
+ head: getHeadConfig(config, GITHUB_PAGE_URL),
63
+ ignoreDeadLinks: true,
64
+ lang: 'zh-Hans',
65
+ lastUpdated: false,
66
+ markdown: getMarkdownConfig(),
67
+ sitemap: {
68
+ hostname: GITHUB_PAGE_URL,
69
+ lastmodDateOnly: false,
70
+ },
71
+ themeConfig: getThemeConfig(config),
72
+ title: repoName,
73
+ srcExclude: IGNORE_LIST,
74
+ vite: {
75
+ plugins: [
76
+ buildProgressPlugin() as any,
77
+ updateConfigPlugin() as any,
78
+ renameNotePlugin() as any,
79
+ getNoteByConfigIdPlugin() as any,
80
+ ...(overrideVite?.plugins || []),
81
+ ],
82
+ server: {
83
+ watch: {
84
+ ignored: IGNORE_LIST,
85
+ },
86
+ ...overrideVite?.server,
87
+ },
88
+ css: {
89
+ preprocessorOptions: {
90
+ scss: {
91
+ silenceDeprecations: ['legacy-js-api'],
92
+ },
93
+ },
94
+ ...overrideVite?.css,
95
+ },
96
+ build: {
97
+ chunkSizeWarningLimit: 1000,
98
+ ...overrideVite?.build,
99
+ },
100
+ define: {
101
+ __TNOTES_REPO_NAME__: JSON.stringify(config.repoName),
102
+ __TNOTES_AUTHOR__: JSON.stringify(config.author),
103
+ __TNOTES_IGNORE_DIRS__: JSON.stringify(config.ignore_dirs),
104
+ __TNOTES_ROOT_ITEM__: JSON.stringify(config.root_item),
105
+ ...overrideVite?.define,
106
+ },
107
+ resolve: {
108
+ dedupe: ['vue', 'vitepress'],
109
+ ...overrideVite?.resolve,
110
+ },
111
+ optimizeDeps: {
112
+ include: [
113
+ // VitePress 内部 CJS 依赖 —— 需要 Vite 预构建为 ESM
114
+ 'vitepress > @vscode/markdown-it-katex',
115
+ 'vitepress > @braintree/sanitize-url',
116
+ 'vitepress > dayjs',
117
+ 'vitepress > dayjs/plugin/utc',
118
+ 'vitepress > dayjs/plugin/localizedFormat',
119
+ ],
120
+ ...overrideVite?.optimizeDeps,
121
+ },
122
+ },
123
+ transformPageData(pageData, ctx) {
124
+ // 为笔记页面注入原始 Markdown 内容(用于一键复制功能)
125
+ //
126
+ // 这里的 rawContent 会被 VitePress 序列化进 SFC 的
127
+ // `<script>export const __pageData = JSON.parse("...")</script>` 块。
128
+ // 如果直接写入原文,原文中的 `<script>` / `</script>` 字面量会被两
129
+ // 类规则误命中:
130
+ // 1. HTML 解析器看到 `</script` 就提前闭合脚本块,触发
131
+ // "Invalid end tag"。
132
+ // 2. VitePress 内部还会用
133
+ // `scriptClientRE = /<script\b[^>]*client\b[^>]*>([^]*?)<\/script>/`
134
+ // 在整段 vueSrc 上扫一遍,匹配到原文里的 `<script src="/client.js">`
135
+ // 之类开标签后会一路吞到真正的 `</script>`。
136
+ //
137
+ // 与其针对每条规则各自做转义(耦合 VitePress 内部实现细节),
138
+ // 不如直接对原文做 base64 编码:base64 字符集仅 `[A-Za-z0-9+/=]`,
139
+ // 不包含 `<` `>`,可彻底规避任何 HTML/正则误匹配。
140
+ // 前端消费时使用 `atob` + `TextDecoder('utf-8')` 还原原文。
141
+ if (/^notes\/\d{4}/.test(pageData.relativePath)) {
142
+ const fullPath = path.resolve(rootPath, pageData.relativePath)
143
+ try {
144
+ const raw = fs.readFileSync(fullPath, 'utf-8')
145
+ pageData.frontmatter.rawContent = Buffer.from(raw, 'utf-8').toString(
146
+ 'base64',
147
+ )
148
+ } catch {
149
+ pageData.frontmatter.rawContent = null
150
+ }
151
+ }
152
+ // 执行外部覆盖的 transformPageData(如有)
153
+ if (typeof overrideTransformPageData === 'function') {
154
+ return overrideTransformPageData(pageData, ctx)
155
+ }
156
+ },
157
+ router: {
158
+ prefetchLinks: false,
159
+ },
160
+ ...restOverrides,
161
+ })
162
+ }
@@ -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,26 @@
1
- /**
2
- * .vitepress/config/head.config.ts
3
- *
4
- * HTML head 标签配置
5
- */
1
+ /**
2
+ * .vitepress/config/head.config.ts
3
+ *
4
+ * HTML head 标签配置
5
+ */
6
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
- }
7
+
8
+ import type { TNotesConfig } from '../../types'
9
+
10
+ export function getHeadConfig(config: TNotesConfig, githubPageUrl: string): HeadConfig[] {
11
+ const head: HeadConfig[] = [
12
+ [
13
+ 'meta',
14
+ {
15
+ name: 'keywords',
16
+ content: config.keywords.join(', '),
17
+ },
18
+ ],
19
+ ['meta', { name: 'author', content: config.author }],
20
+ ['link', { rel: 'canonical', href: githubPageUrl }],
21
+ ['link', { rel: 'icon', href: githubPageUrl + 'favicon.ico' }],
22
+ ['link', { rel: 'preconnect', href: 'https://fonts.googleapis.com' }],
23
+ ]
24
+
25
+ return head
26
+ }
@@ -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,26 @@
1
- /**
2
- * .vitepress/config/markdown-it.d.ts
3
- *
4
- * 第三方库类型声明
5
- */
6
-
7
- declare module 'markdown-it-container' {
1
+ /**
2
+ * .vitepress/config/markdown-it.d.ts
3
+ *
4
+ * 第三方库类型声明
5
+ */
6
+
7
+ declare module 'markdown-it-container' {
8
8
  import { PluginWithOptions } from 'markdown-it'
9
- const markdownItContainer: PluginWithOptions<any>
10
- export default markdownItContainer
11
- }
12
-
13
- declare module 'markdown-it-link-attributes' {
9
+
10
+ const markdownItContainer: PluginWithOptions<any>
11
+ export default markdownItContainer
12
+ }
13
+
14
+ declare module 'markdown-it-link-attributes' {
14
15
  import { PluginWithOptions } from 'markdown-it'
15
- const markdownItLinkAttributes: PluginWithOptions<any>
16
- export default markdownItLinkAttributes
17
- }
18
-
19
- declare module 'markdown-it-task-lists' {
16
+
17
+ const markdownItLinkAttributes: PluginWithOptions<any>
18
+ export default markdownItLinkAttributes
19
+ }
20
+
21
+ declare module 'markdown-it-task-lists' {
20
22
  import { PluginWithOptions } from 'markdown-it'
21
- const markdownItTaskLists: PluginWithOptions<any>
22
- export default markdownItTaskLists
23
- }
23
+
24
+ const markdownItTaskLists: PluginWithOptions<any>
25
+ export default markdownItTaskLists
26
+ }