Skip to content

Commit 1d6dfe1

Browse files
committed
Revise
1 parent 4b96214 commit 1d6dfe1

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

addons/van_cone/API_REFERENCE.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Van Cone
1+
# Van Cone
22

33
See [README.md](./README.md) for installation and overview.
44

@@ -13,11 +13,11 @@ See [README.md](./README.md) for installation and overview.
1313

1414
- `routerElement` - (required) the root DOM element element that holds the app (element defined by active route)
1515

16-
- `routes` - (required) an array of [routes](#routes)
16+
- `routes` - (required) an array of [`routes`](#routes)
1717

18-
- `defaultNavState` - (optional) the default navigation state, any type allowed by [history.pushState](https://developer.mozilla.org/en-US/docs/Web/API/History/pushState)
18+
- `defaultNavState` - (optional) the default navigation state, any type allowed by [`history.pushState`](https://developer.mozilla.org/en-US/docs/Web/API/History/pushState)
1919

20-
- [routerConfig](#constructorrouterconfig) = (optional) - configure `prefix` to prepend to each url, or `backendPrefix` if different than frontend.
20+
- [`routerConfig`](#constructorrouterconfig) = (optional) - configure `prefix` to prepend to each url, or `backendPrefix` if different than frontend.
2121

2222
**return**
2323

@@ -27,7 +27,7 @@ An object with the following items is returned:
2727

2828
- `currentPage` - a `van.state` object representing the `name` value of the active route
2929

30-
- `router` - the [router](#router) object for the application
30+
- `router` - the [`router`](#router) object for the application
3131

3232
- `navState` - a `van.state` object representing the current [`window.history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state)
3333

@@ -54,7 +54,7 @@ A list of objects defining each route. Each route object has the following prope
5454

5555
**`callable`** (required) a callback that either returns an element to put on the DOM or another callable that returns this element (for more complex apps requiring imports). The callback is passed 2 arguments, an object representing the params parsed from the URL and another representing parsed query string params.
5656

57-
**`backend`** (optional) provide this value when data is fetched from a different endpoint on the backend than on the frontend. See [router.backendUrl](#backendurlroutename-params---query) for more.
57+
**`backend`** (optional) provide this value when data is fetched from a different endpoint on the backend than on the frontend. See [`router.backendUrl`](#backendurlroutename-params---query) for more.
5858

5959
**`title`** (optional) if provided the title of the page will change to this when this route is active.
6060

@@ -92,7 +92,7 @@ const routes = [
9292
```
9393

9494
### different backend endpoint
95-
When data is fetched from a different endpoint provide a backend path as follows. See [router.backendUrl](#backendurlroutename-params---query) for information on generating a backend url for fetching data.
95+
When data is fetched from a different endpoint provide a backend path as follows. See [`router.backendUrl`](#backendurlroutename-params---query) for information on generating a backend url for fetching data.
9696
```javascript
9797
const routes = [
9898
{
@@ -203,18 +203,18 @@ const userPage = (params, query, context) => {
203203
## `router`
204204

205205
#### `constructor(routerConfig)`
206-
The `routerConfig` object is used to construct a new router, it is an object with two optional keys `prefix` and `backendPrefix`. If `routerConfig` is not provided or either key is not provided they will default to an empty string.
206+
The `routerConfig` object is used to construct a new router, it is an object with two optional keys `prefix` and `backendPrefix`. If `routerConfig` is not provided or either key is not provided they will default to an empty string.
207207

208-
`prefix` will be prepended to front end URLs, the ones shown in the browser and matched when navigating to different pages. See [router.navUrl](#navurlroutename-params---query) for more.
208+
`prefix` will be prepended to front end URLs, the ones shown in the browser and matched when navigating to different pages. See [`router.navUrl`](#navurlroutename-params---query) for more.
209209

210-
The `backendPrefix` is useful for when the backend is at a different host or has a different prefix than the front end. It is only used as a utility to generate URLs for fetching data, it is ignored for route matching and page navigation. See [router.backendUrl](#backendurlroutename-params---query) for more.
210+
The `backendPrefix` is useful for when the backend is at a different host or has a different prefix than the front end. It is only used as a utility to generate URLs for fetching data, it is ignored for route matching and page navigation. See [`router.backendUrl`](#backendurlroutename-params---query) for more.
211211

212212
#### `navUrl(routeName, params = {}, query = {})`
213-
Return a string representing a url for the route with name `routeName`, and optionally form url params with the `params` argument or query params with the `query` argument. The return can be used with [navigate](#navigateurl-context) or any other place a url string is needed. If `prefix` was included with [routerConfig](#constructorrouterconfig) it will be prepended to the url.
213+
Return a string representing a url for the route with name `routeName`, and optionally form url params with the `params` argument or query params with the `query` argument. The return can be used with [`navigate`](#navigateurl-context) or any other place a url string is needed. If `prefix` was included with [`routerConfig`](#constructorrouterconfig) it will be prepended to the url.
214214

215-
**Note: to access this function from the return value of [createCone](#createconerouterelement-routes-defaultnavstate) call `router.navUrl`**
215+
**Note: to access this function from the return value of [`createCone`](#createconerouterelement-routes-defaultnavstate) call `router.navUrl`**
216216

217-
The following [route](#routes):
217+
The following [`route`](#routes):
218218
```javascript
219219
{
220220
path: "/user/:userId",
@@ -231,11 +231,11 @@ router.formatUrl('user', { userId: 123 }, { activeTab: 'profile'})
231231
```
232232

233233
#### `backendUrl(routeName, params = {}, query = {})`
234-
Return a string backend url for the route with name `routeName`, and optionally form url params with the `params` argument or query params with the `query` argument. The return can be used for fetching data. If `backendPrefix` was included with [routerConfig](#constructorrouterconfig) it will be prepended to the url.
234+
Return a string backend url for the route with name `routeName`, and optionally form url params with the `params` argument or query params with the `query` argument. The return can be used for fetching data. If `backendPrefix` was included with [`routerConfig`](#constructorrouterconfig) it will be prepended to the url.
235235

236-
**Note: to access this function from the return value of [createCone](#createconerouterelement-routes-defaultnavstate) call `router.backendUrl`**
236+
**Note: to access this function from the return value of [`createCone`](#createconerouterelement-routes-defaultnavstate) call `router.backendUrl`**
237237

238-
The following [routerConfig](#constructorrouterconfig) and [routes](#routes):
238+
The following [`routerConfig`](#constructorrouterconfig) and [`routes`](#routes):
239239
```javascript
240240
const routerConfig = { backendPrefix: 'http://localhost:8000' }
241241

@@ -273,21 +273,21 @@ router.formatUrl('item', { itemId: 123 })
273273
## `navigate(url, context)`
274274
Programmatically navigate to `url`. Optionally pass `context` which can be and data to the resolved router component.
275275

276-
You can use [router.navUrl](#navigateurl-context) to generate urls from named routes with url and query params.
276+
You can use [`router.navUrl`](#navigateurl-context) to generate urls from named routes with url and query params.
277277

278278
## `pushHistory(url)`
279279
Push `url` to browser history and update address bar only, do not modify DOM.
280280

281-
You can use [router.navUrl](#navigateurl-context) to generate urls from named routes with url and query params.
281+
You can use [`router.navUrl`](#navigateurl-context) to generate urls from named routes with url and query params.
282282

283283
## `handleNav(event, context)`
284284
An event wrapper for [`navigate`](#navigateurl-context) to be used with an on click action. `handleNav` will call `event.preventDefault` and then call [`navigate`](#navigateurl-context) with `event.target.href`.
285285

286-
It is used internally to create the [navLink](#navlinkprops-children) component.
286+
It is used internally to create the [`navLink`](#navlinkprops-children) component.
287287

288288
Optionally pass `context` which can be and data to the resolved router component.
289289

290-
You can use [router.navUrl](#navurlroutename-params---query) to generate urls from named routes and formatting url/query params.
290+
You can use [`router.navUrl`](#navurlroutename-params---query) to generate urls from named routes and formatting url/query params.
291291

292292
## `isCurrentPage(pageName)`
293293
Returns a `van.derive` object with a boolean that is true when `pageName` is the active route
@@ -296,7 +296,7 @@ if (isCurrentPage("home").val) console.log("we're home!")
296296
```
297297

298298
## `navLink(props, ...children)`
299-
Uses [router.navUrl](#navurlroutename-params---query) to return a link element using `van.tags.a` by passing `props` and `children` to the underling call to `van.tags.a` with a few modifications to the resulting `a` element that adds programmatic navigation and dynamic styling for when it is the active route. URLs are generated using the name of the route, and optional url and query string params.
299+
Uses [`router.navUrl`](#navurlroutename-params---query) to return a link element using `van.tags.a` by passing `props` and `children` to the underling call to `van.tags.a` with a few modifications to the resulting `a` element that adds programmatic navigation and dynamic styling for when it is the active route. URLs are generated using the name of the route, and optional url and query string params.
300300

301301
### examples
302302
A basic call to the route named `home` with the inner text for the a tag `Home`. This is the bare minimum required for `navLink`.
@@ -365,7 +365,7 @@ The following have default values:
365365
* `props.class` (default: `router-link`)
366366

367367
The following are hardcoded and cannot be changed:
368-
* `props.href` is set by a call to [router.navUrl](#navurlroutename-params---query) with `props.name`, `props.params` and `props.query`
368+
* `props.href` is set by a call to [`router.navUrl`](#navurlroutename-params---query) with `props.name`, `props.params` and `props.query`
369369
* `props.role` is set to `link`
370370
* `props.onClick` is set to [`handleNav`](#handlenavevent-context)
371371

addons/van_cone/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ See the [API Reference](./API_REFERENCE.md) for full documentation.
9494

9595

9696
# Support, issues, and suggestions
97-
Open an issue or discussion either on the [offical repo](https://github.com/vanjs-org/van) or [my fork](https://github.com/b-rad-c/van/tree/main). Make sure to tag my username: [@b-rad-c](https://github.com/b-rad-c).
97+
Open an issue or discussion either on the [official repo](https://github.com/vanjs-org/van) or [my fork](https://github.com/b-rad-c/van/tree/main). Make sure to tag my username: [@b-rad-c](https://github.com/b-rad-c).
9898

9999
# Contributing
100100
Got some skills? Want to contribute? Send a pull request!
@@ -105,10 +105,10 @@ I, [@b-rad-c](https://github.com/b-rad-c) am the maintainer of this project howe
105105
Some things I'm interested in.
106106
* unittests
107107
* convert to TypeScript
108-
* stabilze API to come out of beta - comments or suggestions to the API are welcome.
108+
* stabilize API to come out of beta - comments or suggestions to the API are welcome.
109109

110110
# The Name
111111
Van Cone is an addon for VanJS which is short for **Van**illa **J**ava**S**cript, and makes a callout to vanilla ice cream in its logo. Van Cone provides the cone that is needed to support the ice cream. VanJS provides reactivity and UI components, Van Cone provides routing, history and navigation components, together they're everything you need for a lightweight SPA experience!
112112

113113
# Credit
114-
router based on [minimal router](https://github.com/jmhdez/minimal-router) (no longer maintained)
114+
Router based on [minimal router](https://github.com/jmhdez/minimal-router) (no longer maintained).

0 commit comments

Comments
 (0)