also support nicknames
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
weight: 4
|
weight: 4
|
||||||
title: "Theme Documentation - Extended Shortcodes"
|
title: "Theme Documentation - Extended Shortcodes"
|
||||||
date: 2020-03-03T16:29:41+08:00
|
date: 2020-03-03T16:29:41+08:00
|
||||||
lastmod: 2020-06-12T09:32:15+03:00
|
lastmod: 2020-06-12T10:10:13+03:00
|
||||||
draft: false
|
draft: false
|
||||||
author: "Dillon"
|
author: "Dillon"
|
||||||
authorLink: "https://dillonzq.com"
|
authorLink: "https://dillonzq.com"
|
||||||
@@ -1298,7 +1298,7 @@ console.log('Hello LoveIt!');
|
|||||||
|
|
||||||
`person` is a shortcode to insert a link to a personal webpage marked up as [h-card](http://microformats.org/wiki/h-card).
|
`person` is a shortcode to insert a link to a personal webpage marked up as [h-card](http://microformats.org/wiki/h-card).
|
||||||
|
|
||||||
The `person` shortcode takes the following parameters (all of these are optional, but it makes no sense to omit the first two):
|
The `person` shortcode takes the following parameters (all of these are optional, but it makes sense to have at least **url** and **name** and/or **nick**):
|
||||||
|
|
||||||
* **url** (**first** positional parameter)
|
* **url** (**first** positional parameter)
|
||||||
|
|
||||||
@@ -1308,6 +1308,10 @@ The `person` shortcode takes the following parameters (all of these are optional
|
|||||||
|
|
||||||
Name of the person.
|
Name of the person.
|
||||||
|
|
||||||
|
* **nick**
|
||||||
|
|
||||||
|
Nickame of the person.
|
||||||
|
|
||||||
* **text** (**third** positional parameter)
|
* **text** (**third** positional parameter)
|
||||||
|
|
||||||
Text to display as hover tooltip of the link.
|
Text to display as hover tooltip of the link.
|
||||||
@@ -1319,10 +1323,10 @@ The `person` shortcode takes the following parameters (all of these are optional
|
|||||||
Example `person` input:
|
Example `person` input:
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
{{</* person url="https://evgenykuznetsov.org" name="Evgeny Kuznetsov" text="author of this shortcode" picture="https://evgenykuznetsov.org/img/avatar.jpg" */>}}
|
{{</* person url="https://evgenykuznetsov.org" name="Evgeny Kuznetsov" nick="nekr0z" text="author of this shortcode" picture="https://evgenykuznetsov.org/img/avatar.jpg" */>}}
|
||||||
```
|
```
|
||||||
|
|
||||||
This renders as {{< person url="https://evgenykuznetsov.org" name="Evgeny Kuznetsov" text="author of this shortcode" picture="https://evgenykuznetsov.org/img/avatar.jpg" >}}.
|
This renders as {{< person url="https://evgenykuznetsov.org" name="Evgeny Kuznetsov" nick="nekr0z" text="author of this shortcode" picture="https://evgenykuznetsov.org/img/avatar.jpg" >}}.
|
||||||
|
|
||||||
Without an explicitly given picture, a generic icon is used. This input:
|
Without an explicitly given picture, a generic icon is used. This input:
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,8 @@
|
|||||||
{{- $name := cond .IsNamedParams (.Get "name") (.Get 1) -}}
|
{{- $name := cond .IsNamedParams (.Get "name") (.Get 1) -}}
|
||||||
{{- $text := cond .IsNamedParams (.Get "text") (.Get 2) -}}
|
{{- $text := cond .IsNamedParams (.Get "text") (.Get 2) -}}
|
||||||
{{- $pic := cond .IsNamedParams (.Get "picture") (.Get 3) -}}
|
{{- $pic := cond .IsNamedParams (.Get "picture") (.Get 3) -}}
|
||||||
{{- $p := dict "Class" "person-mention" "Name" $name "URL" $url "Text" $text "Image" $pic -}}{{- partial "plugin/h-card" $p -}}
|
{{- $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 -}}
|
||||||
|
|||||||
Reference in New Issue
Block a user