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

6 lines
205 B
JavaScript
Raw Normal View History

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