Register Vue.js Filters as Plugins in Nuxt

InstructorJohn Lindquist

Share this video with your friends

Send Tweet

Vue.js filters need to run before your app starts. In Nuxt, you do this by adding the filter as a plugin then registering it with your nuxt.config.js. This lesson walks you through create a date filter to better visually format the time.

Rou Hun Fan
~ 7 years ago

what editor is this? I'm wondering how you're geting the full list of functions within date-fns

Christopher Hall
~ 5 years ago

For anyone else following along, with the release of v2.0 of the "date-fns" module, the distanceInWordsToNow function was deprecated. You will want to use the formatDistanceToNow function instead.

In fact, you can use the addSuffix: true option to automatically add a prefix or suffix, such as DATE ago or in DATE. formatDistanceToNow(time, {addSuffix: true})

Josh Ellis
~ 5 years ago

For anyone else following along, with the release of v2.0 of the "date-fns" module, the distanceInWordsToNow function was deprecated. You will want to use the formatDistanceToNow function instead.

Appreciate this