rndr realm

Creative Studio

Getting Started with Next.js 15 and MDX

Welcome to this sample blog post! This article demonstrates various MDX features and markdown syntax that you can use in your blog.

Introduction

MDX allows you to use JSX in your markdown content, making it incredibly powerful for creating interactive blog posts. You can write regular markdown and seamlessly integrate React components.

Features Showcase

Text Formatting

Here are some common text formatting options:

  • Bold text using **text**
  • Italic text using *text*
  • Bold and italic using ***text***
  • ~~Strikethrough~~ using ~~text~~
  • Inline code using backticks

Lists

Unordered List

  • First item
  • Second item
    • Nested item 1
    • Nested item 2
  • Third item

Ordered List

  1. First step
  2. Second step
  3. Third step

Code Blocks

Here's a JavaScript code example:

1
// Example: React Server Component
2
export default async function BlogPost({ params }) {
3
const post = await getPost(params.slug);
4
5
return (
6
<article>
7
<h1>{post.title}</h1>
8
<div>{post.content}</div>
9
</article>
10
);
11
}

TypeScript example:

1
interface BlogPost {
2
title: string;
3
description: string;
4
date: string;
5
slug: string;
6
content: string;
7
}
8
9
const posts: BlogPost[] = [];

Blockquotes

"The only way to do great work is to love what you do."

 Steve Jobs

You can also nest blockquotes:

This is a blockquote

This is a nested blockquote

It can contain formatted text too!

Check out Next.js documentation for more information.

Here's how you'd add an image:

1
![Alt text](https://via.placeholder.com/800x400)

MDX Components

One of the most powerful features of MDX is the ability to use React components directly in your markdown.

1
export const Highlight = ({ children, color }) => (
2
<span
3
style={{
4
backgroundColor: color,
5
borderRadius: "2px",
6
color: "#fff",
7
padding: "0.2rem",
8
}}
9
>
10
{children}
11
</span>
12
);
13
14
<Highlight color="#25c2a0">This is highlighted!</Highlight>;

Custom Callouts

You can create custom components for callouts:

1
<div className="callout callout-info">
2
<strong>Info:</strong> This is an informational message.
3
</div>
4
5
<div className="callout callout-warning">
6
<strong>Warning:</strong> This is a warning message.
7
</div>
8
9
<div className="callout callout-success">
10
<strong>Success:</strong> This is a success message.
11
</div>

Best Practices

  1. Keep frontmatter consistent - Use the same fields across all posts
  2. Optimize images - Use Next.js Image component for better performance
  3. Add metadata - Include description and tags for SEO
  4. Use semantic HTML - Helps with accessibility and SEO
  5. Test responsiveness - Ensure your content looks good on all devices

Conclusion

This sample article demonstrates the flexibility and power of MDX for creating rich, interactive blog content. You can:

  • Write regular markdown
  • Use React components
  • Add custom styling
  • Include code examples
  • Create interactive elements

Happy blogging!

Getting Started with Next.js 15 and MDX | RNDR Realm