meteor - How to create different two head.html using iron-router -
i writing project in meteor, there client side , admin , js, css files different need create different head.html them, how can import "head"s elements (script, style etc.) using iron-router?
i preface saying if you're loading css , js in meteor e.g.:
<link href="styles.css" rel="stylesheet" /> <script src="script.js"></script>
you're doing wrong. meteor automatically loads css , js put in project directory. if need dynamically load css or js external sources, see https://stackoverflow.com/a/14521217/2723753.
but assuming know that, there's not easy way you're asking. it's easiest create 2 apps , create packages can share of code/assets between apps.
if want 2 distinct iron router layouts/styles within 1 app, way i've done use modified version of london:body-class package sets layout name , route name classes on html , body elements.
then in css can refer e.g.
body.adminlayout button { background-color: blue; } body.adminlayout header { background-color: red; }
i use stylus because can use variables colours etc. , because rules can nested massive time-saver:
variables.import.styl:
$some_color_variable = rgba(r,g,b,a) $another_color_variable = rgba(r,g,b,a) $yet_another_color = rgba(r,g,b,a)
admin_layout.styl:
@import 'variables.import' html.adminlayout font-size 20px body.adminlayout button background-color $some_color_variable header background-color $another_color_variable // etc. etc.
public_layout.styl:
@import 'variables.import' body.publiclayout button background-color $yet_another_color // etc. etc.
i'll leave @ now, if clarify you're trying achieve can improve answer...
Comments
Post a Comment