-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.js
62 lines (52 loc) · 1.48 KB
/
log.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* @Author: 简隐 [email protected]
* @Date: 2024-03-31 19:15:45
* @LastEditors: 简隐 [email protected]
* @LastEditTime: 2024-03-31 23:08:41
* @FilePath: \latest-blogs\log.js
* @Description:
*
* Copyright (c) 2024 by 简隐, All Rights Reserved.
*/
// const gitlog = require("gitlog").default;
import gitlog from 'gitlog'
const options = {
repo: '/',
number: 1000000,
branch: 'master',
fields: ["hash", "abbrevHash", "subject", "authorName", "authorDate", "authorDateRel", "tag"],
execOptions: { maxBuffer: 1000 * 1024 * 10 },
};
export default function GitChangelogMarkdownSection(options) {
let root = ''
return {
name: '@jadeq/vitepress-plugin-markdown-changelog',
// May set to 'pre' since end user may use vitepress wrapped vite plugin to
// specify the plugins, which may cause this plugin to be executed after
// vitepress or the other markdown processing plugins.
enforce: 'pre',
configResolved(config) {
root = config.root ?? ''
},
transform(code, id) {
if (!id.endsWith('.md'))
return code
let path = id.split('docs')
const thislog = gitlog.default({
repo: './',
branch: 'master',
number: 1000000,
file: id,
fields: ["hash", "abbrevHash", "subject", "authorName", "authorDate", "authorDateRel", "tag"],
})
return test(code, id, '文件历史')
},
}
}
function test(code, thislog, title) {
return `${code}
## ${title}
<CA id="thislog">
</CA>
`
}