Skip to content

The Meteor FlowRouter helper which allows setting up routes with less boilerplate

License

Notifications You must be signed in to change notification settings

adversinc/meteor-smart-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a Meteor FlowRouter helper which allows setting up routes with less boilerplate. Basically, the routes are being prepared as a set of properties.

Still much to do.

Should be called before all other files to ensure that our custom routes (e.g. signup) have a priority over useraccounts

ROUTE SETTINGS

  • layout (optional) - the layout to use
  • main - the template to use for main slot
  • top - template to put in top slot of the layout
  • left - template to put in left slot of the layout

ROUTE INHERITANCE

Route can be marked as a child of another route, by using a "parent" field. Currently this only affects a page title generation.

DYNAMIC TEMPLATES

Route can load template dynamically, thus allowing other pages load faster. This is being done using Meteor dynamic module loading.

To have route template load dynamically, add the following function to route:

dynamicTemplate: () =>
	{ return import("/imports/ui/pages/maintenance/code.js") },

This makes template module dynamic, and its code will load only on actual route request.

Important: as of 1.5.2, Meteor requires to see an IMPICIT module load directive "import('/import/...../code.js')" in the code. Thus, "dynamicTemplate" have to stay a function with an implicit code inside.

PAGE BODY CLASSES

To allow styling individual pages, router automatically ads the class named according to the page route, e.g.: page-index, page-new-message

This class is being added on route render and removed just before the new route is being rendered.

Also, to (possibly) notify user about page loading, router adds "routers-switching" class to the body while new route is loading.

Custom body classes

The custom body classes can be set for the specific route or the whole website. Set route.bodyClass, defaultSet.bodyClass to string or array of strings.

PAGE TITLE

Page title is being constructed using the following parts:

  1. session.get("document.title")
  2. current route "title" value
  3. the value of the "parent" route (see ROUTE INHERITANCE)
  4. the default title

These values are being joined with " - ".

TODO

  1. Add redirectIfLogged support (it is being used somewhere)

About

The Meteor FlowRouter helper which allows setting up routes with less boilerplate

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published