Permalink
Browse files

Dynamic Title

Page title now comes from paths.js and updates on route change
  • Loading branch information...
BradDenver committed Dec 31, 2014
1 parent d7216b9 commit 531c9bb9028933a0a542f6555943ef9383363adc
Showing with 24 additions and 2 deletions.
  1. +6 −2 elements/Layout.jsx
  2. +18 −0 paths.js
View
@@ -1,19 +1,23 @@
var React = require('react'),
LayoutNav = require('./LayoutNav.jsx');
Router = require('react-router');
RouteHandler = Router.RouteHandler;
RouteHandler = Router.RouteHandler,
paths = require('../paths.js');
var Layout = React.createClass({
mixins: [Router.State],
getDefaultProps: function() {
return {title: 'React Static Site'};
},
render: function() {
var script = (process.env.NODE_ENV!=='production') ? <script src="http://localhost:3000/scripts/bundle.js"></script> : '';
var title = paths.titleForPath(this.getPathname());
return (
<html>
<head>
<title>{this.props.title}</title>
<title>{title}</title>
</head>
<body>
<div id="layout">
View
@@ -0,0 +1,18 @@
var paths = {
'/': {
'title': 'React Static Site'
},
'/about': {
'title': 'About - React Static Site'
}
};
module.exports = {
allPaths: function() {
return paths;
},
titleForPath: function(path) {
return paths[path].title;
}
};

0 comments on commit 531c9bb

Please sign in to comment.