-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.js
More file actions
executable file
·37 lines (34 loc) · 1.24 KB
/
app.js
File metadata and controls
executable file
·37 lines (34 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
(function () {
var _ = require("underscore"),
express = require('express'),
path = require('path'),
port = Number(process.env.PORT || 3000),
app = express();
// the callback to the markdown processor
var setRoutes = function (err, results) {
var sitePages = _.compact(results);
_.each(sitePages, function (page) {
if (page.file === "index") {
_.extend(page, {
tableOfContents: _.without(sitePages, _.findWhere(sitePages, {file: "index"}))
});
}
app.get("/" + page.path, function (req, res) {
res.render("content", page);
});
});
app.listen(port, function () {
console.log("Listening on " + port);
});
};
app.set("view engine", "ejs");
app.get("/javascripts/skrollr.min.js", function (req, res) {
res.sendfile(path.join(__dirname, "node_modules/skrollr/dist/skrollr.min.js"));
});
app.get("/stylesheets/bootstrap.min.css", function (req, res) {
res.sendfile(path.join(__dirname, "node_modules/bootstrap/dist/css/bootstrap.min.css"));
});
app.use(require("stylus").middleware(path.join(__dirname, "public")));
app.use(express.static(path.join(__dirname, "public")));
require("./lib/process_content").processContent(setRoutes);
}());