From 12fc429b87a06179b9a09df4cc1748c646404efa Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Tue, 30 Aug 2022 21:24:49 +0200 Subject: [PATCH] feat: support mermaid codeblocks (#302) BREAKING CHANGE: Mermaid can be rendered using code blocks now as an alternative to the shortcode. To support this feature, the minimum supported Hugo version was changed to v0.93. --- README.md | 2 +- .../content/posts/advanced/shortcodes.md | 31 +++++++++++++++++++ .../content/posts/usage/getting-started.md | 2 +- .../_markup/render-codeblock-mermaid.html | 11 +++++++ theme.toml | 2 +- 5 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 layouts/_default/_markup/render-codeblock-mermaid.html diff --git a/README.md b/README.md index f129d7e..ec43f6f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Geekblog [![Build Status](https://img.shields.io/drone/build/thegeeklab/hugo-geekblog?logo=drone&server=https%3A%2F%2Fdrone.thegeeklab.de)](https://drone.thegeeklab.de/thegeeklab/hugo-geekblog) -[![Hugo Version](https://img.shields.io/badge/hugo-0.65-blue.svg)](https://gohugo.io) +[![Hugo Version](https://img.shields.io/badge/hugo-0.93-blue.svg)](https://gohugo.io) [![GitHub release](https://img.shields.io/github/v/release/thegeeklab/hugo-geekblog)](https://github.com/thegeeklab/hugo-geekblog/releases/latest) [![GitHub contributors](https://img.shields.io/github/contributors/thegeeklab/hugo-geekblog)](https://github.com/thegeeklab/hugo-geekblog/graphs/contributors) [![License: MIT](https://img.shields.io/github/license/thegeeklab/hugo-geekblog)](https://github.com/thegeeklab/hugo-geekblog/blob/main/LICENSE) diff --git a/exampleSite/content/posts/advanced/shortcodes.md b/exampleSite/content/posts/advanced/shortcodes.md index 54d23f2..510a52f 100644 --- a/exampleSite/content/posts/advanced/shortcodes.md +++ b/exampleSite/content/posts/advanced/shortcodes.md @@ -387,6 +387,37 @@ sequenceDiagram {{< /columns >}} +As an alternative to shortcodes, code blocks can be used for markdown as well. + +{{< columns >}} + + +````tpl +```mermaid +flowchart LR +A[Hard] -->|Text| B(Round) +B --> C{Decision} +C -->|One| D[Result 1] +C -->|Two| E[Result 2] +``` +```` + +<---> + + + +```mermaid +flowchart LR +A[Hard] -->|Text| B(Round) +B --> C{Decision} +C -->|One| D[Result 1] +C -->|Two| E[Result 2] +``` + + + +{{< /columns >}} + ## KaTeX [KaTeX](https://katex.org/) shortcode let you render math typesetting in markdown document. diff --git a/exampleSite/content/posts/usage/getting-started.md b/exampleSite/content/posts/usage/getting-started.md index feae52b..e426c74 100644 --- a/exampleSite/content/posts/usage/getting-started.md +++ b/exampleSite/content/posts/usage/getting-started.md @@ -15,7 +15,7 @@ Geekblog is a simple Hugo theme for personal blogs. It is intentionally designed [![Build Status](https://img.shields.io/drone/build/thegeeklab/hugo-geekblog?logo=drone&server=https%3A%2F%2Fdrone.thegeeklab.de)](https://drone.thegeeklab.de/thegeeklab/hugo-geekblog) -[![Hugo Version](https://img.shields.io/badge/hugo-0.65-blue.svg)](https://gohugo.io) +[![Hugo Version](https://img.shields.io/badge/hugo-0.93-blue.svg)](https://gohugo.io) [![GitHub release](https://img.shields.io/github/v/release/thegeeklab/hugo-geekblog)](https://github.com/thegeeklab/hugo-geekblog/releases/latest) [![GitHub contributors](https://img.shields.io/github/contributors/thegeeklab/hugo-geekblog)](https://github.com/thegeeklab/hugo-geekblog/graphs/contributors) [![License: MIT](https://img.shields.io/github/license/thegeeklab/hugo-geekblog)](https://github.com/thegeeklab/hugo-geekblog/blob/main/LICENSE) diff --git a/layouts/_default/_markup/render-codeblock-mermaid.html b/layouts/_default/_markup/render-codeblock-mermaid.html new file mode 100644 index 0000000..ce65354 --- /dev/null +++ b/layouts/_default/_markup/render-codeblock-mermaid.html @@ -0,0 +1,11 @@ + +{{ if not (.Page.Scratch.Get "mermaid") }} + + + {{ .Page.Scratch.Set "mermaid" true }} +{{ end }} + + +
+  {{- .Inner -}}
+
diff --git a/theme.toml b/theme.toml index f52ee2b..b31b91c 100644 --- a/theme.toml +++ b/theme.toml @@ -5,7 +5,7 @@ description = "Hugo theme made for blogs" homepage = "https://hugo-geekblog.geekdocs.de/" demosite = "https://hugo-geekblog.geekdocs.de/" tags = ["blog", "responsive", "simple"] -min_version = "0.65.0" +min_version = "0.93.0" [author] name = "Robert Kaussow"