forked from JulianCataldo/web-garden
-
Notifications
You must be signed in to change notification settings - Fork 0
/
markdown-magic.ts
64 lines (60 loc) · 1.58 KB
/
markdown-magic.ts
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
63
64
import path from 'path';
import markdownMagic from 'markdown-magic';
import tree from 'markdown-magic-directory-tree';
import vBadge from 'markdown-magic-version-badge';
import install from 'markdown-magic-install-command';
// import template from 'markdown-magic-template';
import pkgJson from 'markdown-magic-package-json';
const config = {
transforms: {
DIRTREE: (content, options, config) =>
tree(
content,
{
...options,
ignore: [
...(options.ignore || []),
'CHANGELOG.md',
'README.md',
'node_modules',
'package.json',
'pnpm-lock.yaml',
'.dev',
'.DS_Store',
],
depth: 1,
},
config,
),
VERSIONBADGE: (content, options, config) =>
vBadge(content, options, config),
INSTALLCMD: (content, options, config) =>
install(
content,
{
client: 'pnpm',
},
config,
)
.replace('--save ', '')
.replace('install', 'i'),
// TEMPLATE: install,
PKGJSON: (content, options, config) =>
pkgJson(
content,
{
...options,
pkg: path.join(path.dirname(config.originalPath), 'package.json'),
},
config,
),
},
};
const markdownPaths = [
path.join(__dirname, 'README.md'),
path.join(__dirname, 'app/*/README.md'),
path.join(__dirname, 'components/*/README.md'),
path.join(__dirname, 'configs/README.md'),
path.join(__dirname, 'demo/README.md'),
];
markdownMagic(markdownPaths, config);