1
0
Fork 0
mirror of https://github.com/dillonzq/LoveIt.git synced 2025-04-12 00:37:37 +02:00

feat(param): add code block render param

This commit is contained in:
Dillon 2025-03-22 17:01:58 +08:00
parent 47e86d443e
commit e840024d81
7 changed files with 66 additions and 19 deletions
exampleSite
content/posts/theme-documentation-content
hugo.toml
hugo.toml
layouts

View file

@ -239,7 +239,21 @@ This part is shown in the [basic markdown syntax page](../basic-markdown-syntax/
**LoveIt** theme has some extended syntax elements for you to write articles.
### Mermaid Diagrams
### Diagrams
#### GoAT Diagrams (ASCII)
```goat
. . . .--- 1 .-- 1 / 1
/ \ | | .---+ .-+ +
/ \ .---+---. .--+--. | '--- 2 | '-- 2 / \ 2
+ + | | | | ---+ ---+ +
/ \ / \ .-+-. .-+-. .+. .+. | .--- 3 | .-- 3 \ / 3
/ \ / \ | | | | | | | | '---+ '-+ +
1 2 3 4 1 2 3 4 1 2 3 4 '--- 4 '-- 4 \ 4
```
#### Mermaid Diagrams
```mermaid
graph TD

View file

@ -238,7 +238,21 @@ resources:
**LoveIt** 主题提供了一些扩展的语法便于你撰写文章.
### Mermaid 图表
### 图表
#### GoAT 图表 (ASCII)
```goat
. . . .--- 1 .-- 1 / 1
/ \ | | .---+ .-+ +
/ \ .---+---. .--+--. | '--- 2 | '-- 2 / \ 2
+ + | | | | ---+ ---+ +
/ \ / \ .-+-. .-+-. .+. .+. | .--- 3 | .-- 3 \ / 3
/ \ / \ | | | | | | | | '---+ '-+ +
1 2 3 4 1 2 3 4 1 2 3 4 '--- 4 '-- 4 \ 4
```
#### Mermaid 图表
```mermaid
graph TD

View file

@ -420,6 +420,9 @@ ignoreErrors = ["error-remote-getjson", "error-missing-instagram-accesstoken"]
# the maximum number of lines of displayed code by default
# 默认展开显示的代码行数
maxShownLines = 50
[params.page.code.render]
goat = true
mermaid = true
# KaTeX mathematical formulas config (KaTeX https://katex.org/)
# KaTeX 数学公式配置 (KaTeX https://katex.org/)
[params.page.math]

View file

@ -340,6 +340,9 @@
# the maximum number of lines of displayed code by default
# 默认展开显示的代码行数
maxShownLines = 50
[params.page.code.render]
goat = true
mermaid = true
# KaTeX mathematical formulas config (KaTeX https://katex.org/)
# KaTeX 数学公式配置 (KaTeX https://katex.org/)
[params.page.math]

View file

@ -1,16 +1,7 @@
{{ $width := .Attributes.width }}
{{ $height := .Attributes.height }}
{{ $class := .Attributes.class | default "" }}
<div class="goat svg-container {{ $class }}">
{{ with diagrams.Goat .Inner }}
<svg xmlns="http://www.w3.org/2000/svg" font-family="Menlo,Lucida Console,monospace"
{{ if or $width $height }}
{{ with $width }} width="{{ . }}"{{ end }}
{{ with $height }} height="{{ . }}"{{ end }}
{{ else }}
viewBox="0 0 {{ .Width }} {{ .Height }}"
{{ end }}>
{{ .Inner }}
</svg>
{{ end }}
</div>
{{- $params := .Page.Scratch.Get "params" -}}
{{- $render := $params.code.render | default dict -}}
{{- if $render.goat | default true -}}
{{- partial "plugin/goat.html" . -}}
{{- else -}}
{{- template "_default/_markup/render-codeblock.html" . -}}
{{- end -}}

View file

@ -1 +1,7 @@
{{- dict "Content" .Inner "Page" .Page | partial "plugin/mermaid.html" -}}
{{- $params := .Page.Scratch.Get "params" -}}
{{- $render := $params.code.render | default dict -}}
{{- if $render.mermaid | default true -}}
{{- dict "Content" .Inner "Page" .Page | partial "plugin/mermaid.html" -}}
{{- else -}}
{{- template "_default/_markup/render-codeblock.html" . -}}
{{- end -}}

View file

@ -0,0 +1,16 @@
{{ $width := .Attributes.width }}
{{ $height := .Attributes.height }}
{{ $class := .Attributes.class | default "" }}
<div class="goat svg-container {{ $class }}">
{{ with diagrams.Goat .Inner }}
<svg xmlns="http://www.w3.org/2000/svg" font-family="Menlo,Lucida Console,monospace"
{{ if or $width $height }}
{{ with $width }} width="{{ . }}"{{ end }}
{{ with $height }} height="{{ . }}"{{ end }}
{{ else }}
viewBox="0 0 {{ .Width }} {{ .Height }}"
{{ end }}>
{{ .Inner }}
</svg>
{{ end }}
</div>