-
Notifications
You must be signed in to change notification settings - Fork 15
Nuxt3 Support #376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Very much looking forward to you sending me your PR! |
we also need to declare: declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
$dayjs(date?: dayjs.ConfigType): dayjs.Dayjs
}
} in order to use it in templates without errors. |
Well if you really need to use it now you can just create a plugin // ~/plugins/dayjs.ts
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import localizedFormat from 'dayjs/plugin/localizedFormat';
import updateLocale from 'dayjs/plugin/updateLocale';
dayjs.extend(relativeTime);
dayjs.extend(localizedFormat);
dayjs.extend(updateLocale);
// OTHER PLUGINS
export default defineNuxtPlugin(() => {
return {
provide: {
dayjs,
},
};
}); <script setup lang="ts">
const { $dayjs } = useNuxtApp();
</script>
<template>
<div>
Now: {{ $dayjs() }}
</div>
</template> |
so when using this plugin, when i try to run
Not sure if it's a nuxt issue or dayjs? |
I haven't tested my version of the nuxt3 plugin with a static-compiled version yet - maybe try adding the |
We need it.thanks! |
I've created a Nuxt 3 module using the official Nuxt 3 module-builder: It's on npm currently at: https://www.npmjs.com/package/@nathanchase/nuxt-dayjs-module It's barebones, and some of the plugins I use are hardcoded into it. Someone else might be able to make it more modular to use the same I wasn't sure the protocol of how to submit this as a PR for this module, since it's vastly different. You can check the playground for examples of the module working. Take a look @potato4d, and see what you think. |
Well, I'm having some issue when actually using the module in Nuxt 3 where I get an error: |
OK! Got it working! v1.0.7 - Now also supports configuration in nuxt.config, like: dayjs: {
plugins: [
'duration',
'relativeTime',
'advancedFormat',
'weekday'
]
} |
Hi @potato4d! I was working on a Nuxt 3 version of this module a while ago. Would you be interested in taking a look? |
@potato4d I sure am interested. Any status on this ? |
9 month without any update in the branch. Is it still maintained? |
I am working on an official nuxt3 module that will be live next week @Dodje, i will close this issue with its URL ASAP |
Uh oh!
There was an error while loading. Please reload this page.
UPDATE: 3rd party module available https://github.com/fumeapp/dayjs
I have written a DayJS plugin for nuxt3 and so far its working pretty well:
plugnis/dayjs.ts
I assume next steps are to transfer this into the template/runtime format and plug in the locale config.
The text was updated successfully, but these errors were encountered: