From 76ccf5775e387b43702a61f24f7fedf7b14050b5 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sun, 8 Jan 2023 09:21:25 +0100 Subject: [PATCH] feat: support @username@twitter.com as link --- composables/i18n.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/composables/i18n.ts b/composables/i18n.ts index 7c4b8724..8e85ab06 100644 --- a/composables/i18n.ts +++ b/composables/i18n.ts @@ -2,11 +2,11 @@ import type { MaybeComputedRef, MaybeRef, UseTimeAgoOptions } from '@vueuse/core const formatter = Intl.NumberFormat() -export const formattedNumber = (num: number, useFormatter: Intl.NumberFormat = formatter) => { +export function formattedNumber(num: number, useFormatter: Intl.NumberFormat = formatter) { return useFormatter.format(num) } -export const useHumanReadableNumber = () => { +export function useHumanReadableNumber() { const { n, locale } = useI18n() const fn = (num: number) => { @@ -29,10 +29,8 @@ export const useHumanReadableNumber = () => { } } -export const useFormattedDateTime = ( - value: MaybeComputedRef, - options: Intl.DateTimeFormatOptions = { dateStyle: 'long', timeStyle: 'medium' }, -) => { +export function useFormattedDateTime(value: MaybeComputedRef, + options: Intl.DateTimeFormatOptions = { dateStyle: 'long', timeStyle: 'medium' }) { const { locale } = useI18n() const formatter = $computed(() => Intl.DateTimeFormat(locale.value, options)) return computed(() => { @@ -41,7 +39,7 @@ export const useFormattedDateTime = ( }) } -export const useTimeAgoOptions = (short = false): UseTimeAgoOptions => { +export function useTimeAgoOptions(short = false): UseTimeAgoOptions { const { d, t, n: fnf, locale } = useI18n() const prefix = short ? 'short_' : '' @@ -56,7 +54,7 @@ export const useTimeAgoOptions = (short = false): UseTimeAgoOptions => { return { rounding: 'floor', showSecond: !short, - updateInterval: short ? 60_000 : 1_000, + updateInterval: short ? 60000 : 1000, messages: { justNow: t('time_ago_options.just_now'), // just return the value