mirror of
https://github.com/dillonzq/LoveIt.git
synced 2025-04-12 00:37:37 +02:00
fix(code): maxShownLines param for code
This commit is contained in:
parent
f52261932c
commit
c05de387c3
4 changed files with 10 additions and 4 deletions
layouts
_default/_markup
partials
shortcodes
|
@ -1 +1 @@
|
|||
{{- dict "Content" .Inner "Lang" .Type "Options" .Options | partial "plugin/code-block.html" -}}
|
||||
{{- dict "Content" .Inner "Lang" .Type "Options" .Options "Page" .Page | partial "plugin/code-block.html" -}}
|
||||
|
|
|
@ -56,7 +56,6 @@
|
|||
{{- end -}}
|
||||
|
||||
{{- $code := $params.code | default dict -}}
|
||||
{{- $config = cond (ne $code.maxShownLines nil) $code.maxShownLines 10 | dict "maxShownLines" | dict "code" | merge $config -}}
|
||||
|
||||
{{- /* clipboard.js */ -}}
|
||||
{{- if ne $code.copy false -}}
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
{{- $content := .Content -}}
|
||||
{{- $lang := .Lang -}}
|
||||
{{- $params := .Page.Scratch.Get "params" -}}
|
||||
{{- $codeParams := $params.code | default dict -}}
|
||||
{{- $maxShownLines := 10 -}}
|
||||
{{- with $codeParams.maxShownLines -}}
|
||||
{{- $maxShownLines = . | int -}}
|
||||
{{- end -}}
|
||||
{{- $lines := split $content "\n" | len -}}
|
||||
{{- $options := dict "lineNoStart" 1 "lineNos" true -}}
|
||||
{{- $options = .Options | partial "function/dict.html" | merge $options -}}
|
||||
{{- $lineNoStart := $options.lineNoStart | int -}}
|
||||
|
@ -7,7 +14,7 @@
|
|||
|
||||
{{- $options = dict "noClasses" false "lineNos" false | merge $options -}}
|
||||
{{- $result := transform.Highlight $content $lang $options -}}
|
||||
<div class="code-block{{ if $lineNos }} code-line-numbers{{ end }} open" style="counter-reset: code-block {{ sub $lineNoStart 1 }}">
|
||||
<div class="code-block{{ if $lineNos }} code-line-numbers{{ end }}{{ if le $lines $maxShownLines }} open{{ end }}" style="counter-reset: code-block {{ sub $lineNoStart 1 }}">
|
||||
<div class="code-header language-bash">
|
||||
<span class="code-title"><i class="arrow fas fa-chevron-right fa-fw" aria-hidden="true"></i></span>
|
||||
<span class="ellipses"><i class="fas fa-ellipsis-h fa-fw" aria-hidden="true"></i></span>
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
{{- if len .Params | eq 2 -}}
|
||||
{{- $options = .Get 1 -}}
|
||||
{{- end -}}
|
||||
{{- dict "Content" $content "Lang" $lang "Options" $options | partial "plugin/code-block.html" -}}
|
||||
{{- dict "Content" $content "Lang" $lang "Options" $options "Page" .Page | partial "plugin/code-block.html" -}}
|
||||
|
|
Loading…
Add table
Reference in a new issue