Nuxt/examples/routes-meta/middleware/theme.js

6 lines
203 B
JavaScript
Raw Normal View History

export default ({ route, store }) => {
2018-08-20 12:59:08 +00:00
// Take the last value (latest route child)
const theme = route.meta.reduce((theme, meta) => meta.theme || theme, 'light')
store.commit('SET_THEME', theme)
2018-08-20 12:59:08 +00:00
}