aboutsummaryrefslogtreecommitdiffstats
path: root/server.js
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2021-04-10 05:46:34 +0000
committerterminaldweller <thabogre@gmail.com>2021-04-10 05:46:34 +0000
commit849e1df9b269d8cb7e1fb918a8200f60a085318a (patch)
treebcb0ef183aabaf6228712e005459872682bcc17b /server.js
parenttrying to add syntax highlighting for markdown (diff)
downloadblog-849e1df9b269d8cb7e1fb918a8200f60a085318a.tar.gz
blog-849e1df9b269d8cb7e1fb918a8200f60a085318a.zip
added a dockerfile. fixed the relative path issues
Diffstat (limited to 'server.js')
-rwxr-xr-xserver.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/server.js b/server.js
index ca73018..82b4b07 100755
--- a/server.js
+++ b/server.js
@@ -20,23 +20,25 @@ const mit = require("markdown-it")({ html: true })
});
const app = express();
-app.use(express.static("./"));
+app.use(express.static(__dirname));
app.use(express.static(path.join(__dirname, "css")));
-app.set("views", "./views");
+app.set("views", path.join(__dirname, "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");
+ let readStream = fs.createReadStream(
+ path.join(__dirname, "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"],
+ mds: fs.readdirSync(path.join(__dirname, "mds"), "utf-8"),
},
});
- console.log(mit.render(chunk));
});
});