Update Theme

This commit is contained in:
Daniel Mason 2024-04-07 14:32:03 +12:00
parent a212477863
commit d47be661bd
Signed by: idanoo
GPG key ID: 387387CDBC02F132
212 changed files with 13069 additions and 8406 deletions

View file

@ -19,11 +19,11 @@
{{- with $caption -}}
<figure{{ with cond $.IsNamedParams ($.Get "class") "" }} class="{{ . }}"{{ end }}>
{{- partial "plugin/image.html" $options -}}
{{- partial "plugin/img.html" $options -}}
<figcaption class="image-caption">
{{- . | safeHTML -}}
</figcaption>
</figure>
{{- else -}}
{{- partial "plugin/image.html" $options -}}
{{- partial "plugin/img.html" $options -}}
{{- end -}}

View file

@ -12,4 +12,4 @@
{{- $options = dict "Content" (.Get 1 | default (.Get 0)) | merge $options -}}
{{- $options = dict "Title" (.Get 2) | merge $options -}}
{{- end -}}
{{- partial "plugin/link.html" $options -}}
{{- partial "plugin/a.html" $options -}}

View file

@ -0,0 +1,9 @@
{{- $url := cond .IsNamedParams (.Get "url") (.Get 0) -}}
{{- $name := cond .IsNamedParams (.Get "name") (.Get 1) -}}
{{- $text := cond .IsNamedParams (.Get "text") (.Get 2) -}}
{{- $pic := cond .IsNamedParams (.Get "picture") (.Get 3) -}}
{{- $options := dict "Class" "person-mention" "Name" $name "URL" $url "Text" $text "Image" $pic -}}
{{- if .IsNamedParams -}}
{{- $options = dict "Nickname" (.Get "nick") | merge $options -}}
{{- end -}}
{{- partial "plugin/h-card" $options -}}

View file

@ -1,18 +1,21 @@
{{- $content := trim .Inner "\n" -}}
{{- $classList := .Get "class" | slice -}}
{{- $classList := slice -}}
{{- with .Get "class" -}}
{{- $classList = $classList | append . -}}
{{- end -}}
{{- $tag := .Get "tag" | default "div" -}}
{{- with .Get "code" -}}
{{- if .Get "code" -}}
{{- /* highlight code content without line number */ -}}
{{- $content = highlight $content . "linenos=false" -}}
{{- $content = highlight $content (.Get "code") "lineNos=false, noClasses=false" -}}
{{- /* delete outer label */ -}}
{{- $content = replaceRE `<div class="highlight"><pre class="chroma"><code[^<>]*>(?s)(.*)</code></pre></div>` "$1" $content -}}
{{- /* parsing markdown links */ -}}
{{- $content = replaceRE `(<span[^<>]*>)([^<>]*)\[([^<>]+)\]\(([^<>]+)\)([^<>]*)(</span>)` "$1$2$6<a href=$4>$3</a>$1$5$6" $content -}}
{{- /* replace " " to "&nbsp;" and replace "\n" to "<br />" */ -}}
{{- $content = replaceRE ` ` "&nbsp;" $content | replaceRE `(<\w+)&nbsp;` "$1 " | replaceRE `\n` "<br />" -}}
{{- /* fix "<br />" location error which is a bug of Typeit HTML parser */ -}}
{{- $content = replaceRE `<br /></span>` "</span><br />" $content -}}
{{- $content = replaceRE `.*<code[^<>]*>(?s)(.*)</code>.*` "$1" $content -}}
{{- if .Get "code-link" -}}
{{- /* parsing code links */ -}}
{{- $content = replaceRE `(<span[^<>]*>)([^<>]*)\[([^<>]+)\]\(([^<>]+)\)([^<>]*)(</span>)` "$1$2$6<a href=\"$4\">$3</a>$1$5$6" $content -}}
{{- end -}}
{{- /* split multiline string */ -}}
{{- $content = split $content "\n" -}}
{{- $classList = $classList | append "highlight" -}}
{{- else -}}
{{- $content = $content | .Page.RenderString -}}
@ -26,6 +29,11 @@
{{- $group = $group | default slice | append $id -}}
{{- dict $key $group | merge $typeitMap | .Page.Scratch.SetInMap "this" "typeitMap" -}}
{{- $attrs := printf `id="%v"` $id -}}
{{- with $classList -}}
{{- $attrs = delimit $classList " " | printf `%v class="%v"` $attrs -}}
{{- end -}}
<div class="typeit">
{{- printf `<%v id="%v" class="%v"></%v>` $tag $id (delimit $classList " ") $tag | safeHTML -}}
{{- printf `<%v %v></%v>` $tag $attrs $tag | safeHTML -}}
</div>

View file

@ -9,5 +9,5 @@
{{- $resource = $resource | resources.ExecuteAsTemplate $path (dict "version" $version "label" $label "color" $color) | minify -}}
{{- $alt := printf "LoveIt %v | %v" $label $version -}}
<a href="{{ $url }}" rel="noopener noreffer" target="_blank">
{{- dict "Src" $resource.RelPermalink "Alt" $alt "Class" "version" | partial "plugin/image.html" -}}
{{- dict "Src" $resource.RelPermalink "Alt" $alt "Class" "version" | partial "plugin/img.html" -}}
</a>