Implemented markdown preview

This commit is contained in:
Sun Knudsen 2022-03-14 08:53:50 -04:00
parent d5ab483e9d
commit e4972b54d0
No known key found for this signature in database
GPG key ID: 02C43AD072D57783
9 changed files with 957 additions and 183 deletions

18
tasks/preview-markdown.js Normal file
View file

@ -0,0 +1,18 @@
"use strict"
import "dotenv/config"
import open from "open"
if (process.argv.length < 3 || !process.argv[2].match(/\.md$/)) {
console.info("Usage: node open-preview.js file")
process.exit(1)
}
const file = process.argv[2]
const options = process.argv[3]
if (options === "use-proxy") {
open(`${process.env.LOCALHOST_PROXY}/${file}`)
} else {
open(`http://localhost:${process.env.PORT ?? 8080}/${file}`)
}