unocss.config.ts
199 lines · 4922 bytes
5 symbols in this file
1/**
2 * All Rights Reserved
3 *
4 * Copyright (c) 2025 taskylizard
5 *
6 * All rights reserved. This code and its associated files may not be copied, modified, distributed, sublicensed, or used in any form, in whole or in part, without prior written permission from the copyright holder.
7 */
8import { FileSystemIconLoader } from '@iconify/utils/lib/loader/node-loaders'
9import { colors } from '@taskylizard/colors'
10import { resolve } from 'node:path'
11import {
12 defineConfig,
13 presetAttributify,
14 presetIcons,
15 presetUno,
16 presetWebFonts,
17 presetWind4,
18 transformerDirectives
19} from 'unocss'
20import { aliases } from './docs/.vitepress/configs/markdown/emoji'
21import {
22 LANG_FLAG_FALLBACK,
23 LANG_FLAG_ICONS
24} from './docs/.vitepress/configs/markdown/langFlags'
25
26const iconPrefixes = [
27 'octicon-',
28 'logos-',
29 'ic-',
30 'mingcute-',
31 'mdi-',
32 'material-symbols-',
33 'simple-icons-',
34 'lucide-',
35 'uil-',
36 'akar-icons-',
37 'map-',
38 'bi-',
39 'streamline-logos-',
40 'streamline-ultimate-',
41 'streamline-sharp-',
42 'iconoir-'
43]
44
45const emojiShortcodeExtractor = {
46 name: 'emoji-shortcode',
47 extract({ code }: { code: string }) {
48 const tokens = new Set<string>()
49 for (const [, markup] of code.matchAll(/:([A-Za-z0-9_+-]+):/g)) {
50 if (aliases[markup]) {
51 tokens.add(`i-${aliases[markup]}`)
52 } else if (iconPrefixes.some((p) => markup.startsWith(p))) {
53 tokens.add(`i-${markup}`)
54 }
55 }
56 return tokens
57 }
58}
59
60// Custom icons collection
61const customIcons = {
62 circle:
63 '<svg viewBox="0 0 120 120"><circle cx="60" cy="60" r="50"></circle></svg>'
64 // Add more custom icons here as needed
65}
66
67const platformIcons = [
68 'and',
69 'ios',
70 'win',
71 'app',
72 'lin',
73 'bsd',
74 'cmd',
75 'web'
76]
77 .map((token) => aliases[token])
78 .filter(Boolean)
79 .map((icon) => `i-${icon}`)
80
81const safelist = [
82 ...platformIcons,
83 'i-lucide-monitor',
84 ...Object.entries(colors).flatMap(([group, shades]) =>
85 Object.keys(shades).flatMap((shade) => [
86 `text-${group}-${shade}`,
87 `bg-${group}-${shade}`
88 ])
89 ),
90 'i-lucide:circle-plus',
91 'i-lucide:circle-alert',
92 'i-lucide:circle-x',
93 'i-lucide:lightbulb',
94 'i-lucide:heart',
95 'i-lucide:message-circle',
96 'i-lucide:copy',
97 'i-lucide:check',
98 'i-lucide:x',
99 'i-lucide:loader-circle',
100 'i-lucide:refresh-cw',
101 'i-lucide:settings',
102 'i-lucide:download',
103 'i-lucide:chevron-down',
104 'i-mdi-chevron-down',
105 'i-lucide:search',
106 'i-lucide:languages',
107 'i-lucide:shield',
108 'i-twemoji-no-one-under-eighteen',
109 'i-twemoji-red-heart',
110 'i-twemoji-orange-heart',
111 'i-twemoji-yellow-heart',
112 'i-twemoji-green-heart',
113 'i-twemoji-blue-heart',
114 'i-twemoji-purple-heart',
115 'i-twemoji-brown-heart',
116 'i-twemoji-black-heart',
117 'i-twemoji-white-heart',
118 'i-twemoji-sparkling-heart',
119 'i-twemoji-beating-heart',
120 'i-twemoji-growing-heart',
121 'i-twemoji-folded-hands',
122 'i-twemoji-glowing-star',
123 'i-twemoji-flag-united-arab-emirates',
124 ...Array.from(
125 new Set([...Object.values(LANG_FLAG_ICONS), LANG_FLAG_FALLBACK])
126 ).map(
127 (icon) => `i-twemoji-${icon}`
128 )
129]
130
131export default defineConfig({
132 content: {
133 filesystem: ['.vitepress/configs/constants.ts', 'docs/index.md']
134 },
135 extractors: [emojiShortcodeExtractor],
136 safelist,
137 theme: {
138 easing: {
139 'out-expo': 'cubic-bezier(0.16, 1, 0.3, 1)',
140 'in-expo': 'cubic-bezier(0.7, 0, 0.84, 0)'
141 },
142 colors: {
143 ...colors,
144 primary: 'var(--vp-c-brand-1)',
145 bg: 'var(--vp-c-bg)',
146 'bg-alt': 'var(--vp-c-bg-alt)',
147 'bg-elv': 'var(--vp-c-bg-elv)',
148 text: 'var(--vp-c-text-1)',
149 'text-2': 'var(--vp-c-text-2)',
150 div: 'var(--vp-c-divider)',
151 // Ayanami Blue
152 'brand': {
153 '50': 'oklch(0.965 0.011 256.71)',
154 '100': 'oklch(0.93 0.024 256.1)',
155 '200': 'oklch(0.861 0.048 253.25)',
156 '300': 'oklch(0.791 0.076 251.19)',
157 '400': 'oklch(0.722 0.105 247.48)',
158 '500': 'oklch(0.626 0.098 247.46)',
159 '600': 'oklch(0.523 0.081 246.86)',
160 '700': 'oklch(0.43 0.066 246.75)',
161 '800': 'oklch(0.335 0.052 246.76)',
162 '900': 'oklch(0.233 0.035 246.39)',
163 '950': 'oklch(0.186 0.029 247.31)'
164 }
165 }
166 },
167 presets: [
168 presetWind4({
169 preflights: {
170 theme: true
171 }
172 }),
173 presetAttributify(),
174 presetWebFonts({
175 fonts: {
176 serif: 'Source Serif 4 Variable',
177 pacifico: {
178 name: 'Pacifico',
179 weights: [400],
180 italic: true
181 }
182 }
183 }),
184 presetIcons({
185 scale: 1.2,
186 extraProperties: {
187 display: 'inline-block',
188 'vertical-align': '-0.125em', // changed from 'middle'
189 'min-width': '1.2rem'
190 },
191 warn: false,
192 collections: {
193 custom: FileSystemIconLoader(resolve(__dirname, 'docs/public/custom')),
194 inline: customIcons
195 }
196 })
197 ],
198 transformers: [transformerDirectives()]
199})