Hello blog!
Welcome to my blog! This is a test post showcasing various MDX features and formatting options.
Hello blog! 👋
Welcome to my blog! This is a test post where I'm exploring all the amazing features that MDX has to offer. Let's dive into the various formatting options and see what works best.
What is MDX?
MDX is a powerful format that lets you write JSX directly in your Markdown documents. It combines the simplicity of Markdown with the power of React components, making it perfect for technical blogs where you need both rich content and interactive elements.
Key Features of MDX
MDX brings together the best of both worlds:
Why I started this blog
I've been building web applications for a while now, and I thought it was time to share my experiences, lessons learned, and cool discoveries with the developer community.
Here are a few reasons why I decided to start blogging:
Code Examples
Let's test some code highlighting with different languages:
Frontend Examples
Here are some examples from the frontend world:
TypeScript/React Component
interface BlogPostProps {
title: string;
description: string;
date: string;
readTime: string;
tags: string[];
}
const BlogPost: React.FC<BlogPostProps> = ({
title,
description,
date,
readTime,
tags
}) => {
return (
<article className="max-w-2xl mx-auto">
<header className="mb-8">
<h1 className="text-3xl font-bold mb-2">{title}</h1>
<p className="text-muted-foreground mb-4">{description}</p>
<div className="flex items-center gap-4 text-sm text-muted-foreground">
<time dateTime={date}>{new Date(date).toLocaleDateString()}</time>
<span>{readTime}</span>
</div>
<div className="flex gap-2 mt-4">
{tags.map((tag) => (
<span
key={tag}
className="px-2 py-1 bg-primary/10 text-primary rounded-md text-xs"
>
#{tag}
</span>
))}
</div>
</header>
</article>
);
};
Backend Examples
Now let's look at some backend code:
Next.js API Route
// pages/api/blog/[slug].js
export default async function handler(req, res) {
const { slug } = req.query;
if (req.method === 'GET') {
try {
const post = await getBlogPost(slug);
if (!post) {
return res.status(404).json({ error: 'Post not found' });
}
res.status(200).json(post);
} catch (error) {
console.error('Error fetching blog post:', error);
res.status(500).json({ error: 'Internal server error' });
}
} else {
res.setHeader('Allow', ['GET']);
res.status(405).end(`Method ${req.method} Not Allowed`);
}
}
Python Script
import os
import json
from datetime import datetime
def generate_blog_metadata(posts_dir: str) -> dict:
"""
Generate metadata for all blog posts in a directory.
"""
metadata = {
'posts': [],
'generated_at': datetime.now().isoformat(),
'total_posts': 0
}
for filename in os.listdir(posts_dir):
if filename.endswith('.mdx'):
post_path = os.path.join(posts_dir, filename)
with open(post_path, 'r', encoding='utf-8') as file:
content = file.read()
# Extract frontmatter (simplified)
if content.startswith('---'):
end_index = content.find('---', 3)
frontmatter = content[3:end_index]
metadata['posts'].append({
'filename': filename,
'slug': filename.replace('.mdx', ''),
'frontmatter': frontmatter.strip()
})
metadata['total_posts'] = len(metadata['posts'])
return metadata
# Usage
if __name__ == "__main__":
posts_metadata = generate_blog_metadata('./src/posts')
print(json.dumps(posts_metadata, indent=2))
SQL Query
-- Get blog posts with tag statistics
SELECT
p.id,
p.title,
p.published_at,
p.read_time,
COUNT(pt.tag_id) as tag_count,
STRING_AGG(t.name, ', ') as tags
FROM blog_posts p
LEFT JOIN post_tags pt ON p.id = pt.post_id
LEFT JOIN tags t ON pt.tag_id = t.id
WHERE p.published = true
GROUP BY p.id, p.title, p.published_at, p.read_time
ORDER BY p.published_at DESC
LIMIT 10;
Lists and Formatting
Unordered List
Ordered List
Nested Lists
Blockquotes
"The best way to learn is by building real projects and sharing your knowledge with others."
Pro Tip: Always write code that your future self will thank you for. Comment your complex logic, use meaningful variable names, and structure your projects consistently.
Links and References
Check out some of my favorite resources:
Images
Here's how images look in the blog:
Hubert "Hukasx0" Kasperek - GitHub Profile picture
This is how image captions look - clean and simple.
Tables
Technology | Use Case | Learning Curve | Rating |
---|---|---|---|
React | Frontend UI | Medium | ⭐⭐⭐⭐⭐ |
Next.js | Full-stack framework | Medium | ⭐⭐⭐⭐⭐ |
TypeScript | Type safety | High | ⭐⭐⭐⭐⭐ |
Tailwind CSS | Styling | Low | ⭐⭐⭐⭐⭐ |
tRPC | API development | Medium | ⭐⭐⭐⭐ |
Drizzle ORM | Database ORM | Low | ⭐⭐⭐⭐ |
Inline Formatting
You can use bold text, italic text and inline code
.
Here's a sentence with code snippets
mixed with regular text. Perfect for mentioning functions like useState()
or useEffect()
in React.
Mathematical Expressions
Sometimes you need to explain algorithms or complexity:
Anchor Links & Navigation
How to Use Anchor Links
This blog supports automatic anchor links for all headings! Here's how they work:
Examples of Anchor Links
Try clicking these links to jump to different sections:
Technical Implementation
The anchor links are automatically generated by:
scroll-mt-20
for proper offsetThis makes it easy to create a table of contents or reference specific sections in longer articles!
Conclusion
This blog will be a space where I document my journey as a full-stack developer, share practical solutions to real problems, and hopefully help other developers along the way.
If you have any questions or suggestions for topics you'd like me to cover, feel free to reach out!
Happy coding! 🚀
Thanks for reading! This post was written to test various MDX formatting features. More technical content coming soon.