mirror of
https://github.com/McShelby/hugo-theme-relearn
synced 2025-04-30 06:22:03 +08:00
tree: use style color if name conflict #1067
This commit is contained in:
parent
964ca24fd0
commit
c062fd1ed2
@ -79,9 +79,9 @@ The **NAME** can be followed by optional double colons (`::`) to define an **ICO
|
||||
- by brand color: `primary`, `secondary`, `accent`
|
||||
- by color: `blue`, `cyan`, `green`, `grey`, `magenta`, `orange`, `red`
|
||||
- by special color: `default`, `transparent`, `code`
|
||||
- you can also [define your own styles](#defining-own-styles).
|
||||
- you can also [define your own styles](shortcodes/notice#defining-own-styles).
|
||||
|
||||
If a **style** and a named HTML color have the same name, the HTML color will be used.
|
||||
If a **style** and a named HTML color have the same name, the **style** color will be used.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -106,7 +106,7 @@ Every possible combination
|
||||
- and now with color::fa-fw fab fa-php
|
||||
- script.php::fa-fw fab fa-markdown::purple
|
||||
- alt script.php::fa-fw fab fa-markdown::#888cc4
|
||||
- magic.php::fa-fw fab fa-markdown::magic
|
||||
- magic.php::fa-fw fab fa-markdown::orange
|
||||
```
|
||||
````
|
||||
|
||||
@ -126,5 +126,5 @@ Every possible combination
|
||||
- and now with color::fa-fw fab fa-php
|
||||
- script.php::fa-fw fab fa-php::purple
|
||||
- alt script.php::fa-fw fab fa-php::#888cc4
|
||||
- magic.php::fa-fw fab fa-php::magic
|
||||
- magic.php::fa-fw fab fa-php::orange
|
||||
````
|
||||
|
@ -1,7 +1,31 @@
|
||||
{{ $content := .content | .page.RenderString }}
|
||||
<div class="list-tree">
|
||||
{{- $content = (replaceRE `<li>([^<>:]+)::([\w-]+)::([^<>\n\r\t ]+)` `<li><i class="fa-fw fas fa-$2 cstyle $3" style="color: $3;"></i><span>$1</span>` $content) }}
|
||||
{{- $content = (replaceRE `<li>([^<>:]+)::([^<>:]+)::([^<>\n\r\t ]+)` `<li><i class="$2 cstyle $3" style="color: $3;"></i><span>$1</span>` $content) }}
|
||||
{{- $matches := findRESubmatch `<li>([^<>:]+)::([\w-]+)::([^<>\n\r\t ]+)` $content }}
|
||||
{{- range $matches }}
|
||||
{{- $name := index . 1 }}
|
||||
{{- $icon := index . 2 }}
|
||||
{{- $color := index . 3 }}
|
||||
{{- $replacement := "" }}
|
||||
{{- if (where site.Params.boxStyle "identifier" $color | first 1) }}
|
||||
{{- $replacement = printf `<li><i class="fa-fw fas fa-%s cstyle %s"></i><span>%s</span>` $icon $color $name }}
|
||||
{{- else }}
|
||||
{{- $replacement = printf `<li><i class="fa-fw fas fa-%s" style="color: %s;"></i><span>%s</span>` $icon $color $name }}
|
||||
{{- end }}
|
||||
{{- $content = replace $content (index . 0) $replacement }}
|
||||
{{- end }}
|
||||
{{- $matches := findRESubmatch `<li>([^<>:]+)::([^<>:]+)::([^<>\n\r\t ]+)` $content }}
|
||||
{{- range $matches }}
|
||||
{{- $name := index . 1 }}
|
||||
{{- $icon := index . 2 }}
|
||||
{{- $color := index . 3 }}
|
||||
{{- $replacement := "" }}
|
||||
{{- if (where site.Params.boxStyle "identifier" $color | first 1) }}
|
||||
{{- $replacement = printf `<li><i class="%s cstyle %s"></i><span>%s</span>` $icon $color $name }}
|
||||
{{- else }}
|
||||
{{- $replacement = printf `<li><i class="%s" style="color: %s;"></i><span>%s</span>` $icon $color $name }}
|
||||
{{- end }}
|
||||
{{- $content = replace $content (index . 0) $replacement }}
|
||||
{{- end }}
|
||||
{{- $content = (replaceRE `<li>([^<>:]+)::([\w-]+)([\n\r\t ]*<)` `<li><i class="fa-fw fas fa-$2"></i><span>$1</span>$3` $content) }}
|
||||
{{- $content = (replaceRE `<li>([^<>:]+)::([^<>\n\r\t]+)` `<li><i class="$2"></i><span>$1</span>` $content) }}
|
||||
{{- $content | safeHTML -}}
|
||||
|
@ -1 +1 @@
|
||||
7.5.0+0d71747e13e0d9d91321f28327447ea0b4310bcc
|
||||
7.5.0+964ca24fd04abba3d8c22dd7bdc9de5a707e08fe
|
Loading…
x
Reference in New Issue
Block a user