-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
39 lines (30 loc) · 941 Bytes
/
index.js
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
38
39
const fs = require('fs');
const packageJson = require('./package.json');
const express = require('express');
const app = express();
const md = require('markdown-it')({
html: true,
linkify: true,
typography: true,
}).use(require('markdown-it-imsize'));
require.extensions['.html'] = function(module, filename) {
module.exports = fs.readFileSync(filename, 'utf8');
};
require.extensions['.md'] = function(module, filename) {
const content = fs.readFileSync(filename, 'utf8');
module.exports = md.render(content);
};
const { home } = require('./routes');
try {
app.use(express.static('public'));
app.use('/favicon.ico', express.static('public/favicon.ico'));
app.get('/', home);
// More markdown pages
// app.get('/other', other);
const port = process.env.PORT || 9000;
app.listen(port, function() {
console.log(`${packageJson.name} listening on port ${port}!`);
});
} catch (e) {
console.error(e);
}