Skip to content

Commit

Permalink
feat: standalone nprogress plugin
Browse files Browse the repository at this point in the history
- Install it: yarn add @vuepress/plugin-nprogress@next
  • Loading branch information
ulivz committed Dec 23, 2018
1 parent 929da11 commit 25db1ba
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 16 deletions.
2 changes: 2 additions & 0 deletions packages/@vuepress/plugin-nprogress/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__tests__
__mocks__
3 changes: 3 additions & 0 deletions packages/@vuepress/plugin-nprogress/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @vuepress/plugin-nprogress

> nprogress plugin for vuepress
21 changes: 21 additions & 0 deletions packages/@vuepress/plugin-nprogress/clientRootMixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Vue from 'vue'
import nprogress from 'nprogress'

export default {
mounted () {
// configure progress bar
nprogress.configure({ showSpinner: false })

this.$router.beforeEach((to, from, next) => {
if (to.path !== from.path && !Vue.component(to.name)) {
nprogress.start()
}
next()
})

this.$router.afterEach(() => {
nprogress.done()
this.isSidebarOpen = false
})
}
}
1 change: 1 addition & 0 deletions packages/@vuepress/plugin-nprogress/enhanceAppFile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './nprogress.styl'
6 changes: 6 additions & 0 deletions packages/@vuepress/plugin-nprogress/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { resolve } = require('path')

module.exports = {
clientRootMixin: resolve(__dirname, 'clientRootMixin.js'),
enhanceAppFiles: resolve(__dirname, 'enhanceAppFile.js')
}
28 changes: 28 additions & 0 deletions packages/@vuepress/plugin-nprogress/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@vuepress/plugin-nprogress",
"version": "1.0.0-alpha.30",
"description": "nprogress plugin for vuepress",
"main": "index.js",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vuejs/vuepress.git"
},
"keywords": [
"documentation",
"vue",
"vuepress",
"generator"
],
"dependencies": {
"nprogress": "^0.2.0"
},
"author": "ULIVZ <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/vuejs/vuepress/issues"
},
"homepage": "https://github.com/vuejs/vuepress/packages/@vuepress/plugin-nprogress#readme"
}
3 changes: 2 additions & 1 deletion packages/@vuepress/theme-default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = (options, ctx) => ({

plugins: [
'@vuepress/active-header-links',
'@vuepress/search'
'@vuepress/search',
'@vuepress/plugin-nprogress'
]
})
13 changes: 0 additions & 13 deletions packages/@vuepress/theme-default/layouts/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
</template>

<script>
import Vue from 'vue'
import nprogress from 'nprogress'
import Home from '../components/Home.vue'
import Navbar from '../components/Navbar.vue'
import Page from '../components/Page.vue'
Expand Down Expand Up @@ -115,18 +113,7 @@ export default {
},
mounted () {
// configure progress bar
nprogress.configure({ showSpinner: false })
this.$router.beforeEach((to, from, next) => {
if (to.path !== from.path && !Vue.component(to.name)) {
nprogress.start()
}
next()
})
this.$router.afterEach(() => {
nprogress.done()
this.isSidebarOpen = false
})
},
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/theme-default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"dependencies": {
"@vuepress/plugin-active-header-links": "^1.0.0-alpha.30",
"@vuepress/plugin-search": "^1.0.0-alpha.30",
"@vuepress/plugin-nprogress": "^1.0.0-alpha.30",
"docsearch.js": "^2.5.2",
"nprogress": "^0.2.0",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2"
}
Expand Down
1 change: 0 additions & 1 deletion packages/@vuepress/theme-default/styles/theme.styl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@require './nprogress'
@require './code'
@require './custom-blocks'
@require './arrow'
Expand Down

0 comments on commit 25db1ba

Please sign in to comment.