Last active
December 11, 2015 02:48
-
-
Save Rolilink/4533070 to your computer and use it in GitHub Desktop.
My File
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var express = require('express'); | |
| var app = express(); | |
| var stylus = require('stylus'); | |
| var nib = require('nib'); | |
| var documentspath = 'src/dcouments' | |
| var docpadInstanceConfiguration = {}; | |
| var docpadInstance = require('docpad').createInstance(docpadInstanceConfiguration, function(err,docpadInstance){ | |
| if (err) return console.log(err.stack); | |
| // ... | |
| }); | |
| function compile(str, path) { | |
| return stylus(str) | |
| .set('filename', path) | |
| .use(nib()) | |
| } | |
| app.set('views', __dirname + '/views/'); | |
| app.set('view engine', 'jade'); | |
| app.engine('jade', require('jade').__express); | |
| app.use(stylus.middleware({ | |
| src: __dirname + '/views', | |
| dest: __dirname + '/public', | |
| compile: compile, | |
| force:true | |
| } | |
| )); | |
| app.use(express.static(__dirname + '/public/')); | |
| app.get('/',function(req,res){ | |
| res.render('index',{}); | |
| }); | |
| app.get('/layout',function(req,res){ | |
| res.render('layout',{}); | |
| }); | |
| app.get('/blog',function(req,res,next){ | |
| }); | |
| app.get('/blog/:title',function(req,res,next){ | |
| req.templateData = { | |
| weDidSomeCustomRendering: true | |
| } | |
| var path = '/posts/'+req.params.title+'.html'; | |
| var doc = docpadInstance.getFile({relativePath: path}); | |
| console.log(doc); | |
| }); | |
| app.listen(1337); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment