Implemented markdown preview
This commit is contained in:
parent
d5ab483e9d
commit
e4972b54d0
9 changed files with 957 additions and 183 deletions
|
@ -1,21 +0,0 @@
|
|||
"use strict"
|
||||
|
||||
import "dotenv/config"
|
||||
|
||||
import clipboard from "clipboardy"
|
||||
|
||||
if (process.argv.length !== 3 || !process.argv[2].match(/http(s)?:\/\//)) {
|
||||
console.info("Usage: node copy-link.js selectedText")
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
var text = process.argv[2]
|
||||
|
||||
if (process.env.LOCALHOST_PROXY) {
|
||||
text = text.replace(
|
||||
"https://raw.githubusercontent.com/sunknudsen/privacy-guides/master",
|
||||
process.env.LOCALHOST_PROXY
|
||||
)
|
||||
}
|
||||
|
||||
clipboard.write(text)
|
18
tasks/preview-markdown.js
Normal file
18
tasks/preview-markdown.js
Normal 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}`)
|
||||
}
|
26
tasks/proxify-link.js
Normal file
26
tasks/proxify-link.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
"use strict"
|
||||
|
||||
import "dotenv/config"
|
||||
import clipboard from "clipboardy"
|
||||
|
||||
if (process.argv.length !== 3 || !process.argv[2].match(/http(s)?:\/\//)) {
|
||||
console.info("Usage: node copy-link.js selectedText")
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (
|
||||
process.env.REPO === undefined ||
|
||||
process.env.LOCALHOST_PROXY === undefined
|
||||
) {
|
||||
console.info("Missing environment variables")
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const selectedText = process.argv[2]
|
||||
|
||||
clipboard.write(
|
||||
selectedText.replace(
|
||||
`https://raw.githubusercontent.com/${process.env.REPO}/master`,
|
||||
process.env.LOCALHOST_PROXY
|
||||
)
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue