diff --git a/README.md b/README.md index 396c729312..ad25caee67 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,11 @@ You can try out a live version [here](https://mermaid.live/). docker run --publish 8000:80 ghcr.io/mermaid-js/mermaid-live-editor ``` +### To configure renderer URL + +When building, Set the Environment variable MERMAID_RENDERER_URL to the rendering service. +Default is `https://mermaid.ink` + ### Development ```bash diff --git a/src/lib/components/actions.svelte b/src/lib/components/actions.svelte index d33010b7fd..742a1821de 100644 --- a/src/lib/components/actions.svelte +++ b/src/lib/components/actions.svelte @@ -2,6 +2,7 @@ import { browser } from '$app/env'; import Card from '$lib/components/card/card.svelte'; + import { rendererUrl } from '$lib/util/env'; import { base64State, codeStore } from '$lib/util/state'; import { toBase64 } from 'js-base64'; import moment from 'moment'; @@ -142,8 +143,8 @@ stateCopy.mermaid = JSON.parse(stateCopy.mermaid); } const b64Code = toBase64(JSON.stringify(stateCopy), true); - iUrl = `https://mermaid.ink/img/${b64Code}`; - svgUrl = `https://mermaid.ink/svg/${b64Code}`; + iUrl = `${rendererUrl}/img/${b64Code}`; + svgUrl = `${rendererUrl}/svg/${b64Code}`; mdCode = `[![](${iUrl})](${window.location.protocol}//${window.location.host}${window.location.pathname}#${encodedState})`; }); diff --git a/src/lib/util/env.ts b/src/lib/util/env.ts new file mode 100644 index 0000000000..679c80b5da --- /dev/null +++ b/src/lib/util/env.ts @@ -0,0 +1 @@ +export const rendererUrl = import.meta.env.MERMAID_RENDERER_URL ?? 'https://mermaid.ink'; diff --git a/svelte.config.js b/svelte.config.js index 4e94a99e85..d1519f7769 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -24,6 +24,7 @@ const config = { target: '#svelte', trailingSlash: 'ignore', vite: { + envPrefix: 'MERMAID_', optimizeDeps: { include: ['mermaid'] } } }