2.0.18 • Published 4 years ago

@profiscience/knockout-contrib-router-plugins-title v2.0.18

Weekly downloads
10
License
WTFPL
Repository
github
Last release
4 years ago

router.plugins.title

Version Dependency Status Peer Dependency Status Dev Dependency Status Downloads

Set document.title for a route. Supports nesting/composition.

Usage

import { Route, createTitleRoutePlugin } from '@profiscience/knockout-contrib'

Route.usePlugin(createTitleRoutePlugin())

// Basic
new Route('/', {
  title: 'Home',
})

// Sync Accessor Function
new Route('/profile', [loadUser], {
  title: (ctx) => `Profile | ${ctx.user.name}`,
})

// Async Accessor Function
new Route('/profile', {
  title: async (ctx) => `Profile | ${await getUserName()}`,
})

Nested Routing

If you have nested routes that both supply a title, by default they will be joined with "|"...

new Route('/', {
  title: 'My Awesome App',
  children: [
    new Route('/', {
      title: 'Home',
    }),
    new Route('/profile', {
      title: 'Profile',
    }),
  ],
})

If you land on / the title will be set to "My Awesome App | Home"; likewise navigating to /profile will update the title to "My Awesome App | Profile".

Using a Custom Formatter

If you'd like to using something other than "|" to join your routes, you may pass a custom formatter function to createTitleRoutePlugin.

Route.usePlugin(
  createTitleRoutePlugin((ts: string[]) => `My Awesome App | ${ts.join(' > ')}`)
)
2.0.18

4 years ago

2.0.17

4 years ago

2.0.16

4 years ago

2.0.15

4 years ago

2.0.13

4 years ago

2.0.14

4 years ago

2.0.12

4 years ago

2.0.11

4 years ago

2.0.10

5 years ago

2.0.9

5 years ago

2.0.8

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

2.0.0-rc.15

5 years ago

2.0.0-rc.14

5 years ago

2.0.0-rc.13

5 years ago

2.0.0-rc.12

5 years ago

2.0.0-rc.11

6 years ago

2.0.0-rc.10

6 years ago

2.0.0-rc.9

6 years ago

2.0.0-rc.8

6 years ago

2.0.0-rc.7

6 years ago

2.0.0-rc.6

6 years ago

2.0.0-rc.5

6 years ago

2.0.0-rc.4

6 years ago

2.0.0-rc.3

6 years ago

2.0.0-rc.2

6 years ago

2.0.0-next.2

6 years ago

2.0.0-next.1

6 years ago

2.0.0-next.0

6 years ago

2.0.0-rc.1

6 years ago

2.0.0-rc.0

6 years ago

1.0.0-alpha.11

6 years ago

1.0.0-alpha.10

6 years ago

1.0.0-alpha.9

6 years ago

1.0.0-alpha.8

6 years ago

1.0.0-alpha.7

6 years ago

1.0.0-alpha.6

6 years ago

1.0.0-alpha.5

6 years ago

1.0.0-alpha.4

6 years ago

1.0.0-alpha.3

6 years ago

1.0.0-alpha.2

6 years ago

1.0.0-alpha.1

6 years ago