Skip to content

تكامل Astro

تكامل UnoCSS لـ Astro: @unocss/astro. راجع المثال.

التثبيت

bash
pnpm add -D unocss
bash
yarn add -D unocss
bash
npm install -D unocss
bash
bun add -D unocss
ts
import { defineConfig } from 'astro/config'
import UnoCSS from 'unocss/astro'

export default defineConfig({
  integrations: [
    UnoCSS(),
  ],
})

قم بإنشاء ملف uno.config.ts:

ts
import { defineConfig } from 'unocss'

export default defineConfig({
  // ...خيارات UnoCSS
})

إعادة تعيين الأنماط

افتراضياً، لن يتم حقن إعادة تعيين أنماط المتصفح. لتمكينه، قم بتثبيت حزمة @unocss/reset:

bash
pnpm add -D @unocss/reset
bash
yarn add -D @unocss/reset
bash
npm install -D @unocss/reset
bash
bun add -D @unocss/reset

وقم بتحديث astro.config.ts الخاص بك:

ts
import { defineConfig } from 'astro/config'
import UnoCSS from 'unocss/astro'

export default defineConfig({
  integrations: [
    UnoCSS({
      injectReset: true // أو مسار إلى ملف الإعادة
    }),
  ],
})

الاستخدام بدون إعدادات مسبقة

لا يأتي هذا المكون الإضافي مع أي إعدادات مسبقة افتراضية.

bash
pnpm add -D @unocss/astro
bash
yarn add -D @unocss/astro
bash
npm install -D @unocss/astro
bash
bun add -D @unocss/astro
ts
import UnoCSS from '@unocss/astro'

export default {
  integrations: [
    UnoCSS(),
  ],
}

لمزيد من التفاصيل، يرجى الرجوع إلى مكون Vite الإضافي.

INFO

إذا كنت تبني إطار عمل meta على رأس UnoCSS، راجع هذا الملف للحصول على مثال حول كيفية ربط الإعدادات المسبقة الافتراضية.

ملاحظات

يجب وضع مكونات client:only في مجلد components أو إضافتها إلى تكوين content الخاص بـ UnoCSS من أجل معالجتها.

Released under the MIT License.