Skip to content

Mermaid built in icons do not lead #7722

@alfredopalhares

Description

@alfredopalhares

Context

Hello, first of all thank you so much for working on this project, it has provided me the best way to quickly deploy documentation that actually gets maintained and updated.

I am trying to use the architecture-diagrams, but whenever I try to use icons from iconify.design as described on the doc.


### Bug description

Given a sample diagram like does not render icons:
```plain
architecture-beta
    group api(logos:aws-lambda)[API]

    service db(logos:aws-aurora)[Database] in api
    service disk1(logos:aws-glacier)[Storage] in api
    service disk2(logos:aws-s3)[Storage] in api
    service server(logos:aws-ec2)[Server] in api

    db:L -- R:server
    disk1:T -- B:server
    disk2:T -- B:db

Screenshot From 2024-11-19 17-03-59

In have tried to load the icons myself by adding this to docs/src/js/register-mermaid-icons.js:

import mermaid from "mermaid";

mermaid.registerIconPacks([
  {
    name: "logos",
    loader: () =>
      fetch("https://unpkg.com/@iconify-json/logos/icons.json")
        .then((res) => {
          if (!res.ok) throw new Error("Failed to fetch icons");
          return res.json();
        })
        .then((icons) => {
          console.log("Icons loaded:", icons);
          return icons;
        })
        .catch((err) => console.error("Error loading icons:", err)),
  },
]);

// Initialize Mermaid
mermaid.initialize({
  startOnLoad: true,
  theme: "default", // or "dark", "neutral"
  securityLevel: "loose", // Needed for inline HTML in Mermaid
});

And load it from mkdocs.yml:

extra_javascript:
  - path: src/js/register-mermaid-icons.js
    type: module

The codes does run, by mermad.registerIconPacks never runs.. what am I doing wrong ?

Related links

Reproduction

9.5.44-mermaid-icons.zip

Steps to reproduce

Build the reproduction sample or use the diagram and js provided on the bu

Browser

No response

Before submitting

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions