This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html data-cfg='{ "routeData": { "routes": [] } }'></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const routes = [ | |
{ | |
"name": "cms-page-2", | |
"path": "/work", | |
"component": function VueComponent() {}, | |
"meta": { | |
"api": { | |
"fetch": function(params, query) {}, | |
"params": {}, | |
"query": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"fetched": { | |
"containers": { | |
"home": { | |
"plugins": [], | |
"type": "cmp-home" | |
}, | |
"main": { | |
"plugins": [], | |
"type": "cmp-main" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"plugins": [ | |
{ | |
"content": { | |
"src": "static/assets/img/alpaca.img", | |
"alt": "Alpaca grazing" | |
}, | |
"type": "cmp-image" | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"fetched": { | |
"partials": { | |
"menu": { | |
"content": {}, | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
beforeRouteEnter(to, from, next) { | |
const Fetched = to.meta.api.fetch(to.params, to.query); | |
next(vm => Fetched.then((vm) => { | |
vm.$set(vm, 'routeData', fetched); | |
}); | |
}, | |
beforeRouteUpdate(to, from, next) { | |
const Fetched = to.meta.api.fetch(to.params, to.query); | |
Fetched.then(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setEndpoint(store, presets) { | |
return function fetch(route) { | |
// 1. Merge params and query with route presets | |
const params = Object.assign({}, presets.params, route.params); | |
const query = Object.assign({}, presets.query, route.query); | |
// 2. Create compiled endpoint url | |
const url = compileUrl(presets.url, params, query); | |
// 3. Push available data into the store's endpoint address |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getRouteData({ commit, state, dispatch }, { url }) { | |
let FetchPromise = state.routes[url]; | |
if (FetchPromise) { | |
return FetchPromise; | |
} | |
return new Promise((resolve, reject) => { | |
Axios.request({ url }).then( | |
(request) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"routes": [ | |
{ | |
"name": "cms-page-2", | |
"path": "/work", | |
"component": "work", | |
"api": { | |
"fetch": { | |
"url": "/api/en/pages/work", | |
"params": {}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Map global filters for being used from within `methods`. This makes them usable in js as well as templates | |
* @param {Array} filters - A list of registered filter names | |
* @return {Object) An object containing filters and their functions | |
*/ | |
export function mapFilters(filters) { | |
return filters.reduce((result, filter) => { | |
result[filter] = function(...args) { | |
return this.$options.filters[filter](...args); | |
}; |
OlderNewer