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";
const cli = yargs(process.argv.slice(2))
.config("config", function (path) {
return JSON.parse(readFileSync(path))
})
.scriptName("gmi-web")
.command("$0 [files..]", "Convert text/gemini to text/html.", (yargs) =>
yargs
@ -88,7 +91,6 @@ const argv = cli
.group(["image", "audio", "video"], "Inline Media:")
.alias("html", "language")
.alias("html", "lang")
.config()
.showHelpOnFail(true)
.help().argv;
@ -98,6 +100,7 @@ if (argv.css === "gmi.css") {
if (argv[key]) {
style += `--${key}: ${argv[key]};`;
}
return style
}, styles);
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;}";
export function head(options) {
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 !== "" ? `<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>${
!options.description
? ""