Using mdx in Rainbow

Using MDX in Rainbow to enrich article content with more components

Sat Sep 02 2023
224 words · 2 minutes

This article describes how to use the components provided by Rainbow in mdx to realize the functions that can’t be realized by normal md.

All the components shown in this article have been packaged and can be used directly by importing the components.

Components provided

The components provided by Rainbow are placed in the /mdx folders. Write something under the document properties (frontmatter):

ASTRO
import Collapse from "../../components/mdx/Collapse.astro";
import Diff from "../../components/mdx/Diff.astro";
import Error from "../../components/mdx/Error.astro";
import Info from "../../components/mdx/Info.astro";
import Kbd from "../../components/mdx/Kbd.astro";  
import Success from "../../components/mdx/Success.astro";
import Warning from "../../components/mdx/Warning.astro";
import TimeLine from "../../components/mdx/TimeLine.astro";
import LinkCard from "../../components/mdx/LinkCard.astro";

Then you can use them anywhere in the article.

Example Usage

Here are some examples of how to use these components:

Repository Cards

RA

Loading repository information...

ASTRO
<LinkCard
  title="Rainbow"
  desc="Rainbow is an elegant, simple, clean Astro blog template"
  url="https://github.com/EveSunMaple/Rainbow"
  img="/view.png"
/>

GitHub Stats

You can also display GitHub statistics for repositories:

EveSunMaple/Rainbow

GitHub Repository

42 Stars
15 Forks
3 Issues
12 Watchers

Primary Language

TypeScript

Contributors

5 contributors

YouTube Embeds

You can also embed YouTube videos directly in your MDX content:

Play

This makes it easy to include video content in your blog posts without having to deal with iframe code manually.

Conclusion

These MDX components make it easy to add rich, interactive content to your Rainbow blog posts. They provide a consistent look and feel while extending the capabilities beyond standard Markdown.


Thanks for reading!

Using mdx in Rainbow

Sat Sep 02 2023
224 words · 2 minutes

© Rainbow Coffs Harbour | CC BY-NC-SA 4.0