function genChunkName (context, route) { const chunkName = relative(context, route.component) .split('/') .filter(s => s !== '..') .map(s => slugify(s)) .join('--') return `page--${chunkName}` }
function genComponent(item) { const component = JSON.stringify(item.component) const chunkName = JSON.stringify(item.chunkName) return [ `const ${item.variableName} = `, `() => import(/* webpackChunkName: ${chunkName} */ ${component})` ].join('') }
function addComponentHandler (state = { }, action) { return Object.assign({}, state, { components: [ ...state.components, action.component ] }) }
// Component const RoutePrivate = (props) => ( props.user.isAuthenticated ? props.role ? props.user.details.role === props.role ? <Route {...props} component={props.component}/> : <Redirect to={userRoutes.login.path}/> : <Route {...props} component={props.component}/> : <Redirect to={userRoutes.login.path}/> )
removeRoute (id) { const options = this._routes.by('id', id) this._pages.findAndRemove({ 'internal.route': id }) this._routes.findAndRemove({ id }) this._unwatchComponent(options.component) }
export default function (Vue, options, { router }) { Vue.component('VueRemarkContent', VueRemarkContent) router.beforeEach((to, from, next) => { if (typeof to.meta.$vueRemark === 'function') { to.meta.$vueRemark().then(() => next()) } else { next() } }) }
function findPageComponents(pages, pageComponents = {}) { if (!Array.isArray(pages)) return pageComponents; pages.forEach(page => { if (page.component) pageComponents[page.path] = page.component; else if (page.children) { findPageComponents(page.children, pageComponents); } }); return pageComponents; }
render() { const { store } = this.props; const { router } = store; return router.extra ? router.extra.component : null; }
function genChunkName (context, route) { const chunkName = relative(context, route.component) .split('/') .filter(s => s !== '..') .map(s => slugify(s)) .join('--') return `page--${chunkName}` }
function genComponent(item) { const component = JSON.stringify(item.component) const chunkName = JSON.stringify(item.chunkName) return [ `const ${item.variableName} = `, `() => import(/* webpackChunkName: ${chunkName} */ ${component})` ].join('') }
function addComponentHandler (state = { }, action) { return Object.assign({}, state, { components: [ ...state.components, action.component ] }) }
function findPageComponents(pages, pageComponents = {}) { if (!Array.isArray(pages)) return pageComponents; pages.forEach(page => { if (page.component) pageComponents[page.path] = page.component; else if (page.children) { findPageComponents(page.children, pageComponents); } }); return pageComponents; }
// Component const RoutePrivate = (props) => ( props.user.isAuthenticated ? props.role ? props.user.details.role === props.role ? <Route {...props} component={props.component}/> : <Redirect to={userRoutes.login.path}/> : <Route {...props} component={props.component}/> : <Redirect to={userRoutes.login.path}/> )
export default function (Vue, options, { router }) { Vue.component('VueRemarkContent', VueRemarkContent) router.beforeEach((to, from, next) => { if (typeof to.meta.$vueRemark === 'function') { to.meta.$vueRemark().then(() => next()) } else { next() } }) }
removeRoute (id) { const options = this._routes.by('id', id) this._pages.findAndRemove({ 'internal.route': id }) this._routes.findAndRemove({ id }) this._unwatchComponent(options.component) }