Skip to content

Commit

Permalink
chore: simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
ulivz committed May 21, 2018
1 parent 05cb65a commit 613ea7f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
5 changes: 0 additions & 5 deletions lib/app/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ export function injectMixins (options, mixins) {
options.mixins.push(...mixins)
}

export function pathToComponentName (pages, path) {
const page = findPageForPath(pages, path)
return page && page.key
}

export function findPageForPath (pages, path) {
for (let i = 0; i < pages.length; i++) {
const page = pages[i]
Expand Down
3 changes: 1 addition & 2 deletions lib/default-theme/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import Home from './Home.vue'
import Navbar from './Navbar.vue'
import Page from './Page.vue'
import Sidebar from './Sidebar.vue'
import { pathToComponentName } from '@app/util'
import store from '@app/store'
import { resolveSidebarItems } from './util'
import throttle from 'lodash.throttle'
Expand Down Expand Up @@ -94,7 +93,7 @@ export default {
nprogress.configure({ showSpinner: false })
this.$router.beforeEach((to, from, next) => {
if (to.path !== from.path && !Vue.component(pathToComponentName(this.$site.pages, to.path))) {
if (to.path !== from.path && !Vue.component(to.name)) {
nprogress.start()
}
next()
Expand Down
1 change: 1 addition & 0 deletions lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ async function genRoutesFile ({ siteData: { pages }, sourceDir, pageFiles }) {
const filePath = path.resolve(sourceDir, file)
let code = `
{
name: ${JSON.stringify(componentName)},
path: ${JSON.stringify(pagePath)},
component: ThemeLayout,
beforeEnter: (to, from, next) => {
Expand Down

0 comments on commit 613ea7f

Please sign in to comment.