diff --git a/README.md b/README.md index 41fd905..acff7c0 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Name | Type | Description ---- | ---- | ----------- suffix | String | suffix for the value of the page title tag prefix | String | prefix for the value of the page title tag +router | [VueRouter instance](https://router.vuejs.org/api/#router-instance-properties) | if present, allows you to set the title via the route. ## Usage @@ -79,3 +80,39 @@ export default { title: ({ $t }) => $t('pages.clients.title') } ``` + +## Vue Router usage +### Setup + +```js +import Vue from 'vue' +import VuePageTitle from 'vue-page-title' + +import router from 'path/to/application/router' + +Vue.use(VuePageTitle, { router }) +``` + +```js +// path/to/application/router +import FooComponent from 'path/to/foo-component' +import HomeComponent from 'path/to/home-component' + +const routes = [{ + path: '/', + component: HomeComponent, + meta: { + title: 'Home Page' // Title must be a string. + } +}, { + path: '/foo', + component: FooComponent, + meta: { + title: 'Foo Page' + } +}] + +export default new VueRouter({ + routes +}) +```