Excluding Bootstrap from Specific Routes in Meteor

Meteor: Add Bootstrap CDN links before admin dashboard route

Never mind. I managed to do it myself. Here is solution if someone else looking for it.

    Router.onAfterAction(function(){
var routeName = Router.current().route.getName();
if ( routeName.indexOf("adminDashboard") == 0 ) {
$("head #injectedBootstrap").remove(); //removes duplicates
$("head").append($("<link rel='stylesheet' id='injectedBootstrap' href='/css/bootstrap.min.css' type='text/css' media='screen' />"));
$("head #injectedBootstrapJs").remove(); //removes duplicates
$("head").append($("<script type='text/javascript' src='/js/bootstrap.min.js'></script>"));
}
});

Customizing Bootstrap while using in Meteor

Use this package to easily customise Bootstrap in Meteor:
https://atmospherejs.com/nemo64/bootstrap

(As was mentioned in the comments already)

Can I mount another route handler through __meteor_bootstrap__.app?

The problem with this solution is that your middleware is put at the bottom of the stack. Therefore the catch-all meteor handler will always run before your "/callback"-handler.

One very hacky way to get around this (until the meteor releases their proper routing support) is to splice in your handler att the top of the stack:

__meteor_bootstrap__.app.stack.splice (0, 0, {
route: '/hello',
handle: function (req,res, next) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end("hello world");
return;
}.future ()
});

Rerun Helper Functions on Route Change for Active Links

Yours is a common problem so Mike Fitzgerald has built a package just for this purpose:

https://atmosphere.meteor.com/package/iron-router-active

The given example is like:

<nav>
<ul>
<li class="{{ isActive 'dashboard' }}">...</li>
<li class="{{ isActive 'dashboard|root' }}">...</li>
<li class="{{ isActive 'users' 'on' }}">...</li>
<li class="{{ isActivePath 'products' }}">...</li>
</ul>
</nav>

andd works through handlebars helpers which are called isActive, isActivePath, isNotActive and isNotActivePath.



Related Topics



Leave a reply



Submit