unocss.config.ts

241b6ecaf91782fb8d110f88effc79c649ee849e
wotaku/unocss.config.ts history · blame · raw

67 lines · 1846 bytes

 1/**
 2 *  Copyright (c) 2024 taskylizard
 3 *
 4 *  Licensed under the Apache License, Version 2.0 (the "License");
 5 *  you may not use this file except in compliance with the License.
 6 *  You may obtain a copy of the License at
 7 *
 8 *  http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 *  Unless required by applicable law or agreed to in writing, software
11 *  distributed under the License is distributed on an "AS IS" BASIS,
12 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 *  See the License for the specific language governing permissions and
14 *  limitations under the License.
15 */
16import { colors } from '@taskylizard/colors'
17import { FileSystemIconLoader } from '@iconify/utils/lib/loader/node-loaders'
18import { resolve } from 'node:path'
19import {
20  defineConfig,
21  presetUno,
22  presetAttributify,
23  presetIcons,
24  transformerDirectives
25} from 'unocss'
26
27const safelist = Object.entries(colors).flatMap(([group, shades]) =>
28  Object.keys(shades).flatMap((shade) => [
29    `text-${group}-${shade}`,
30    `bg-${group}-${shade}`
31  ])
32)
33
34export default defineConfig({
35  content: {
36    filesystem: ['.vitepress/configs/constants.ts']
37  },
38  safelist,
39  theme: {
40    colors: {
41      ...colors,
42      primary: 'var(--vp-c-brand-1)',
43      bg: 'var(--vp-c-bg)',
44      'bg-alt': 'var(--vp-c-bg-alt)',
45      'bg-elv': 'var(--vp-c-bg-elv)',
46      text: 'var(--vp-c-text-1)',
47      'text-2': 'var(--vp-c-text-2)',
48      div: 'var(--vp-c-divider)'
49    }
50  },
51  presets: [
52    presetUno(),
53    presetAttributify(),
54    presetIcons({
55      scale: 1.2,
56      extraProperties: {
57        display: 'inline-block',
58        'vertical-align': 'middle'
59      },
60      warn: true,
61      collections: {
62        custom: FileSystemIconLoader(resolve(__dirname, '.docs/public/custom'))
63      }
64    })
65  ],
66  transformers: [transformerDirectives()]
67})