npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

astro-mermaid-renderer

v0.1.2

Published

Astro で Mermaid 図を描画するコンポーネント集。SVGレンダリング・ズーム/パン対応プレビューモーダル・Markdownコードブロック変換を提供します。

Readme

astro-mermaid-renderer

A small collection of Astro components for rendering Mermaid diagrams. It consists of Mermaid.astro for displaying diagrams and MermaidLoader.astro for client-side rendering and interactive preview.

Files

  • src/components/Mermaid.astro
    • Renders a Mermaid diagram string as a .mermaid element
  • src/components/MermaidLoader.astro
    • Lazily loads Mermaid and converts unrendered .mermaid elements to SVG
    • Provides a zoom/pan preview modal with wheel zoom and pinch zoom support
  • docs/reference.md
    • Module specification (Japanese)

Features

  • Singleton-like Mermaid script loading
  • Idempotent rendering
  • Idempotent preview event registration
  • Automatic conversion of Mermaid code blocks from Markdown
  • SVG preview with open/close, zoom in/out, reset, and pan

Installation

npm install astro-mermaid-renderer
# or
pnpm add astro-mermaid-renderer
# or
yarn add astro-mermaid-renderer
# or
bun add astro-mermaid-renderer

Usage

1. Add MermaidLoader to your layout

Load MermaidLoader once in a shared layout (e.g. src/layouts/BaseLayout.astro). Place it at the end of <body>.

---
import MermaidLoader from "astro-mermaid-renderer/MermaidLoader.astro";
---

<html lang="en">
  <body>
    <slot />
    <MermaidLoader />
  </body>
</html>

2. Display a diagram with the Mermaid component

Use the Mermaid component in any .astro file.

---
import Mermaid from "astro-mermaid-renderer/Mermaid.astro";
---

<Mermaid chart={`graph TD
  A[Start] --> B{Decision}
  B -->|Yes| C[Done]
  B -->|No| D[Retry]
`} />

3. Auto-convert Markdown code fences (optional)

The remarkMermaid plugin converts ```mermaid code blocks in Markdown automatically.

Add it to astro.config.mjs:

import { defineConfig } from "astro/config";
import mdx from "@astrojs/mdx";
import { remarkMermaid } from "astro-mermaid-renderer/remark-mermaid";

export default defineConfig({
  integrations: [mdx()],
  markdown: {
    remarkPlugins: [remarkMermaid],
  },
});

Then write code fences in Markdown as usual:

```mermaid
graph TD
  A --> B
```

Behavior Contracts

The following are guaranteed for compatibility:

  • Public class names and DOM contracts are preserved
  • The following data attributes are never broken:
    • data-mermaid-upgraded
    • data-mermaid-rendered
    • data-mermaid-preview-bound

Notes

  • Mermaid is loaded from the jsDelivr CDN
  • Dynamically added .mermaid elements are not automatically re-scanned
  • Very large diagrams may cause high browser rendering load

Development

See docs/reference.md for implementation details. Contribution guidelines are in CONTRIBUTING.md.

Bun CLI

Run bun install first to install local dependencies (astro and prettier) before using bun run dev or bun run debug.

bun install
bun run dev
bun run debug
bun run build
bun run check
  • bun run dev — Start the Astro dev server
  • bun run debug — Start the dev server with the debug page at /debug
  • bun run build — Run Astro build
  • bun run check — Run Prettier check followed by Astro build