nuxt-viewport
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -5,2 +5,9 @@ # Changelog | ||
### [0.0.5](https://github.com/mvrlin/nuxt-viewport/compare/v0.0.4...v0.0.5) (2021-06-17) | ||
### Bug Fixes | ||
* **runtime:** parse cookie and user-agent only if request headers available ([e755ab5](https://github.com/mvrlin/nuxt-viewport/commit/e755ab5897f79d36138b88bf0fac2f4b02f30708)) | ||
### [0.0.4](https://github.com/mvrlin/nuxt-viewport/compare/v0.0.3...v0.0.4) (2021-03-03) | ||
@@ -7,0 +14,0 @@ |
@@ -8,9 +8,16 @@ import cookie from 'cookie' | ||
export default async function (ctx, inject) { | ||
const { headers } = ctx.ssrContext.req | ||
const options = <%= serialize(options) %> | ||
const { req = {} } = ctx.ssrContext | ||
const requestCookies = cookie.parse(headers.cookie || '') | ||
const cookieViewport = requestCookies[options.cookieName] | ||
let cookieViewport = '' | ||
let requestCookies = {} | ||
let userAgent = '' | ||
const breakpoint = await detectBreakpoint.call(options, cookieViewport, headers['user-agent']) | ||
if (req.headers) { | ||
requestCookies = cookie.parse(req.headers.cookie || '') | ||
cookieViewport = requestCookies[options.cookieName] | ||
userAgent = req.headers['user-agent'] | ||
} | ||
const breakpoint = await detectBreakpoint.call(options, cookieViewport, userAgent) | ||
const viewport = useViewport(options, breakpoint) | ||
@@ -17,0 +24,0 @@ |
{ | ||
"name": "nuxt-viewport", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Define custom viewports for your Nuxt project", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -60,8 +60,11 @@ # nuxt-viewport | ||
```js | ||
import { defineComponent, watch } from '@nuxtjs/composition-api' | ||
import { defineComponent, useContext, watch } from '@nuxtjs/composition-api' | ||
export default defineComponent({ | ||
setup(_, { root }) { | ||
setup() { | ||
// Context. | ||
const context = useContext() | ||
// Viewport module. | ||
const viewport = root.$viewport | ||
const viewport = context.$viewport | ||
@@ -216,3 +219,3 @@ // Watch breakpoint for updates. | ||
// Result: true. | ||
$viewport.match('tablet', 'mobileWide') | ||
$viewport.matches('tablet', 'mobileWide') | ||
``` | ||
@@ -219,0 +222,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16734
317
254