From b9d20e04f2f6307c0e708e56d05e25ebc942d2df Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Thu, 22 Oct 2015 18:08:39 +0200 Subject: Display the board name in the page title Fixes #364 --- client/config/router.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'client/config/router.js') diff --git a/client/config/router.js b/client/config/router.js index 1cac43a0..0a6958d0 100644 --- a/client/config/router.js +++ b/client/config/router.js @@ -88,3 +88,26 @@ _.each(redirections, (newPath, oldPath) => { }], }); }); + +// As it is not possible to use template helpers in the page we create a +// reactive function whose role is to set any page-specific tag in the +// using the `kadira:dochead` package. Currently we only use it to display the +// board title if we are in a board page (see #364) but we may want to support +// some tags in the future. +const appTitle = 'Wekan'; + +// XXX The `Meteor.startup` should not be necessary -- we don't need to wait for +// the complete DOM to be ready to call `DocHead.setTitle`. But the problem is +// that the global variable `Boards` is undefined when this file loads so we +// wait a bit until hopefully all files are loaded. This will be fixed in a +// clean way once Meteor will support ES6 modules -- hopefully in Meteor 1.3. +Meteor.startup(() => { + Tracker.autorun(() => { + const currentBoard = Boards.findOne(Session.get('currentBoard')); + const titleStack = [appTitle]; + if (currentBoard) { + titleStack.push(currentBoard.title); + } + DocHead.setTitle(titleStack.reverse().join(' - ')); + }); +}); -- cgit v1.2.3-1-g7c22