diff --git a/content/posts/2020-07-14-hello-world/index.md b/content/posts/2020-07-14-hello-world/index.md index 805eb07..d430add 100644 --- a/content/posts/2020-07-14-hello-world/index.md +++ b/content/posts/2020-07-14-hello-world/index.md @@ -8,6 +8,8 @@ tags: categories: favorite: false tikz: true +graphviz: true +mermaid: true --- ## Test post please ignore @@ -40,6 +42,29 @@ echo hello world | cut -d' ' -f 1 \end{tikzpicture} {{% /tikz %}} +### Graphviz support + +{{% graphviz %}} + graph { + a -- b + b -- c + c -- a + } +{{% /graphviz %}} + +### Mermaid support + +{{% mermaid %}} + graph TD + A[Enter Chart Definition] --> B(Preview) + B --> C{decide} + C --> D[Keep] + C --> E[Edit Definition] + E --> B + D --> F[Save Image and Code] + F --> B +{{% /graphviz %}} + ### Spoilers {{% spoiler "Don't open me" %}} diff --git a/layouts/partials/head-extra.html b/layouts/partials/head-extra.html index 1e65c9f..dc97efa 100644 --- a/layouts/partials/head-extra.html +++ b/layouts/partials/head-extra.html @@ -3,6 +3,30 @@ {{ end }} + +{{ if (.Params.graphviz) }} + + +{{ end }} + +{{ if (.Params.mermaid) }} + +{{ end }} {{ with .OutputFormats.Get "atom" -}} {{ printf `` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} {{ end -}} diff --git a/layouts/shortcodes/graphviz.html b/layouts/shortcodes/graphviz.html new file mode 100644 index 0000000..45516a3 --- /dev/null +++ b/layouts/shortcodes/graphviz.html @@ -0,0 +1,16 @@ +
+ {{ with .Get "file" }}
+ {{ if eq (. | printf "%.1s") "/" }}
+ {{/* Absolute path are from root of site. */}}
+ {{ $.Scratch.Set "filepath" . }}
+ {{ else }}
+ {{/* Relative paths are from page directory. */}}
+ {{ $.Scratch.Set "filepath" $.Page.File.Dir }}
+ {{ $.Scratch.Add "filepath" . }}
+ {{ end }}
+
+ {{ $.Scratch.Get "filepath" | readFile }}
+ {{ else }}
+ {{.Inner}}
+ {{ end }}
+
diff --git a/layouts/shortcodes/mermaid.html b/layouts/shortcodes/mermaid.html
new file mode 100644
index 0000000..80cf0a5
--- /dev/null
+++ b/layouts/shortcodes/mermaid.html
@@ -0,0 +1,16 @@
+
+ {{ with .Get "file" }}
+ {{ if eq (. | printf "%.1s") "/" }}
+ {{/* Absolute path are from root of site. */}}
+ {{ $.Scratch.Set "filepath" . }}
+ {{ else }}
+ {{/* Relative paths are from page directory. */}}
+ {{ $.Scratch.Set "filepath" $.Page.File.Dir }}
+ {{ $.Scratch.Add "filepath" . }}
+ {{ end }}
+
+ {{ $.Scratch.Get "filepath" | readFile }}
+ {{ else }}
+ {{.Inner}}
+ {{ end }}
+
diff --git a/layouts/shortcodes/tikz.html b/layouts/shortcodes/tikz.html
index a3a78f4..c298b09 100644
--- a/layouts/shortcodes/tikz.html
+++ b/layouts/shortcodes/tikz.html
@@ -1,3 +1,16 @@