All Projects โ†’ veliovgroup โ†’ Meteor-flow-router-title

veliovgroup / Meteor-flow-router-title

Licence: BSD-3-Clause license
Change document.title on the fly within flow-router

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Meteor-flow-router-title

flow-router
๐Ÿšฆ Carefully extended flow-router for Meteor
Stars: โœญ 191 (+730.43%)
Mutual labels:  meteor, meteor-package, flow-router, meteorjs
jazeee-meteor-spiderable
Fork of Meteor Spiderable with longer timeout, caching, better server handling
Stars: โœญ 33 (+43.48%)
Mutual labels:  meteor-package, seo, meteorjs
Meteor-logger
๐Ÿงพ Meteor isomorphic logger. Store application logs in File (FS), MongoDB, or print in Console
Stars: โœญ 51 (+121.74%)
Mutual labels:  meteor, meteor-package, meteorjs
Meteor-logger-file
๐Ÿ”– Meteor Logging: Store application log messages into file (FS)
Stars: โœญ 24 (+4.35%)
Mutual labels:  meteor, meteor-package, meteorjs
hypersubs
an upgraded version of Meteor subscribe, which helps optimize data and performance!
Stars: โœญ 13 (-43.48%)
Mutual labels:  meteor, meteor-package, meteorjs
svelte-meteor-data
Reactively track Meteor data inside Svelte components
Stars: โœญ 14 (-39.13%)
Mutual labels:  meteor, meteor-package, meteorjs
awesome-blaze
๐Ÿ”ฅA curated list of awesome things related to Blaze
Stars: โœญ 29 (+26.09%)
Mutual labels:  meteor, meteor-package, meteorjs
spiderable-middleware
๐Ÿค– Prerendering for JavaScript powered websites. Great solution for PWAs (Progressive Web Apps), SPAs (Single Page Applications), and other websites based on top of front-end JavaScript frameworks
Stars: โœญ 29 (+26.09%)
Mutual labels:  meteor, meteor-package, seo
Meteor-Template-helpers
Template helpers for Session, logical operations and debug
Stars: โœญ 35 (+52.17%)
Mutual labels:  meteor, meteor-package, meteorjs
Meteor-logger-mongo
๐Ÿƒ Meteor Logging: Store application log messages in MongoDB
Stars: โœญ 20 (-13.04%)
Mutual labels:  meteor, meteor-package, meteorjs
meteor-subscription-scope
Scope queries on collections to subscriptions
Stars: โœญ 20 (-13.04%)
Mutual labels:  meteor, meteor-package
MeteorCandy-meteor-admin-dashboard-devtool
The Fast, Secure and Scalable Admin Panel / Dashboard for Meteor.js
Stars: โœญ 50 (+117.39%)
Mutual labels:  meteor, meteorjs
Meteor-Cookies
๐Ÿช Isomorphic bulletproof cookie functions for client and server
Stars: โœญ 41 (+78.26%)
Mutual labels:  meteor, meteor-package
seo-genius
Lightweight WordPress SEO plugin
Stars: โœญ 15 (-34.78%)
Mutual labels:  seo, seo-meta
classicpress-seo
Classic SEO is the first SEO plugin built specifically to work with ClassicPress. A fork of Rank Math, the plugin contains many essential SEO tools to help optimize your website.
Stars: โœญ 18 (-21.74%)
Mutual labels:  seo, seo-meta
Client-Storage
๐Ÿ—„ Bulletproof persistent Client storage, works with disabled Cookies and/or localStorage
Stars: โœญ 15 (-34.78%)
Mutual labels:  meteor, meteor-package
ostrio-analytics
๐Ÿ“Š Visitor's analytics tracking code for ostr.io service
Stars: โœญ 14 (-39.13%)
Mutual labels:  meteor, meteor-package
Awesome-meta-tags
๐Ÿ“™ Awesome collection of meta tags
Stars: โœญ 18 (-21.74%)
Mutual labels:  seo, seo-meta
meteor-two-factor
๐Ÿ” Two factor authentication package for accounts-password
Stars: โœญ 80 (+247.83%)
Mutual labels:  meteor, meteor-package
drupal 8 unset html head link
๐Ÿค– Module for unset any wrong HTML links (like rel="delete-form", rel="edit-form", etc.) from head on Drupal 8.x websites. This is trust way to grow up position in SERP Google, Yandex, etc.
Stars: โœญ 19 (-17.39%)
Mutual labels:  seo, seo-meta

support support

Reactive page title

Change document.title on the fly within flow-router-extra.

Features:

  • ๐Ÿ‘จโ€๐Ÿ”ฌ 100% tests coverage;
  • ๐ŸŽ› Per route, per group, and default (all routes) title tag.

Various ways to set title, ordered by prioritization:

  • FlowRouter.route() [overrides all below]
  • FlowRouter.group()
  • FlowRouter.globals
  • Head template <title>Text</title> tag [might be overridden by any above]

Install:

meteor add ostrio:flow-router-title

Demos / Tests:

ES6 Import:

import { FlowRouterTitle } from 'meteor/ostrio:flow-router-title';

Related Packages:

Usage:

Initialize FlowRouterTitle class by passing FlowRouter object. Right after creating all routes:

import { FlowRouter }      from 'meteor/ostrio:flow-router-extra';
import { FlowRouterTitle } from 'meteor/ostrio:flow-router-title';

FlowRouter.route('/', {
  action() { /* ... */ },
  title: 'Title'
  /* ... */
});

new FlowRouterTitle(FlowRouter);

Set title via Route

Set title property in route's or group's configuration:

// Set default document.title value in
// case router has no title property
FlowRouter.globals.push({
  title: 'Default title'
});

FlowRouter.route('/me/account', {
  name: 'account',
  title: 'My Account'
});

.set() method

Set document.title during runtime (without route(s)):

FlowRouter.route('/', {/* ... */});

const titleHandler = new FlowRouterTitle(FlowRouter);
// `.set()` method accepts only String
titleHandler.set('My Awesome Title String'); // <- Returns `true`
titleHandler.set(() => { return 'Wrapped title'; }); // <- Returns `false`, as function can't be set into the `document.title`

Function context

Use function context (with data hook):

FlowRouter.route('/post/:_id', {
  name: 'post',
  waitOn(params) {
    return [Meteor.subscribe('post', params._id)];
  },
  data(params) {
    return Collections.Posts.findOne(params._id);
  },
  title(params, query, data) {
    if (data) {
      return data.title;
    }
    return '404: Page not found';
  }
});

Group context

Use group context:

const account = FlowRouter.group({
  prefix: '/account',
  title: 'Account',
  titlePrefix: 'Account > '
});

account.route('/', {
  name: 'accountIndex' // Title will be `Account`
});

account.route('/settings', {
  name: 'AccountSettings',
  title: 'My Settings' // Title will be `Account > My Settings`
});

Reactive data sources

To change title reactively, just pass it as function:

FlowRouter.route('/me/account', {
  name: 'account',
  title() {
    // In this example we used `ostrio:i18n` package
    return i18n.get('account.document.title');
  }
});

// Use params from route
FlowRouter.route('/page/:something', {
  name: 'somePage',
  title(params) {
    return 'Page ' + params.something;
  }
});

More examples

In all examples below title can be a Function or String:

import { FlowRouter } from 'meteor/ostrio:flow-router-extra';

FlowRouter.globals.push({
  title() {/* ... */} // <-- Suitable for reactive data source
});

FlowRouter.globals.push({
  title: 'Title text'
});

FlowRouter.group({
  title() {/* ... */}, // <-- Suitable for reactive data source
  titlePrefix() {/* ... */} // <-- Can accept reactive data source, but won't trigger re-computation
});

FlowRouter.group({
  title: 'Title text',
  titlePrefix: 'Title prefix text'
});

FlowRouter.route('/path', {
  title() {/* ... */} // <-- Reactive
});

FlowRouter.route('/path', {
  title: 'Title text'
});

Running Tests

  1. Clone this package
  2. In Terminal (Console) go to directory where package is cloned
  3. Then run:

Meteor/Tinytest

# Default
meteor test-packages ./

# With custom port
meteor test-packages ./ --port 8888

# With local MongoDB and custom port
MONGO_URL="mongodb://127.0.0.1:27017/flow-router-title-tests" meteor test-packages ./ --port 8888

Support this project:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].