* Update Nuxt dependencies * Fix ref access in ChartDisplay * Fix feature flags cookie options type error * Specify type-only imports * Fix shorthands access to tags outside of reactive scope * Replace most useRoute calls with useRoute from vue-router Nuxt's version of this composable is horrendously broken (nuxt/nuxt#21340) * Import all svgs with ?component parameter Fixes weird hydration issues + gives correct type
19 lines
540 B
TypeScript
19 lines
540 B
TypeScript
import { createFormatter, type Formatter } from '@vintl/how-ago'
|
|
import type { IntlController } from '@vintl/vintl/controller'
|
|
|
|
const formatters = new WeakMap<IntlController<any>, Formatter>()
|
|
|
|
export function useRelativeTime(): Formatter {
|
|
const vintl = useVIntl()
|
|
|
|
let formatter = formatters.get(vintl)
|
|
|
|
if (formatter == null) {
|
|
const formatterRef = computed(() => createFormatter(vintl.intl))
|
|
formatter = (value, options) => formatterRef.value(value, options)
|
|
formatters.set(vintl, formatter)
|
|
}
|
|
|
|
return formatter
|
|
}
|