1.0.1 • Published 2 years ago

nuxt-date-fns v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

date-fns plugin for Nuxt.

📦 Install

  1. Install nuxt-date-fns as development dependency:
npm i nuxt-date-fns -D
  1. Add it to the modules section of your nuxt.config:
import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
  modules: ['nuxt-date-fns']
})

🚀 Example

Use any date-fns methods in your Nuxt application.

<template>
  <div>
    {{ $dateFns.format(new Date(), 'dd-MM-yyyy') }}
  </div>
</template>

<script setup lang="ts">
// alternatively, you can also use it here
const { $dateFns } = useNuxtApp()
</script>

🔨 Config

NameDefaultDescription
format'yyyy-MM-dd'Date format (defaults to ISO 8601)
defaultLocaleenUSDefault locale, used by every function when no locale is specified
fallbackLocaleenUSFallback locale, used when specified locale is not supported

💻 Example - Config

import { defineNuxtConfig } from 'nuxt';

export default defineNuxtConfig({
  modules: ['nuxt-date-fns'],
  dateFns: {
    format: 'dd-MM-yyyy',
    defaultLocale: 'fr',
    fallbackLocale: 'enUS'
  }
});

📄 License

MIT License © 2022 - Arthur Dufour