forked from typicode/jsonplaceholder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
3,114 additions
and
324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Convert to markdown | ||
// use layout to | ||
// create index.html | ||
// create guide.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
const showdown = require("showdown"); | ||
const pupa = require("pupa"); | ||
|
||
function readFile(filename) { | ||
return fs.readFileSync(path.join(__dirname, "templates", filename), "utf-8"); | ||
} | ||
|
||
function render(filename, content) { | ||
fs.writeFileSync( | ||
path.join(__dirname, "public", filename), | ||
pupa(layout, { content }) | ||
); | ||
} | ||
|
||
const layout = readFile("layout.html"); | ||
const index = readFile("index.html"); | ||
|
||
const converter = new showdown.Converter({ simplifiedAutoLink: true }); | ||
const guideMarkdown = readFile("GUIDE.md"); | ||
// const headingRegexp = /^## (.*)$/gm; | ||
// console.log("res", text.match(headingRegexp)); | ||
const guide = converter.makeHtml(guideMarkdown); | ||
|
||
render("index.html", index); | ||
render("guide.html", guide); |
Oops, something went wrong.