From: Eduardo San Martin Morote Date: Mon, 14 Sep 2020 10:19:06 +0000 (+0200) Subject: docs(api): add route location normalized X-Git-Tag: v4.0.0-beta.10~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b505ecf3455bff83f850f59db747e3a13efeaaaa;p=thirdparty%2Fvuejs%2Frouter.git docs(api): add route location normalized --- diff --git a/docs/api/index.md b/docs/api/index.md index 0b516cd1..00ff48e6 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -752,12 +752,13 @@ Route record that can be provided by the user when adding routes via the [`route ### redirect -- **Type**: [`RouteLocationRaw`](#routelocationraw) (Optional) +- **Type**: `RouteLocationRaw | (to: RouteLocationNormalized) => RouteLocationRaw` (Optional) - **Details**: Where to redirect if the route is directly matched. The redirection happens - before any navigation guard and triggers a new navigation with the new - target location. + before any navigation guard and triggers a new navigation with the new target + location. Can also be a function that receives the target route location and + returns the location we should redirect to. ### children @@ -849,7 +850,7 @@ Normalized version of a [Route Record](#routerecordraw) - **Type**: `RouteMeta` - **Details**: - Arbitrary data attached to all matched records merged (non recursively) from parent to child. + Arbitrary data attached to the record. - **See also**: [Meta fields](/guide/advanced/meta.md) @@ -918,6 +919,27 @@ Resolved [RouteLocationRaw](#routelocationraw) that can contain [redirect record Normalized route location. Does not have any [redirect records](#routerecordraw). In navigation guards, `to` and `from` are always of this type. +### fullPath + +- **Type**: `string` +- **Details**: + + Encoded URL associated to the route location. Contains `path`, `query` and `hash`. + +### hash + +- **Type**: `string` +- **Details**: + + Decoded `hash` section of the URL. Always starts with a `#`. Empty string if there is no `hash` in the URL. + +### query + +- **Type**: `Record` +- **Details**: + + Dictionary of decoded query params extracted from the `search` section of the URL. + ### matched - **Type**: [`RouteRecordNormalized[]`](#routerecordnormalized) @@ -925,6 +947,43 @@ Normalized route location. Does not have any [redirect records](#routerecordraw) Array of [normalized route records](#routerecord) that were matched with the given route location. +### meta + +- **Type**: `RouteMeta` +- **Details**: + + Arbitrary data attached to all matched records merged (non recursively) from parent to child. + +- **See also**: [Meta fields](/guide/advanced/meta.md) + +### name + +- **Type**: `string | symbol | undefined | null` +- **Details**: + + Name for the route record. `undefined` if none was provided. + +### params + +- **Type**: `Record` +- **Details**: + + Dictionary of decoded params extracted from `path`. + +### path + +- **Type**: `string` +- **Details**: + + Encoded `pathname` section of the URL associated to the route location. + +### redirectedFrom + +- **Type**: [`RouteLocation`](#routelocation) +- **Details**: + + Route location we were initially trying to access before ending up on the current location when a `redirect` option was found or a navigation guard called `next()` with a route location. `undefined` if there was no redirection. + ## NavigationFailure ### from diff --git a/docs/guide/advanced/navigation-guards.md b/docs/guide/advanced/navigation-guards.md index 8b422fcf..53e55757 100644 --- a/docs/guide/advanced/navigation-guards.md +++ b/docs/guide/advanced/navigation-guards.md @@ -86,7 +86,9 @@ router.beforeResolve(async to => { }) ``` -`router.beforeResolve` is the ideal spot to fetch data or do any other operation that you want to avoid doing if the user cannot enter a page. It's also very easy to combine with [`meta` fields](./meta.md) to create a [generic fetching mechanism](#TODO). +`router.beforeResolve` is the ideal spot to fetch data or do any other operation that you want to avoid doing if the user cannot enter a page. + + ## Global After Hooks diff --git a/docs/guide/essentials/redirect-and-alias.md b/docs/guide/essentials/redirect-and-alias.md index 2b89d718..c44f2666 100644 --- a/docs/guide/essentials/redirect-and-alias.md +++ b/docs/guide/essentials/redirect-and-alias.md @@ -98,4 +98,4 @@ const routes = [ ] ``` -TODO: canonical links in cookbook https://support.google.com/webmasters/answer/139066?hl=en +**Note about SEO**: when using aliases, make sure to define canonical links: https://support.google.com/webmasters/answer/139066?hl=en. diff --git a/docs/guide/migration/index.md b/docs/guide/migration/index.md index 2008d76b..9e85c8a3 100644 --- a/docs/guide/migration/index.md +++ b/docs/guide/migration/index.md @@ -188,7 +188,7 @@ try { ### Removal of `router.match` and changes to `router.resolve` -Both `router.match`, and `router.resolve` have been merged together into `router.resolve` with a slightly different signature. [Refer to the API](#TODO) for more details. +Both `router.match`, and `router.resolve` have been merged together into `router.resolve` with a slightly different signature. [Refer to the API](/api/#resolve) for more details. **Reason**: Uniting multiple methods that were use for the same purpose. diff --git a/docs/index.md b/docs/index.md index 6b0397e8..836d2177 100644 --- a/docs/index.md +++ b/docs/index.md @@ -13,6 +13,4 @@ Vue Router is the official router for [Vue.js](http://vuejs.org). It deeply inte - Customizable Scroll Behavior - Proper encoding for URLs - - [Get started](./guide/) or play with the [playground](https://github.com/vuejs/vue-router-next/tree/master/playground) (see [`README.md`](https://github.com/vuejs/vue-router-next) to run them).