Skip to content

Instantly share code, notes, and snippets.

@prozbik
Created September 22, 2015 04:12
Show Gist options
  • Save prozbik/eb32d299a5fac0d67f23 to your computer and use it in GitHub Desktop.
Save prozbik/eb32d299a5fac0d67f23 to your computer and use it in GitHub Desktop.
app.get('/:page?', function(req,res){
var page = req.params.page, data; //page = requrest(:page)
if(!page) page = 'home'; // page = home by default
data = storage[page];
if(!data) res.redirect('/') return;
data.links = Object.keys(store);
res.render('index', data);
})
var storage = {
home: {
page: 'Home page',
content: 'content for home page'
},
about: {
page: 'About page',
content: 'Some cool content for about page'
}
}
}
//by sorax fro screencast 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment