Installing a Vite or Rollup plugin
هذا المحتوى غير متوفر بلغتك بعد.
Astro builds on top of Vite, and supports both Vite and Rollup plugins. This recipe uses a Rollup plugin to add the ability to import a YAML (.yml
) file in Astro.
Recipe
Section titled Recipe-
Install
@rollup/plugin-yaml
: -
Import the plugin in your
astro.config.mjs
and add it to the Vite plugins array: -
Finally, you can import YAML data using an
import
statement:While you can now import YAML data in your Astro project, your editor will not provide types for the imported data. To add types, create or find an existing
*.d.ts
file in thesrc
directory of your project and add the following:This will allow your editor to provide type hints for your YAML data.