Skip to content

Commit

Permalink
Merge pull request mermaid-js#422 from mermaid-js/feat/RendererConfig
Browse files Browse the repository at this point in the history
Feat/RendererConfig
  • Loading branch information
sidharthv96 authored Oct 4, 2021
2 parents 4b9534e + ace89a4 commit 4626d2b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/lib/components/actions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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})`;
});
</script>
Expand Down
1 change: 1 addition & 0 deletions src/lib/util/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const rendererUrl = import.meta.env.MERMAID_RENDERER_URL ?? 'https://mermaid.ink';
1 change: 1 addition & 0 deletions svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const config = {
target: '#svelte',
trailingSlash: 'ignore',
vite: {
envPrefix: 'MERMAID_',
optimizeDeps: { include: ['mermaid'] }
}
}
Expand Down

0 comments on commit 4626d2b

Please sign in to comment.