@@ -40,60 +40,73 @@ But the options don't stop there. We have more options to configure the plugin t
40
40
41
41
``` typescript twoslash
42
42
import type {
43
- Commit , RewritePathsBy
43
+ Commit , CommitToStringHandler , CommitToStringsHandler , RewritePathsBy
44
44
} from ' @nolebase/vitepress-plugin-git-changelog/vite'
45
45
// ---cut---
46
46
interface Options {
47
+ /**
48
+ * The current working directory in which to search files.
49
+ *
50
+ * @default process.cwd()
51
+ */
52
+ cwd? : string
47
53
/**
48
- * When fetching git logs, what directories should be included?
54
+ * When fetching git logs, what files should be included?
55
+ *
56
+ * @default [' ** /*.md', '!node_modules']
49
57
*/
50
- includeDirs ? : string []
58
+ include ? : string []
51
59
/**
52
60
* Your repository URL.
53
61
* Yes, you can dynamically generate it.
54
62
*
55
63
* @default ' https://github.com/example/example'
56
64
*/
57
- repoURL? : string | (( commit : Commit ) => string )
65
+ repoURL? : string | CommitToStringHandler
58
66
/**
59
67
* A function to get the release tag URL.
60
68
*
61
69
* @default (commit) => `${commit.repo_url}/releases/tag/${commit.tag}`
62
70
*/
63
- getReleaseTagURL? : (commit : Commit ) => string
71
+ getReleaseTagURL? : CommitToStringHandler
72
+ /**
73
+ * A function to get the release tags URL.
74
+ *
75
+ * @default (commit) => commit.tags?.map(tag => `${commit.repo_url}/releases/tag/${tag}`)
76
+ */
77
+ getReleaseTagsURL? : CommitToStringsHandler
64
78
/**
65
79
* A function to get the commit URL.
66
80
*
67
81
* @default (commit) => `${commit.repo_url}/commit/${commit.hash}`
68
82
*/
69
- getCommitURL? : ( commit : Commit ) => string
83
+ getCommitURL? : CommitToStringHandler
70
84
/**
71
- * A map that contains rewrite rules of paths.
72
- *
73
- * This is quite useful when you have your pages in a different directory than the base url after deployed since the
74
- * data will be calculated again on the client side.
85
+ * Rules to rewrite paths by patterns.
75
86
*
76
- * For example:
77
- * - We have a page at `docs/pages/en/integrations/page.md`
78
- * - And we will deploy it to `https://example.com/en/integrations/page`
87
+ * This can be quite useful when your pages are in different directories,
88
+ * or when they are generated at runtime according to path.ts.
79
89
*
80
- * Then you can set the rewrite paths like this:
81
- * ```json
82
- * {
83
- * "docs/": ""
84
- * }
85
- * ```
90
+ * Since the plugin matches the git information for each page by comparing the local path,
91
+ * you can override the local file path to `vitepress.useData.page.value.filePath` with this option.
86
92
*
87
- * This will rewrite the path to `en/integrations/page.md`
88
- * Which is the correct path for the deployed page and runtime scripts to work properly.
93
+ * @example
89
94
*
90
- * Note: in runtime, which is client side, the final extension will be replaced with `.md` if the extension is `.html`.
91
- */
92
- rewritePaths? : Record <string , string >
93
- /**
94
- * Rules to rewrite paths by patterns.
95
+ * ```typescript
96
+ * GitChangelog({
97
+ * rewritePathsBy: {
98
+ * handler: (_commit, path) => {
99
+ * if (path) {
100
+ * // path: packages/characters/src/lib1.ts
101
+ * if (path.startsWith('packages/characters/src/') && !path.includes('index.ts'))
102
+ * return `${path.replace('packages/characters/src/', '').slice(0, -3)}.md`
103
+ * }
104
+ * return path
105
+ * },
106
+ * },
107
+ * })
108
+ * ```
95
109
*
96
- * Same as `rewritePaths`, but it can be a function that returns a promise or plain value.
97
110
* Besides that, we offer some built-in handlers to rewrite paths by patterns:
98
111
*
99
112
* - `rewritePathsByRewritingExtension(from: string, to: string)`: to rewrite paths by rewriting the extension.
@@ -112,17 +125,12 @@ interface Options {
112
125
* ```
113
126
*
114
127
* @see rewritePathsByRewritingExtension
115
- *
116
128
*/
117
129
rewritePathsBy? : RewritePathsBy
118
130
/**
119
131
* The maximum number of git logs to fetch.
120
132
*/
121
133
maxGitLogCount? : number
122
- /**
123
- * The maximum number of concurrent processes to fetch git logs.
124
- */
125
- maxConcurrentProcesses? : number
126
134
}
127
135
```
128
136
0 commit comments