From f52f4bd69131e6ea60b26b4c845dcddb2fb85286 Mon Sep 17 00:00:00 2001 From: razonyang Date: Sun, 18 Sep 2022 23:39:12 +0800 Subject: [PATCH] docs: update the Diagram page --- exampleSite/content/posts/diagram/index.md | 88 +++++++++++++++++++++- 1 file changed, 85 insertions(+), 3 deletions(-) diff --git a/exampleSite/content/posts/diagram/index.md b/exampleSite/content/posts/diagram/index.md index 7e2ad7b2b..a1894b6ea 100644 --- a/exampleSite/content/posts/diagram/index.md +++ b/exampleSite/content/posts/diagram/index.md @@ -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). + -## 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 +{{}} +YOUR DIAGRAM INSTRUCTIONS +{{}} +``` +You can also wrap it with other shortcodes, such as `text/align-center`. + +```markdown +{{% text/align-center %}} +{{}} +YOUR DIAGRAM INSTRUCTIONS +{{}} +{{% /text/align-center %}} +``` + +## Examples + +### Flow Chart + +```markdown +{{}} +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] +{{}} +``` + +{{% text/align-center %}} {{< mermaid >}} graph TD A[Christmas] -->|Get money| B(Go shopping) @@ -35,9 +76,21 @@ graph TD C -->|Two| E[iPhone] C -->|Three| F[fa:fa-car Car] {{< /mermaid >}} +{{% /text/align-center %}} + +### Sequence Diagram -## Sequence Diagram +```markdown +{{}} +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! +{{}} +``` +{{% text/align-center %}} {{< mermaid >}} sequenceDiagram Alice->>+John: Hello John, how are you? @@ -45,9 +98,37 @@ sequenceDiagram John-->>-Alice: Hi Alice, I can hear you! John-->>-Alice: I feel great! {{< /mermaid >}} +{{% /text/align-center %}} -## Class Diagram +### Class Diagram + +```markdown +{{}} +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() + } +{{}} +``` +{{% text/align-center %}} {{< mermaid >}} classDiagram Animal <|-- Duck @@ -71,3 +152,4 @@ classDiagram +run() } {{< /mermaid >}} +{{% /text/align-center %}}