Add meta description to docs

This commit is contained in:
Stephan Hoyer 2018-11-27 23:50:45 +01:00
parent c7b56161a5
commit 7b1fda5b66
47 changed files with 540 additions and 267 deletions

View file

@ -1,3 +1,6 @@
<!--meta-description
Documentation on m.buildPathname(), which creates URLs from path templates and query objects
-->
# buildPathname(object)
- [Description](#description)
@ -11,7 +14,7 @@
Turns a [path template](paths.md) and a parameters object into a string of form `/path/user?a=1&b=2`
```javascript
var querystring = m.buildPathname("/path/:id", {id: "user", a: "1", b: "2"})
var pathname = m.buildPathname("/path/:id", {id: "user", a: "1", b: "2"})
// "/path/user?a=1&b=2"
```
@ -19,12 +22,13 @@ var querystring = m.buildPathname("/path/:id", {id: "user", a: "1", b: "2"})
### Signature
`querystring = m.buildPathname(object)`
`pathname = m.buildPathname(object)`
Argument | Type | Required | Description
------------ | ------------------------------------------ | -------- | ---
`object` | `Object` | Yes | A key-value map to be converted into a string
**returns** | `String` | | A string representing the input object
`path` | `String` | Yes | A URL path
`query ` | `Object` | Yes | A key-value map to be converted into a string
**returns** | `String` | | A string representing the URL with the query string
[How to read signatures](signatures.md)
@ -35,7 +39,7 @@ Argument | Type | Required | Descripti
The `m.buildPathname` creates a [path name](paths.md) from a path template and a parameters object. It's useful for building URLs, and it's what [`m.route`](route.md), [`m.request`](request.md), and [`m.jsonp`](jsonp.md) all use internally to interpolate paths. It uses [`m.buildQueryString`](buildQueryString.md) to generate the query parameters to append to the path name.
```javascript
var querystring = m.buildPathname("/path/:id", {id: "user", a: 1, b: 2})
var pathname = m.buildPathname("/path/:id", {id: "user", a: 1, b: 2})
// querystring is "/path/user?a=1&b=2"
// pathname is "/path/user?a=1&b=2"
```