aboutsummaryrefslogtreecommitdiffstats
path: root/server.js
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2021-04-09 13:04:02 +0000
committerterminaldweller <thabogre@gmail.com>2021-04-09 13:04:02 +0000
commita3bc5c5231c476180651aa596ba4aa50fc878290 (patch)
tree79b79a4b7077620f747c8a52f372b3e8b0925232 /server.js
parentInitial commit (diff)
downloadblog-a3bc5c5231c476180651aa596ba4aa50fc878290.tar.gz
blog-a3bc5c5231c476180651aa596ba4aa50fc878290.zip
a simple node express ejs blog
Diffstat (limited to 'server.js')
-rwxr-xr-xserver.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/server.js b/server.js
new file mode 100755
index 0000000..eaf1ac5
--- /dev/null
+++ b/server.js
@@ -0,0 +1,39 @@
+#!/usr/bin/env node
+"use strict";
+
+const express = require("express");
+const path = require("path");
+const fs = require("fs");
+const mitTexMath = require("markdown-it-texmath");
+const mitMulMd = require("markdown-it-multimd-table");
+const mit = require("markdown-it")({ html: true })
+ .enable(["table"])
+ .disable(["strikethrough"])
+ .use(mitTexMath, {
+ engine: require("katex"),
+ delimiters: "gitlab",
+ katexOptions: { macros: { "\\RR": "\\mathbb{R}" } },
+ })
+ .use(mitMulMd);
+const app = express();
+
+app.use(express.static("./"));
+app.use(express.static(path.join(__dirname, "css")));
+app.set("views", "./views");
+app.set("view engine", "ejs");
+app.engine("ejs", require("ejs").__express);
+
+app.get("/", (req, res) => {
+ let readStream = fs.createReadStream("./mds/cstruct2luatable.md", "utf-8");
+ // FIXME-this is gonna be so wrong when the md is bigger than one chunk
+ readStream.on("data", (chunk) => {
+ res.render("index", {
+ data: {
+ blogHttp: mit.render(chunk),
+ mds: ["c struct to lua table", "lazy makefiles", "telegram lua"],
+ },
+ });
+ });
+});
+
+app.listen(3000);