-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
45 lines (38 loc) · 872 Bytes
/
example.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
// #### Import
// remark-usage-ignore-next 2
import stubbedFs from 'mock-fs';
// eslint-disable-next-line import/order
import fs from 'node:fs';
import {remark} from 'remark';
import injectBadges from './lib/index.js';
// remark-usage-ignore-next
stubbedFs();
// #### Execute
remark()
.use(
injectBadges,
{
contribution: {
badgeKey: {
text: 'alt-text for the badge image',
link: 'url for badge link',
img: 'badge image url'
}
}
}
)
.process(
`# project-name
<!--status-badges start -->
<!--status-badges end -->
<!--consumer-badges start -->
<!--consumer-badges end -->
<!--contribution-badges start -->
<!--contribution-badges end -->
`,
(err, file) => {
fs.writeFileSync(`${process.cwd()}/README.md`, `${file}`);
}
);
// remark-usage-ignore-next
stubbedFs.restore();