Back to blog
Development

Rendering Markdown Content in Nuxt 4

|by Bael

Markdown is the natural format for blog content. Here's how to render it beautifully in a Nuxt 4 application.

Parsing Markdown

Use a lightweight markdown parser like markdown-it:

``ts import MarkdownIt from 'markdown-it'

const md = new MarkdownIt({ html: true, linkify: true, typographer: true, highlight(str: string, lang: string) { // Add syntax highlighting here return <pre><code class="language-x">...code...</code></pre> } })

const html = md.render('# Hello World') `

Creating a Composable

Wrap it in a Vue composable for easy use:

`ts export function useMarkdown(content: string) { const html = computed(() => md.render(content)) return { html } } `

Frontmatter Extraction

Parse YAML frontmatter for metadata:

`md


title: My Post date: 2025-08-15 tags: [nuxt, markdown]

Content starts here

`

Styling Markdown Output

Brutalist markdown styling:

`css .markdown-body h1 { font-family: 'JetBrains Mono', monospace; text-transform: uppercase; border-bottom: 3px solid #00ff41; padding-bottom: 0.5rem; }

.markdown-body code { font-family: 'JetBrains Mono', monospace; background: #1a1a1a; color: #00ff41; padding: 0.15em 0.4em; }

.markdown-body pre { background: #0a0a0a; border: 2px solid #333; padding: 1.5rem; overflow-x: auto; }

.markdown-body blockquote { border-left: 4px solid #00ff41; padding-left: 1rem; color: #888; font-style: italic; } `

Full Integration

The complete flow:

  • Store blog posts with markdown body in blogPosts.ts.
  • Import and parse in page components.
  • Render with v-html` in the template.
  • Style with brutalist typography CSS.
The result: pure content, zero database, zero API calls — just static markdown rendered into beautifully brutal HTML.

Share