소스 검색

Add optional mermaid shortcode (#551)

* add optional mermaid shotcode

* Use page level configuration for mermaid + use local file

Signed-off-by: hossainemruz <hossainemruz@gmail.com>

* Fix comment

Co-authored-by: Emruz Hossain <hossainemruz@gmail.com>
Co-authored-by: Emruz Hossain <emruz@appscode.com>
James Ray 3 년 전
부모
커밋
c89fe66332
4개의 변경된 파일28개의 추가작업 그리고 0개의 파일을 삭제
  1. 8 0
      layouts/_default/single.html
  2. 6 0
      layouts/partials/mermaid.html
  3. 13 0
      layouts/shortcodes/mermaid.html
  4. 1 0
      static/js/mermaid-8.14.0.min.js

+ 8 - 0
layouts/_default/single.html

@@ -210,7 +210,15 @@
 <script>
   hljs.initHighlightingOnLoad();
 </script>
+
+<!-------------- Enable Math support for this page  ---------------->
 {{ if .Params.math }}
     {{ partial "math.html" . }}
 {{ end }}
+
+<!-------------- Enable mermaid support for this page  ---------------->
+{{ if .Params.mermaid }}
+    {{ partial "mermaid.html" . }}
+{{ end }}
+
 {{ end }}

+ 6 - 0
layouts/partials/mermaid.html

@@ -0,0 +1,6 @@
+<script src="{{ "/js/mermaid-8.14.0.min.js" | relURL }}"></script>
+<script>
+    mermaid.initialize({
+        startOnLoad:true
+    });
+</script>

+ 13 - 0
layouts/shortcodes/mermaid.html

@@ -0,0 +1,13 @@
+{{ $alignment:= .Get "align"}}
+{{ if not $alignment }}
+    {{ $alignment = "center"}}
+{{ end }}
+
+{{ $background:= .Get "background" }}
+{{ if not $background }}
+    {{ $background = "none"}}
+{{ end }}
+
+<div class="mermaid" align="{{ $alignment }}" style="background-color: {{ $background }}; border-radius: 5px;">
+    {{ safeHTML .Inner }}
+</div>

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 0
static/js/mermaid-8.14.0.min.js


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.