Skip to content

Commit

Permalink
chore(website): add support for mermaid (#1552)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni authored Oct 5, 2023
1 parent 68bf280 commit 0e53862
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 0 additions & 1 deletion docs/internal-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ These are the meta models and their meaning:
- **StringModel** represent string values.
- **AnyModel** represent generic values that cannot otherwise be represented by one of the other models.


```mermaid
---
title: Meta Model
Expand Down
18 changes: 16 additions & 2 deletions modelina-website/src/components/docs/Docs.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';
import { withRouter, NextRouter } from 'next/router';
import DocsList from "../../../config/docs.json";
import { ReactMarkdown } from 'react-markdown/lib/react-markdown';
Expand All @@ -7,6 +7,7 @@ import remarkGfm from "remark-gfm";
import CodeBlock from '../CodeBlock';
import rehypeRaw from 'rehype-raw';
import GithubButton from '../buttons/GithubButton';
import Script from 'next/script';

interface WithRouterProps {
router: NextRouter;
Expand All @@ -31,8 +32,8 @@ class Docs extends React.Component<
showMenu: true
};
this.renderMenuTree = this.renderMenuTree.bind(this);

}

/**
* Render the menu items dynamically in a depth first approach
*/
Expand Down Expand Up @@ -144,6 +145,9 @@ class Docs extends React.Component<
components={{
code({node, inline, className, children, ...props}) {
const match = /language-(\w+)/.exec(className || '')
if(className === 'language-mermaid') {
return <pre className="mermaid bg-white flex justify-center">{children}</pre>
}
return !inline && match ? (
<CodeBlock
{...props}
Expand All @@ -158,6 +162,16 @@ class Docs extends React.Component<
)}}}>
{this.props.source}
</ReactMarkdown>
<Script
type="module"
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: `
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs";
mermaid.initialize({startOnLoad: true});
mermaid.contentLoaded();`,
}}
/>
</div>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion modelina-website/src/components/layouts/Head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export default function HeadComponent({
<meta property="og:url" content={permalink} />
<meta property="og:image" content={image} />
<meta property="og:description" content={description} />

<title>{title}</title>
</Head>
);
Expand Down

0 comments on commit 0e53862

Please sign in to comment.