Installation
Installation
Section titled “Installation”Install the required packages:
npm install astro-mermaid mermaid
Or with other package managers:
# yarnyarn add astro-mermaid mermaid
# pnpmpnpm add astro-mermaid mermaid
Basic Setup
Section titled “Basic Setup”Add the integration to your astro.config.mjs
:
import { defineConfig } from 'astro/config';import mermaid from 'astro-mermaid';
export default defineConfig({ integrations: [ mermaid() ]});
With Options
Section titled “With Options”import { defineConfig } from 'astro/config';import mermaid from 'astro-mermaid';
export default defineConfig({ integrations: [ mermaid({ theme: 'forest', autoTheme: true, mermaidConfig: { flowchart: { curve: 'basis' } } }) ]});
Usage in Markdown
Section titled “Usage in Markdown”Once installed, you can use mermaid code blocks in your markdown files:
```mermaidgraph LR A[Install] --> B[Configure] B --> C[Use in Markdown] C --> D[Beautiful Diagrams!]```
Which renders as:
graph LR A[Install] --> B[Configure] B --> C[Use in Markdown] C --> D[Beautiful Diagrams!]
TypeScript Support
Section titled “TypeScript Support”The integration includes TypeScript definitions. Your editor should provide autocomplete for configuration options:
import mermaid from 'astro-mermaid';// Full TypeScript support for options