Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 3x 7x 7x 1x 6x 3x 7x 2x 5x 1x 7x 1x 7x | import fs from 'fs-extra';
import path from 'path';
import { type RunArgvs, type MDToHTMLOptions } from './index.js';
export type Options = Omit<RunArgvs, '_'>
export function formatConfig(opts: Options) {
let options = { ...opts } as MDToHTMLOptions;
Eif (!options.document) {
options.document = { title: opts.title, meta: [], link: [], style: [] }
}
const projectPkg = path.resolve(process.cwd(), opts.config || 'package.json');
let pgkData: any = {};
Eif (fs.existsSync(projectPkg)) {
pgkData = fs.readJSONSync(projectPkg);
if (pgkData['markdown-to-html']) {
const mth = pgkData['markdown-to-html'] as MDToHTMLOptions;
const { title, meta, link } = options.document;
options = { ...options, ...mth, document: { ...options.document, title, meta, link, ...mth.document } }
} else E{
options.reurls = { ...options.reurls, ...pgkData.reurls }
options.document = { ...options.document, ...pgkData.document }
}
options.document.title = options.document.title ?? pgkData.name;
options['github-corners'] = opts['github-corners'] ?? options['github-corners'] ?? (
typeof pgkData.repository === 'string' ? pgkData.repository : (typeof pgkData.repository === 'object' && pgkData.repository?.url ? pgkData.repository.url : undefined)
);
}
Iif (opts['github-corners'] && typeof opts['github-corners'] === 'string') {
options['github-corners'] = opts['github-corners'].replace(/^git[+]/, '')
}
if (Array.isArray(options.document.link) && options.favicon) {
options.document.link.push({ rel: 'icon', href: options.favicon, type: 'image/x-icon' });
}
Eif (Array.isArray(options.document.meta)) {
if (options.description) {
options.document.meta.push({ description: options.description });
} else if (pgkData.description) {
options.document.meta.push({ description: pgkData.description });
}
if (options.keywords) {
options.document.meta.push({ keywords: options.keywords });
} else if (pgkData.keywords && Array.isArray(pgkData.keywords)) {
options.document.meta.push({ keywords: pgkData.keywords.join(',') });
}
if (typeof options.author === 'string') {
options.document.meta.push({ author: options.author });
}
}
return options;
} |