-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathserver.js
38 lines (31 loc) · 969 Bytes
/
server.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
const express = require('express');
const { Liquid } = require('liquidjs');
const path = require('path');
const fs = require('fs');
const app = express();
const engine = new Liquid({
root: [
path.resolve(__dirname, 'templates'),
path.resolve(__dirname, 'sections'),
path.resolve(__dirname, 'snippets')
],
extname: '.liquid',
});
app.engine('liquid', engine.express());
app.set('views', path.resolve(__dirname, 'templates'));
app.set('view engine', 'liquid');
app.use(express.static('public'));
const products = require('./data/products.json');
const collections = require('./data/collections.json');
const settings = JSON.parse(fs.readFileSync('./config/settings_data.json', 'utf-8'));
app.get('/', (req, res) => {
res.render('index', {
products,
collections,
settings: settings.sections
});
});
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
});