Code Blocks
This post tests the rich code block features including syntax highlighting, line numbers, and the copy button.
JavaScript Example
function greet(name) {
const message = `Hello, ${name}!`;
console.log(message);
return message;
}
// Usage
greet("World");
TypeScript Example
interface Post {
title: string;
date: Date;
tags: string[];
draft?: boolean;
}
function createPost(title: string, tags: string[]): Post {
return {
title,
date: new Date(),
tags,
};
}
CSS Example
:root {
--primary: oklch(0.5 0.2 250);
--spacing: 1rem;
}
.container {
max-width: 75ch;
margin-inline: auto;
padding: var(--spacing);
}
How It Works
- Write code in fenced blocks with a language identifier
- Add
title="filename"metadata for filename display - Hover over the code block to reveal the copy button
- Click to copy — you’ll see “Copied!” feedback
That’s it! Clean and simple.