diff --git a/cli.js b/cli.js index 5805467..66c56b6 100755 --- a/cli.js +++ b/cli.js @@ -39,6 +39,12 @@ require("yargs") describe: "The *.gmi files to convert", }) .required("files", true) + .option("language", { + alias: "lang", + required: true, + type: "string", + describe: "Set the document meta language tag", + }) .option("images", { type: "boolean", default: false, @@ -61,6 +67,7 @@ require("yargs") "gmi.css is included by default. Use --no-css to for the bare-minimum "); -const toHTML = (exports.toHTML = (file, options) => ` +const toHTML = (exports.toHTML = (file, options) => { + const tokens = JSON.parse(file.contents.toString("utf8")); + const title = tokens[0].h1; + return ` -${head(file.path, options)} +${head(file.path, title, options)}
-${gemtext(JSON.parse(file.contents.toString("utf8")), options)} +${gemtext(tokens, options)} -`); +`; +}); + module.exports = (options) => (file, cb) => { if (!TOKENS_EXT.test(file.path)) return cb(null); file.contents = Buffer.from(toHTML(file, options)); @@ -25,9 +30,10 @@ module.exports = (options) => (file, cb) => { }; // TODO: meta: language, description, canonical -function head(file, options) { +function head(file, title, options) { return ` + ${ !options.css ? BASE_STYLE @@ -35,7 +41,12 @@ function head(file, options) { path.resolve(__dirname, "./gmi.min.css"), "utf8" )}` + }${ + !options.canonical + ? "" + : `` } +${text}
`; if (href) { - if (inline.images && IMG_EXT.test(href)) + if (images && IMG_EXT.test(href)) return ``; - if (inline.audio && AUDIO_EXT.test(href)) + if (audio && AUDIO_EXT.test(href)) return ``; - if (inline.video && VIDEO_EXT.test(href)) + if (video && VIDEO_EXT.test(href)) return ``; return `${title || href}`;