2024-02-08 21:36:10
This commit is contained in:
parent
9ad6003b01
commit
cfe4a72f4f
29
layouts/shortcodes/tag.html
Normal file
29
layouts/shortcodes/tag.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
{{- /*
|
||||
@param {string} (positional parameter 0) Tag name.
|
||||
|
||||
@returns {template.HTML}
|
||||
|
||||
@examples
|
||||
|
||||
{{< tag "linux" >}}
|
||||
*/ -}}
|
||||
|
||||
{{- if (.Get 0) -}}
|
||||
|
||||
{{- $text := (.Get 0) -}}
|
||||
{{- $tag := (site.GetPage (printf "tags/%s" ($text))) -}}
|
||||
{{- $cat := (site.GetPage (printf "categories/%s" ($text))) -}}
|
||||
|
||||
{{- if ($tag) -}}
|
||||
<a href="{{ ($tag.RelPermalink) }}" target="_blank">#{{ ($text) }}</a>
|
||||
{{- else if ($cat) -}}
|
||||
<a href="{{ ($cat.RelPermalink) }}" target="_blank">#{{ ($text) }}</a>
|
||||
{{- else -}}
|
||||
{{- ($text) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- else -}}
|
||||
|
||||
{{ (partial "alerts/no_params" .) }}
|
||||
|
||||
{{- end -}}
|
Loading…
Reference in a new issue