Skip to content

Commit 3a1448a

Browse files
committed
chore: setup docs
1 parent 5968bee commit 3a1448a

File tree

9 files changed

+14659
-8389
lines changed

9 files changed

+14659
-8389
lines changed

docs/.gitkeep

Whitespace-only changes.

docs/.vuepress/config.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module.exports = {
2+
title: 'Vue Router Middleware Plugin',
3+
description: 'The vue router middleware pipeline you deserve',
4+
themeConfig: {
5+
nav: [
6+
{ text: 'Guide', link: '/guide/' },
7+
{ text: 'API', link: '/api/' },
8+
{ text: 'GitHub', link: 'https://github.com/dsfx3d/vue-router-middleware-plugin'}
9+
],
10+
sidebar: {
11+
'/guide/': [
12+
{
13+
title: 'Guide',
14+
collapsable: false,
15+
children: [
16+
''
17+
]
18+
}
19+
],
20+
'/api/': [
21+
{
22+
title: 'API Reference',
23+
collapsable: false,
24+
children: [
25+
'',
26+
'context',
27+
'options'
28+
]
29+
}
30+
]
31+
}
32+
}
33+
}

docs/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
home: true
3+
heroText: Middleware Plugin
4+
tagline: The middleware pipeline you deserve
5+
actionText: Get Started →
6+
actionLink: /guide/
7+
features:
8+
- title: Performant
9+
details: Inspired from Nuxt Middlewares and built on top of vue router's Navigation Guards to offer the best of performance.
10+
- title: Light-Weight
11+
details: A light weight but powerful middleware pipeline to control logic between your routes.
12+
- title: Extensible
13+
details: The plugin API is inherently extensible to use within your applications or in integration with third-party plugins.
14+
footer: MIT Licensed | Copyright © 2020 @dsfx3d
15+
---

docs/api/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Configuration
2+
3+
Pass the configuration object

docs/api/context.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Context
2+
3+
The `context` or middleware context is the only argument in all middleware functions. It's an object which provide properties which can be used to control the behaviour of a middleware
4+
5+
```javascript
6+
export default ({ app, to, from, redirect }) => {
7+
if (to.path === '/protected') {
8+
redirect(from)
9+
} else {
10+
const { visits } = app.$getMiddlewareContext()
11+
app.$updateMiddlewareContext('visits', (visits || 0) + 1)
12+
}
13+
}
14+
```
15+
16+
## Built-In Properties
17+
18+
The context has the following built-in properties:
19+
20+
### `app: VueConstructor`
21+
22+
A regular vue constructor with injected plugin [options](options/).
23+
24+
### `to: Route`
25+
26+
The target [Route Object](https://router.vuejs.org/api/#the-route-object) being navigated to.
27+
28+
*An argument from [Navigation Guard](https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards)*
29+
30+
### `from: Route`
31+
32+
The target [Route Object](https://router.vuejs.org/api/#the-route-object) being navigated from.
33+
34+
*An argument from [Navigation Guard](https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards)*
35+
36+
### `redirect: function`
37+
38+
A function to redirect to any route. Accepts same arguments as the `next` function in a [Navigation Guard](https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards) but unlike a navigation guard, it's not required to be called in each middleware in order to resolve it.
39+
40+
## Adding custom properties
41+
42+
From the example above, we are appearently adding a property `visits` to the middleware context. Goto [options](options/) for more.

docs/api/options.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Options

docs/guide/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Introduction

0 commit comments

Comments
 (0)