diff options
-rw-r--r-- | css/master.css | 25 | ||||
-rwxr-xr-x | server.js | 39 | ||||
-rw-r--r-- | views/index.ejs | 18 |
3 files changed, 82 insertions, 0 deletions
diff --git a/css/master.css b/css/master.css new file mode 100644 index 0000000..69d862e --- /dev/null +++ b/css/master.css @@ -0,0 +1,25 @@ +body{$ + font-family: "DejaVuSansMono NF", Helvetica, monospace; + color: #005f87; + background: #000000; + /* linear-gradient( */ + /* rgba(68, 68, 68, 1), */ + /* rgba(0, 0, 0, 1) */ + /* ); */ + text-align: left; + padding: 20px; + border-style: solid; +} + +.sidenav { + color: #00afd7; + height: 100%; + width: 160px; + position: fixed; + z-index: 1; + top: 0; + left: 0; + background-color: #111; + overflow-x: hidden; + padding-top: 20px; +} 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); diff --git a/views/index.ejs b/views/index.ejs new file mode 100644 index 0000000..f1f7bb1 --- /dev/null +++ b/views/index.ejs @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width"> + <title>Blog</title> + <link rel="stylesheet" href="/css/master.css" type="text/css" media="screen" title="no title" charset="utf-8"> + </head> + <body> + <div class="sidenav"> + <% data.mds.forEach(function(md) { %> + <h2><%= md %></h2> + <a href="#" target="_blank"><%= md %></a> + <% }) %> + </div> + <%- data.blogHttp %> + </body> +</html> |