Skip to content

Commit

Permalink
docs: update the Diagram page
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Sep 18, 2022
1 parent 300f2c9 commit f52f4bd
Showing 1 changed file with 85 additions and 3 deletions.
88 changes: 85 additions & 3 deletions exampleSite/content/posts/diagram/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,51 @@ authors = ["RazonYang"]
This article offers a sample of basic diagram usage that can be used in Hugo content files.

Please see also [Mermaid](https://mermaid-js.github.io).

<!--more-->

## Flow Chart
## Prerequisites

The diagram is disabled by default, you'll need to enable the `diagram` in front matter, otherwise the diagram won't be rendered.

{{< code-toggle >}}
diagram = true
{{< /code-toggle >}}

## Usage

```markdown
{{</* mermaid */>}}
YOUR DIAGRAM INSTRUCTIONS
{{</* /mermaid */>}}
```

You can also wrap it with other shortcodes, such as `text/align-center`.

```markdown
{{% text/align-center %}}
{{</* mermaid */>}}
YOUR DIAGRAM INSTRUCTIONS
{{</* /mermaid */>}}
{{% /text/align-center %}}
```

## Examples

### Flow Chart

```markdown
{{</* mermaid */>}}
graph TD
A[Christmas] -->|Get money| B(Go shopping)
B --> C{Let me think}
C -->|One| D[Laptop]
C -->|Two| E[iPhone]
C -->|Three| F[fa:fa-car Car]
{{</* /mermaid */>}}
```

{{% text/align-center %}}
{{< mermaid >}}
graph TD
A[Christmas] -->|Get money| B(Go shopping)
Expand All @@ -35,19 +76,59 @@ graph TD
C -->|Two| E[iPhone]
C -->|Three| F[fa:fa-car Car]
{{< /mermaid >}}
{{% /text/align-center %}}

### Sequence Diagram

## Sequence Diagram
```markdown
{{</* mermaid */>}}
sequenceDiagram
Alice->>+John: Hello John, how are you?
Alice->>+John: John, can you hear me?
John-->>-Alice: Hi Alice, I can hear you!
John-->>-Alice: I feel great!
{{</* /mermaid */>}}
```

{{% text/align-center %}}
{{< mermaid >}}
sequenceDiagram
Alice->>+John: Hello John, how are you?
Alice->>+John: John, can you hear me?
John-->>-Alice: Hi Alice, I can hear you!
John-->>-Alice: I feel great!
{{< /mermaid >}}
{{% /text/align-center %}}

## Class Diagram
### Class Diagram

```markdown
{{</* mermaid */>}}
classDiagram
Animal <|-- Duck
Animal <|-- Fish
Animal <|-- Zebra
Animal : +int age
Animal : +String gender
Animal: +isMammal()
Animal: +mate()
class Duck{
+String beakColor
+swim()
+quack()
}
class Fish{
-int sizeInFeet
-canEat()
}
class Zebra{
+bool is_wild
+run()
}
{{</* /mermaid */>}}
```

{{% text/align-center %}}
{{< mermaid >}}
classDiagram
Animal <|-- Duck
Expand All @@ -71,3 +152,4 @@ classDiagram
+run()
}
{{< /mermaid >}}
{{% /text/align-center %}}

0 comments on commit f52f4bd

Please sign in to comment.