markdown-to-html-cli 3.2.11 → 3.2.14
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.
- package/README.md +1 -10
- package/lib/create.js +54 -92
- package/lib/create.js.map +1 -1
- package/lib/index.d.ts +0 -9
- package/lib/index.js.map +1 -1
- package/lib/nodes/copy.d.ts +2 -0
- package/lib/nodes/copy.js +76 -1
- package/lib/nodes/copy.js.map +1 -1
- package/lib/nodes/dark-mode.d.ts +6 -0
- package/lib/nodes/dark-mode.js +29 -0
- package/lib/nodes/dark-mode.js.map +1 -0
- package/lib/nodes/{githubCornersFork.d.ts → github-corners-fork.d.ts} +0 -0
- package/lib/nodes/github-corners-fork.js +122 -0
- package/lib/nodes/github-corners-fork.js.map +1 -0
- package/lib/nodes/{githubCorners.d.ts → github-corners.d.ts} +1 -1
- package/lib/nodes/github-corners.js +110 -0
- package/lib/nodes/github-corners.js.map +1 -0
- package/lib/nodes/markdown-style.d.ts +2 -0
- package/lib/nodes/markdown-style.js +1045 -0
- package/lib/nodes/markdown-style.js.map +1 -0
- package/package.json +7 -16
- package/src/cli.ts +5 -0
- package/src/create.ts +101 -0
- package/src/index.ts +113 -0
- package/src/nodes/copy.ts +148 -0
- package/src/nodes/dark-mode.ts +31 -0
- package/{github-fork-ribbon.css → src/nodes/github-corners-fork.ts} +38 -1
- package/src/nodes/github-corners.ts +116 -0
- package/src/nodes/markdown-style.ts +1047 -0
- package/src/nodes/octiconLink.ts +12 -0
- package/src/utils.ts +50 -0
- package/github.css +0 -930
- package/lib/nodes/githubCorners.js +0 -59
- package/lib/nodes/githubCorners.js.map +0 -1
- package/lib/nodes/githubCornersFork.js +0 -20
- package/lib/nodes/githubCornersFork.js.map +0 -1
package/src/utils.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { RunArgvs, MDToHTMLOptions } from './';
|
|
4
|
+
|
|
5
|
+
export type Options = Omit<RunArgvs, '_'>
|
|
6
|
+
|
|
7
|
+
export function formatConfig(opts: Options) {
|
|
8
|
+
let options = { ...opts, document: { title: opts.title, meta: [], link: [] } } as MDToHTMLOptions;
|
|
9
|
+
const projectPkg = path.resolve(process.cwd(), opts.config || 'package.json');
|
|
10
|
+
let pgkData: any = {};
|
|
11
|
+
if (fs.existsSync(projectPkg)) {
|
|
12
|
+
pgkData = fs.readJSONSync(projectPkg);
|
|
13
|
+
if (pgkData.name && !options.document.title) {
|
|
14
|
+
options.document.title = pgkData.name;
|
|
15
|
+
}
|
|
16
|
+
if (pgkData.repository && !opts['github-corners']) {
|
|
17
|
+
opts['github-corners'] = typeof pgkData.repository === 'string' ? pgkData.repository : pgkData.repository.url;
|
|
18
|
+
}
|
|
19
|
+
if (pgkData['markdown-to-html']) {
|
|
20
|
+
const mth = pgkData['markdown-to-html'] as MDToHTMLOptions;
|
|
21
|
+
const { title, meta, link } = options.document;
|
|
22
|
+
options = { ...options, ...mth, document: { title, meta, link, ...mth.document } }
|
|
23
|
+
if (mth['github-corners']) {
|
|
24
|
+
opts['github-corners'] = mth['github-corners'];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (opts['github-corners']) {
|
|
29
|
+
opts['github-corners'] = opts['github-corners'].replace(/^git[+]/, '')
|
|
30
|
+
}
|
|
31
|
+
if (Array.isArray(options.document.link) && options.favicon) {
|
|
32
|
+
options.document.link.push({ rel: 'icon', href: options.favicon, type: 'image/x-icon' });
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(options.document.meta)) {
|
|
35
|
+
if (options.description) {
|
|
36
|
+
options.document.meta.push({ description: options.description });
|
|
37
|
+
} else if (pgkData.description) {
|
|
38
|
+
options.document.meta.push({ description: pgkData.description });
|
|
39
|
+
}
|
|
40
|
+
if (options.keywords) {
|
|
41
|
+
options.document.meta.push({ keywords: options.keywords });
|
|
42
|
+
} else if (pgkData.keywords && Array.isArray(pgkData.keywords)) {
|
|
43
|
+
options.document.meta.push({ keywords: pgkData.keywords.join(',') });
|
|
44
|
+
}
|
|
45
|
+
if (typeof options.author === 'string') {
|
|
46
|
+
options.document.meta.push({ author: options.author });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return options;
|
|
50
|
+
}
|