Friday, August 19, 2011

Building a Simple Web App - Step 4

Add navigation to layout.jade


ul#nav
      li 
        a(href='/', class='current') Home
      li
        a(href='/summary') Summary
      li 
        a(href='/map') Map

Add nav styles to styles.css


#nav {  
  margin: 0;
  padding: 0;
}

#nav li {
  display: inline;
}

#nav a:link,
#nav a:visited {
  color: #000;
  background: #b2b580;
  padding:20px 40px 4px 10px;
  text-decoration: none;
}

#nav a.current {
  color: #fff;
}

Create summary.jade and map.jade in Views folder


Create route for new summary and map pages in express


app.get('/:dir', function(req, res) {
  res.render(req.params.dir, {title: req.params.dir + ' page'});
});