Nuxt/examples/dynamic-layouts/middleware/mobile.js

5 lines
159 B
JavaScript
Raw Normal View History

2017-03-17 17:03:12 +00:00
export default function (ctx) {
2018-08-08 10:54:05 +00:00
const userAgent = ctx.req ? ctx.req.headers['user-agent'] : navigator.userAgent
2017-03-17 17:03:12 +00:00
ctx.isMobile = /mobile/i.test(userAgent)
}