| @@ -7,6 +7,7 @@ |
| 7 | 7 | */ |
| 8 | 8 | import type { IconifyJSON } from '@iconify-json/octicon' |
| 9 | 9 | import type { MarkdownRenderer } from 'vitepress' |
| 10 | import { iconTooltips } from './tooltip' |
| 10 | 11 | |
| 11 | 12 | // Icons that need to be used should be imported here |
| 12 | 13 | import { icons as akar } from '@iconify-json/akar-icons' |
| @@ -133,6 +134,31 @@ const aliases: Record<string, string> = { |
| 133 | 134 | hs: 'mdi-hulu' |
| 134 | 135 | } |
| 135 | 136 | |
| 137 | // Tooltip labels for icon aliases (desktop hover) |
| 138 | const aliasLabels: Record<string, string> = { |
| 139 | s: 'Favorite', src: 'Source Code', cs: 'Closed Source', |
| 140 | e: 'Extension / Plugin', prx: 'Proxies', ero: 'R18', |
| 141 | acc: 'Needs account', help: 'Help / Docs', more: 'Related', |
| 142 | and: 'Android', ios: 'iOS / iPadOS', app: 'MacOS', |
| 143 | win: 'Windows', lin: 'Linux', bsd: 'BSD', |
| 144 | cmd: 'CLI / TUI', ff: 'Firefox', cr: 'Chromium', web: 'Web', |
| 145 | strm: 'Stream', ddl: 'Online / DDL', mag: 'Torrent / p2p', |
| 146 | lcl: 'Local file', batch: 'Batch Download', |
| 147 | sp: 'Single Page Mode', dp: 'Double Page Mode', ls: 'Long-Strip Mode', |
| 148 | paid: 'Paid', sub: 'Subscription', free: 'Has free content', |
| 149 | coin: 'Coin / Point', fm: 'Freemium', |
| 150 | d: 'Discord', f: '4chan', x: 'Twitter', tg: 'Telegram', |
| 151 | mal: 'MyAnimeList', al: 'AniList', k: 'Kitsu', simkl: 'Simkl', |
| 152 | sgd: 'Google Drive', sm: 'MEGA', smf: 'MediaFire', host: 'Other Host', |
| 153 | fjp: 'Japan', fkr: 'Korea', fcn: 'China', |
| 154 | js: 'JavaScript', css: 'CSS', py: 'Python', dock: 'Docker', |
| 155 | n: 'Nightly build', alt: 'Alternative', rss: 'RSS Feed', tf: 'Testflight', |
| 156 | yes: 'Yes / Available', no: 'No / Unavailable', |
| 157 | global: 'Global', cc: 'Subtitles / CC', hs: 'Hardsubs', |
| 158 | up: 'More Info', ms: 'Feedback', |
| 159 | sync: 'Sync', ie: 'Import / Export' |
| 160 | } |
| 161 | |
| 136 | 162 | // Custom icons using UnoCSS inline collection |
| 137 | 163 | const customIconAliases: Record<string, string> = { |
| 138 | 164 | 'custom-circle': 'inline-circle' |
| @@ -163,26 +189,26 @@ export { aliases, defs } |
| 163 | 189 | export function emojiRender(md: MarkdownRenderer) { |
| 164 | 190 | md.renderer.rules.emoji = (tokens, idx) => { |
| 165 | 191 | const markup = tokens[idx].markup |
| 192 | const label = aliasLabels[markup] || iconTooltips[markup] |
| 193 | |
| 194 | const tip = label?.replace(/"/g, '"') |
| 195 | const wrap = (cls: string) => tip |
| 196 | ? `<span class="icon-tip" data-tip="${tip}" tabindex="-1"><span class="${cls}"></span></span>` |
| 197 | : `<span class="${cls}"></span>` |
| 166 | 198 | |
| 167 | 199 | // Check for custom icon aliases first |
| 168 | | if (customIconAliases[markup]) { |
| 169 | | return `<span class="i-${customIconAliases[markup]}"></span>` |
| 170 | | } |
| 200 | if (customIconAliases[markup]) return wrap(`i-${customIconAliases[markup]}`) |
| 171 | 201 | |
| 172 | 202 | // Check for aliases |
| 173 | | if (aliases[markup]) { |
| 174 | | return `<span class="i-${aliases[markup]}"></span>` |
| 175 | | } |
| 203 | if (aliases[markup]) return wrap(`i-${aliases[markup]}`) |
| 176 | 204 | |
| 177 | 205 | // Check for prefixed icons |
| 178 | 206 | for (const emoji of emojis) { |
| 179 | | if (markup.startsWith(emoji.prefix!)) { |
| 180 | | return `<span class="i-${markup}"></span>` |
| 181 | | } |
| 207 | if (markup.startsWith(emoji.prefix!)) return wrap(`i-${markup}`) |
| 182 | 208 | } |
| 183 | 209 | |
| 184 | 210 | // Default to twemoji |
| 185 | | return `<span class="i-twemoji-${markup}"></span>` |
| 211 | return wrap(`i-twemoji-${markup}`) |
| 186 | 212 | } |
| 187 | 213 | } |
| 188 | 214 | |