breadcrumb

pull/29/head
afc163 10 years ago
parent e551caddd5
commit c42ca53d91

@ -27,13 +27,17 @@ let Breadcrumb = React.createClass({
if (this.context.router) { if (this.context.router) {
routes = this.context.router.getCurrentRoutes(); routes = this.context.router.getCurrentRoutes();
params = this.context.router.getCurrentParams(); params = this.context.router.getCurrentParams();
crumbs = routes.map(function(route) { crumbs = routes.map(function(route, i) {
var name = route.name.replace(/\:(.*)/g, function(replacement, key) { var name = route.name.replace(/\:(.*)/g, function(replacement, key) {
return params[key] || replacement; return params[key] || replacement;
}); });
return <BreadcrumbItem> var link;
<Link to={route.path} params={params}>{name}</Link> if (i === routes.length - 1) {
</BreadcrumbItem>; link = <span>{name}</span>;
} else {
link = <Link to={route.path} params={params}>{name}</Link>;
}
return <BreadcrumbItem>{link}</BreadcrumbItem>;
}); });
} else { } else {
crumbs = this.props.children; crumbs = this.props.children;

@ -4,7 +4,7 @@
color: #999; color: #999;
font-size: 12px; font-size: 12px;
a&-link { a {
color: #666; color: #666;
} }

Loading…
Cancel
Save