Skip to content

Commit 25db1ba

Browse files
committed
feat: standalone nprogress plugin
- Install it: yarn add @vuepress/plugin-nprogress@next
1 parent 929da11 commit 25db1ba

File tree

11 files changed

+64
-16
lines changed

11 files changed

+64
-16
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__tests__
2+
__mocks__
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# @vuepress/plugin-nprogress
2+
3+
> nprogress plugin for vuepress
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Vue from 'vue'
2+
import nprogress from 'nprogress'
3+
4+
export default {
5+
mounted () {
6+
// configure progress bar
7+
nprogress.configure({ showSpinner: false })
8+
9+
this.$router.beforeEach((to, from, next) => {
10+
if (to.path !== from.path && !Vue.component(to.name)) {
11+
nprogress.start()
12+
}
13+
next()
14+
})
15+
16+
this.$router.afterEach(() => {
17+
nprogress.done()
18+
this.isSidebarOpen = false
19+
})
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './nprogress.styl'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const { resolve } = require('path')
2+
3+
module.exports = {
4+
clientRootMixin: resolve(__dirname, 'clientRootMixin.js'),
5+
enhanceAppFiles: resolve(__dirname, 'enhanceAppFile.js')
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "@vuepress/plugin-nprogress",
3+
"version": "1.0.0-alpha.30",
4+
"description": "nprogress plugin for vuepress",
5+
"main": "index.js",
6+
"publishConfig": {
7+
"access": "public"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/vuejs/vuepress.git"
12+
},
13+
"keywords": [
14+
"documentation",
15+
"vue",
16+
"vuepress",
17+
"generator"
18+
],
19+
"dependencies": {
20+
"nprogress": "^0.2.0"
21+
},
22+
"author": "ULIVZ <[email protected]>",
23+
"license": "MIT",
24+
"bugs": {
25+
"url": "https://github.com/vuejs/vuepress/issues"
26+
},
27+
"homepage": "https://github.com/vuejs/vuepress/packages/@vuepress/plugin-nprogress#readme"
28+
}

packages/@vuepress/theme-default/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module.exports = (options, ctx) => ({
1919

2020
plugins: [
2121
'@vuepress/active-header-links',
22-
'@vuepress/search'
22+
'@vuepress/search',
23+
'@vuepress/plugin-nprogress'
2324
]
2425
})

packages/@vuepress/theme-default/layouts/Layout.vue

-13
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@
4848
</template>
4949

5050
<script>
51-
import Vue from 'vue'
52-
import nprogress from 'nprogress'
5351
import Home from '../components/Home.vue'
5452
import Navbar from '../components/Navbar.vue'
5553
import Page from '../components/Page.vue'
@@ -115,18 +113,7 @@ export default {
115113
},
116114
117115
mounted () {
118-
// configure progress bar
119-
nprogress.configure({ showSpinner: false })
120-
121-
this.$router.beforeEach((to, from, next) => {
122-
if (to.path !== from.path && !Vue.component(to.name)) {
123-
nprogress.start()
124-
}
125-
next()
126-
})
127-
128116
this.$router.afterEach(() => {
129-
nprogress.done()
130117
this.isSidebarOpen = false
131118
})
132119
},

packages/@vuepress/theme-default/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
"dependencies": {
3232
"@vuepress/plugin-active-header-links": "^1.0.0-alpha.30",
3333
"@vuepress/plugin-search": "^1.0.0-alpha.30",
34+
"@vuepress/plugin-nprogress": "^1.0.0-alpha.30",
3435
"docsearch.js": "^2.5.2",
35-
"nprogress": "^0.2.0",
3636
"stylus": "^0.54.5",
3737
"stylus-loader": "^3.0.2"
3838
}

packages/@vuepress/theme-default/styles/theme.styl

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@require './nprogress'
21
@require './code'
32
@require './custom-blocks'
43
@require './arrow'

0 commit comments

Comments
 (0)