Skip to content

Releases: nuxt/vue-meta

v2.3.0

08 Oct 09:33
Compare
Choose a tag to compare

Highlights

Adding additional meta info

Example of adding additional meta info for eg a third party plugin:

const { set, remove } = app.$meta().addApp('custom')

set({
  meta: [{ charset: 'utf=8' }]
})

setTimeout(() => remove(), 3000)

There is no reactivity for custom apps. You need to take care of that and call set and remove when apropiate. If you call addApp.set on the client before the app is mounted, the tags will be processed on the first refresh. If you call set when the app is mounted they tags are immediately processed.

The function is called addApp because the added metaInfo is treated exactly the same as when there are multiple apps on one page. Eg the tags that will be added will also list the appId you specifiy:

<meta data-vue-meta="custom" charset="utf-8">

New SSR injector helpers

So templates can be a little less verbose:

Old: https://github.com/nuxt/vue-meta/blob/fc71e1f1c4ca27e2eaf99e288c005976d492c004/examples/ssr/app.template.html
New: https://github.com/nuxt/vue-meta/blob/master/examples/ssr/app.template.html

Add line break (SSR only)

Pass either a boolean true to inject().head(true), inject().bodyPrepend(true) or inject().bodyAppend(true) to insert a linebreak after all tags.

If you want to keep using the old syntax, pass a prop ln: true as arg: meta.script.text({ body: true, ln: true })

Support setting attributes from multiple apps

The behaviour that vue-meta always adds data- attributes to track attributes on the client side has been changed. Instead of a data attribute we keep a local attributeMap object in the attribute updater which also adds support for updating attributes from multiple apps. To track this data from a ssr page, the data- tag is still added but with a JSON encoded map.

For example

// data
metaInfo = {
  bodyAttr: { foo: 'bar', fizz: ['fuzz', 'fozz'] }
}

// ssr tag
<body foo="bar" fizz="fuzz fozz" data-vue-meta="%7B%22foo%22:%7B%22ssr%22:%22bar%22%7D,%22fizz%22:%7B%22ssr%22:%5B%22fuzz%22,%22fozz%22%5D%7D%7D">

// tag after hydration
<body foo="bar" fizz="fuzz fozz">

// attribute map (values listed per app id)
{ bodyAttrs: {
  foo: { ssr: 'bar' },
  fizz: { ssr: ['fuzz', 'fozz'] }
}}

Change plugin options during runtime

Some plugin options can be changed during runtime by calling app.$meta().setOptions(). Besides the two new options below you can also use enable refreshOnceOnNavigation this way (its not possible to disable refreshOnceOnNavigation)

New option debounceWait

You can now configure for how long vue-meta debounces meta updates. The default value is 10ms.

This option can be set during runtime:

// debounce meta updates for 50ms 
app.$meta().setOptions({ debounceWait: 50 })

New option waitOnDestroyed

Once a component is destroyed, vue-meta will update the meta information to make sure any info added by the destroyed component is removed. Default value is true

Previously this always set an interval of 50ms to make sure to wait until the element had been removed (due to transitions). If you set waitOnDestroyed: false then the destroyed update will always be called in the nextTick instead.

Note that destroyed updates are also debounced with other lifecycle hook updates

This option can be set during runtime:

app.$meta().setOptions({ waitOnDestroyed: false })

Changelog

Features

  • feat: add options debounceWait (d43b77c)
  • feat: add option waitOnDestroyed (f745059)
  • feat: add possibility to add additional meta info (0ab76ee)
  • feat: add support for setting attributes from multiple apps (d9b0ab2)
  • feat: enable setting refreshOnceOnNavigation during runtime (9d14387)

Fixes

  • fix: use computed prop (which uses caching) instead of calling the fn directly (c344d60)

Refactors

  • refactor: destroyed never runs on server anyway (631cc9c)
  • refactor: minimize function calls / use of bind (0e49a9c)
  • refactor: prefer functions over closures for hooks (54ea6c6)
  • refactor: small bundle size improvements (9eba2b5)

Documentation

  • docs: add Factor to frameworks (#459) (Andrew Powers) (da0ba13)
  • docs: Use direct link to Nuxt documentation (#446) (novellac) (20ac995)

Chore

  • chore: add missing (c1b01b9)
  • chore: dist size improvements (ee12bfc)
  • chore: fix lint (b73b8ed)
  • chore: lint & fix test (ae98f65)
  • chore: prevent enhancements to go stale (f1ed379)
  • chore: strip bundles deepmerge even more (398d1af)
  • chore: stripped deepmerge a bit too much (695159f)
  • chore: update dependencies (47a1dde)

Tests

  • test: add tests for new functionalities (a2f0e7d)
  • test: build ssr fixture in test so we can collect coverage (dcdd47a)

Miscellaneous

  • example: cleartimeout in ssr example (9225d5e)
  • example: update dependencies (1854018)

v2.2.2

30 Aug 16:32
Compare
Choose a tag to compare

This release provides a workaround for a memory leak that was present in vue-meta. We recommend everybody to upgrade as soon as possible.

Bug Fixes

  • workaround for memoryleak in destroyed hook (ec7b1fb)
  • types: add json property (#439) (96a14f7)
  • types: add "content" property to MetaPropertyEquiv and remove "name" (#436) (4384f44)
  • types: export metaInfo types directly from index (#441) (dc30544)

Thanks to

v2.2.1

30 Aug 16:24
Compare
Choose a tag to compare

Bug Fixes

v2.2.0

04 Aug 10:34
Compare
Choose a tag to compare

Features

  • support generating tags directly from metaInfo object (cb2758e)

v2.1.1

27 Jul 08:13
Compare
Choose a tag to compare

Bug Fixes

  • babel config for rollup (71b2d52)

v2.1.0

24 Jul 14:36
Compare
Choose a tag to compare

The v2.1 release adds new features which where originally mostly postponed for v3, but have been brought forward due to various reasons.

As the docs have been updated to reflect the new features, we will link to the docs if you wish more detials:

Features

  • add option for prepending (no)script to body (#410) (05163a7)
  • auto add ssrAttribute to htmlAttrs (9cf6d32)
  • enable onload callbacks (#414) (fc71e1f)
  • make ssr app id configurable (b0c85e5)
  • support json content (without disabling sanitizers) (#415) (51fe6ea)

Bug Fixes

  • also use ssrAppId for client update (50c0509)
  • don't generate <title> tag if metaInfo.title is null or false (#409) (39ef287)
  • dont update title on client with falsy value except empty string (6efcdf1)

Thanks to

v2.0.5

24 Jul 14:32
Compare
Choose a tag to compare

Bug Fixes

  • add warning for v1 boolean attribute syntax (bfeab17)
  • dont change title when value is undefined (fix #396) (90f9710)
  • ensure hasAttribute exists on $root.$el (f1511ac)
  • only show boolean attrs with truthy value (1d9072a)

Tests

  • enable all getMetaInfo tests again (24d7fee)

Thanks to

v2.0.4

22 Jun 15:07
Compare
Choose a tag to compare

Bug Fixes

  • add warning for v1 boolean attribute syntax (bfeab17)
  • dont change title when value is undefined (fix #396) (90f9710)

v2.0.3

22 Jun 15:05
Compare
Choose a tag to compare

Bug Fixes

  • $meta can be called server side before app is initiated (ecd725d)

v2.0.2

10 Jun 10:48
Compare
Choose a tag to compare

Bug Fixes

  • correctly transpile builds (eg ie compatibility) (6751d24)
  • use simple polyfilled includes method (623970d)