Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

astro-diagram

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

astro-diagram

Embed you Mermaid diagrams inside your Astro templates. Features server-side rendering and smart caching.

latest
Source
npmnpm
Version
0.7.0
Version published
Maintainers
1
Created
Source

🚀  Astro — Diagrams with Mermaid JS 🧜🏻‍♀️

NPM Downloads ISC License PRs Welcome
Astro TypeScript Prettier EditorConfig ESLint

Embed you Mermaid diagrams in no time inside your Astro templates.
Features server-side rendering and smart caching.
Available as a stand-alone component or as an MDX plugin, replacing mermaid code blocks on-the-fly.

Uses the mermaid library and puppeteer under the hood.

Warning
🚧  Still in beta.

📦  Installation

pnpm i mermaid astro-diagram

🛠  Usage

---
import { Diagram, type Config } from 'astro-diagram';

const config = {
  theme: 'forest',
  // ...
} as Config;

const code = `
sequenceDiagram
Alice ->> Bob: Hello Bob, how are you?
Bob-->>John: How about you John?
Bob--x Alice: I am good thanks!
Bob-x John: I am good thanks!
Note right of John: Bob thinks a long<br/>long time, so long<br/>that the text does<br/>not fit on a row.

Bob-->Alice: Checking with John...
Alice->John: Yes... John, how are you?`;

// ...
---
<!-- ... -->
<body>
  <!-- Place component inside `BODY` tag -->

  <Diagram config={config} code={code /* required */} />

  <!-- ... -->
</body>

With MD(X) code block

Warning
This is still a work-in-progress.
Some rendering bugs and inconsistencies remain.

In your astro.config.{ts,mjs}:

import remarkMermaid from 'astro-diagram/remark-mermaid';
// ...

export default defineConfig({
  // ...
  markdown: {
    remarkPlugins: [
      // remarkGfm,

      remarkMermaid,

      // ...
    ],
  },
  // ...
});

Then, in your MD(X), use the mermaid language for your code fences, exactly like you would on GitHub flavored Markdown for example.

🎉  Result

sequenceDiagram
Alice ->> Bob: Hello Bob, how are you?
Bob-->>John: How about you John?
Bob--x Alice: I am good thanks!
Bob-x John: I am good thanks!
Note right of John: Bob thinks a long<br/>long time, so long<br/>that the text does<br/>not fit on a row.

Bob-->Alice: Checking with John...
Alice->John: Yes... John, how are you?

To do

Keywords

astro

FAQs

Package last updated on 15 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts