#Mdx file from an Astro component to Svelte component
3 messages · Page 1 of 1 (latest)
Hi @delicate nebula. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Based on the information provided in the extracts, it's not explicitly stated whether you can send the content of an MDX file from an Astro template to a Svelte component. However, Astro does allow you to import and use MDX files in your Astro components, and it also supports the use of Svelte components.
In Astro, you can import MDX files directly into your Astro files, giving you access to their Markdown content and other properties such as frontmatter values. This is done using an import statement or Astro.glob() for multiple pages (source (https://docs.astro.build/en/guides/markdown-content#importing-markdown)).
---
// Import a single file
import * as myPost from '../pages/post/my-post.md';
// Import multiple files with Astro.glob
const posts = await Astro.glob('../pages/post/*.md');
---
You can also use the Content component to render the full contents of a Markdown or MDX file (source (https://docs.astro.build/en/guides/markdown-content#the-content-component)).
---
import {Content as PromoBanner} from '../components/promoBanner.md';
---
<h2>Today's promo</h2>
<PromoBanner />
Astro also supports the use of Svelte components through its Svelte integration (source (https://docs.astro.build/en/guides/integrations-guide/svelte)).