1
0
mirror of https://github.com/elk-zone/elk synced 2024-11-23 22:56:09 +09:00
elk/config/emojis.ts
2023-01-07 10:31:48 +01:00

24 lines
849 B
TypeScript

// @unimport-disabled
import { emojiFilename, emojiPrefix, emojiRegEx } from '@iconify-emoji/twemoji'
import type { EmojiRegexMatch } from '@iconify/utils/lib/emoji/replace/find'
import { getEmojiMatchesInText } from '@iconify/utils/lib/emoji/replace/find'
// Re-export everything from package
export * from '@iconify-emoji/twemoji'
// Package name
export const iconifyEmojiPackage = '@iconify-emoji/twemoji'
export function getEmojiAttributes(input: EmojiRegexMatch | string) {
const match = typeof input === 'string'
? getEmojiMatchesInText(emojiRegEx, input)?.[0]
: input
const file = emojiFilename(match)
const className = `iconify-emoji iconify-emoji--${emojiPrefix}${file.padding ? ' iconify-emoji-padded' : ''}`
return {
class: className,
src: `/emojis/${emojiPrefix}/${file.filename}`,
alt: match.match,
}
}