21 lines
575 B
TypeScript
21 lines
575 B
TypeScript
import { clsx, type ClassValue } from 'clsx'
|
|
import { twMerge } from 'tailwind-merge'
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
|
return twMerge(clsx(inputs))
|
|
}
|
|
|
|
export function formatDate(date: Date) {
|
|
return Intl.DateTimeFormat('en-US', {
|
|
year: 'numeric',
|
|
month: 'long',
|
|
day: 'numeric',
|
|
}).format(date)
|
|
}
|
|
|
|
export function readingTime(html: string) {
|
|
const textOnly = html.replace(/<[^>]+>/g, '')
|
|
const wordCount = textOnly.split(/\s+/).length
|
|
const readingTimeMinutes = (wordCount / 200 + 1).toFixed()
|
|
return `${readingTimeMinutes} min read`
|
|
}
|