Exploring Code Highlighting and Images in Sanity
1/1/1970
Sanity.io provides a powerful CMS for developers, including support for structured text with code highlighting and image rendering.
Key Features
Sanity's schema allows for a range of content blocks in the body
field. Let's explore some examples below.
Code Highlighting
Sanity supports multiple languages for code snippets. Here's an example of a JavaScript function:
function greet(name) {
return `Hello, ${name}!`;
}
console.log(greet("World"));
You can also write in Python:
def greet(name): return f"Hello, {name}!" print(greet("World"))
Image Rendering
Images can include captions and alternative text. Here’s an example:
Caption: A breathtaking view of the mountains.
Quotes and Styled Text
Sanity supports various text styles and decorators:
"Sanity is the platform that gives you complete control over your content."
You can use bold, italic, or code
inline styles as needed.
Conclusion
With Sanity's flexible schema, you can craft rich blog posts with a blend of text, images, and code snippets. Whether you're a developer or content creator, the possibilities are endless!