fix parse config bug

move charset to top of head
This commit is contained in:
Talon Poole 2021-02-12 21:17:00 +00:00
parent 6a11b71497
commit 45e90e61ac
2 changed files with 6 additions and 4 deletions

5
cli.js
View file

@ -8,6 +8,9 @@ import CleanCSS from "clean-css";
import toHTML, { BASE_CSS, html } from "./html.js"; import toHTML, { BASE_CSS, html } from "./html.js";
const cli = yargs(process.argv.slice(2)) const cli = yargs(process.argv.slice(2))
.config("config", function (path) {
return JSON.parse(readFileSync(path))
})
.scriptName("gmi-web") .scriptName("gmi-web")
.command("$0 [files..]", "Convert text/gemini to text/html.", (yargs) => .command("$0 [files..]", "Convert text/gemini to text/html.", (yargs) =>
yargs yargs
@ -88,7 +91,6 @@ const argv = cli
.group(["image", "audio", "video"], "Inline Media:") .group(["image", "audio", "video"], "Inline Media:")
.alias("html", "language") .alias("html", "language")
.alias("html", "lang") .alias("html", "lang")
.config()
.showHelpOnFail(true) .showHelpOnFail(true)
.help().argv; .help().argv;
@ -98,6 +100,7 @@ if (argv.css === "gmi.css") {
if (argv[key]) { if (argv[key]) {
style += `--${key}: ${argv[key]};`; style += `--${key}: ${argv[key]};`;
} }
return style
}, styles); }, styles);
argv.css = new CleanCSS().minify( argv.css = new CleanCSS().minify(

View file

@ -29,11 +29,10 @@ export const BASE_CSS =
"p,a,pre,h1,h2,h3,ul,blockquote,img,audio,video{display:block;max-width:100%;margin:0;padding:0;overflow-wrap:anywhere;}"; "p,a,pre,h1,h2,h3,ul,blockquote,img,audio,video{display:block;max-width:100%;margin:0;padding:0;overflow-wrap:anywhere;}";
export function head(options) { export function head(options) {
return ` return `
<meta charset="${options.charset}">
<meta name="viewport" content="width=device-width,initial-scale=1">
${options.css !== "" ? `<meta name="color-scheme" content="dark light">` : ""} ${options.css !== "" ? `<meta name="color-scheme" content="dark light">` : ""}
${options.css !== "" ? `<style>${options.css}</style>` : ""} ${options.css !== "" ? `<style>${options.css}</style>` : ""}
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta charset="${options.charset}">
<meta language="${options.language}">
<title>${options.title}</title>${ <title>${options.title}</title>${
!options.description !options.description
? "" ? ""