mirror of
https://github.com/dillonzq/LoveIt.git
synced 2024-11-21 22:36:16 +01:00
commit
70829cfd5e
6 changed files with 127 additions and 4 deletions
|
@ -306,6 +306,16 @@
|
|||
height: 1.25em;
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
|
||||
.person-mention.h-card {
|
||||
display: inline-block;
|
||||
img {
|
||||
vertical-align: -12%;
|
||||
max-height: 1.1em;
|
||||
margin-right: 0ex;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@import "../_partial/_single/footer";
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
weight: 4
|
||||
title: "Theme Documentation - Extended Shortcodes"
|
||||
date: 2020-03-03T16:29:41+08:00
|
||||
lastmod: 2020-03-03T16:29:41+08:00
|
||||
lastmod: 2020-06-12T10:10:13+03:00
|
||||
draft: false
|
||||
author: "Dillon"
|
||||
authorLink: "https://dillonzq.com"
|
||||
|
@ -374,4 +374,51 @@ Block Formula:
|
|||
\[ a=b+c \\ d+e=f \]
|
||||
{{< /raw >}}
|
||||
|
||||
{{< script >}}
|
||||
console.log('Hello LoveIt!');
|
||||
{{< /script >}}
|
||||
|
||||
This renders as {{< person "https://dillonzq.com/" Dillon "author of the LoveIt theme" >}}.
|
||||
Raw content using Markdown syntax: {{< raw >}}**Hello**{{< /raw >}}
|
||||
|
||||
## 13 person
|
||||
|
||||
`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 has the following named parameters:
|
||||
|
||||
* **url** *[required]* (**first** positional parameter)
|
||||
|
||||
URL of the personal page.
|
||||
|
||||
* **name** *[required]* (**second** positional parameter)
|
||||
|
||||
Name of the person.
|
||||
|
||||
* **text** *[optional]* (**third** positional parameter)
|
||||
|
||||
Text to display as hover tooltip of the link.
|
||||
|
||||
* **picture** *[optional]* (**fourth** positional parameter)
|
||||
|
||||
A picture to use as person's avatar.
|
||||
|
||||
* **nick** *[optional]*
|
||||
|
||||
Nickame of the person.
|
||||
|
||||
Example `person` input:
|
||||
|
||||
```markdown
|
||||
{{</* 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" 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:
|
||||
|
||||
```markdown
|
||||
{{</* person "https://dillonzq.com/" Dillon "author of the LoveIt theme" */>}}
|
||||
```
|
||||
|
||||
This renders as {{< person "https://dillonzq.com/" Dillon "author of the LoveIt theme" >}}.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
weight: 4
|
||||
title: "主题文档 - 扩展 Shortcodes"
|
||||
date: 2020-03-03T16:29:59+08:00
|
||||
lastmod: 2020-03-03T16:29:59+08:00
|
||||
lastmod: 2020-06-12T10:10:13+03:00
|
||||
draft: false
|
||||
author: "Dillon"
|
||||
authorLink: "https://dillonzq.com"
|
||||
|
@ -249,7 +249,7 @@ This is a **right-aligned** paragraph.
|
|||
|
||||
`admonition` shortcode 有以下命名参数:
|
||||
|
||||
* **type** *[必需]* (**第一个**位置参数)
|
||||
* **type** *[可选]* (**第一个**位置参数)
|
||||
|
||||
`admonition` 横幅的类型, 默认值是 `note`.
|
||||
|
||||
|
@ -375,3 +375,45 @@ console.log('Hello LoveIt!');
|
|||
{{< /raw >}}
|
||||
|
||||
原始的带有 Markdown 语法的内容: {{< raw >}}**Hello**{{< /raw >}}
|
||||
|
||||
## 13 person
|
||||
|
||||
`person` shortcode 用来在你的文章中以 [h-card](http://microformats.org/wiki/h-card) 的格式插入个人网站链接.
|
||||
|
||||
`person` shortcode 有以下命名参数:
|
||||
|
||||
* **url** *[必需]* (**第一个**位置参数)
|
||||
|
||||
URL of the personal page.
|
||||
|
||||
* **name** *[必需]* (**第二个**位置参数)
|
||||
|
||||
Name of the person.
|
||||
|
||||
* **text** *[可选]* (**第三个**位置参数)
|
||||
|
||||
Text to display as hover tooltip of the link.
|
||||
|
||||
* **picture** *[可选]* (**第四个**位置参数)
|
||||
|
||||
A picture to use as person's avatar.
|
||||
|
||||
* **nick** *[可选]*
|
||||
|
||||
Nickame of the person.
|
||||
|
||||
一个 `person` 示例:
|
||||
|
||||
```markdown
|
||||
{{</* person url="https://evgenykuznetsov.org" name="Evgeny Kuznetsov" nick="nekr0z" 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" >}}.
|
||||
|
||||
一个使用通用图标的 `person` 示例:
|
||||
|
||||
```markdown
|
||||
{{</* person "https://dillonzq.com/" Dillon "author of the LoveIt theme" */>}}
|
||||
```
|
||||
|
||||
呈现的输出效果为 {{< person "https://dillonzq.com/" Dillon "author of the LoveIt theme" >}}.
|
||||
|
|
15
layouts/partials/plugin/h-card.html
Normal file
15
layouts/partials/plugin/h-card.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
{{- $rel := .Rel -}}
|
||||
{{- $nick := .Nickname -}}
|
||||
{{- $text := .Text -}}
|
||||
{{- $n := .Nickname | default .Name | default .Email | default .URL | default "👀" -}}
|
||||
<span class="h-card{{ with .Class }} {{ . }}{{- end -}}">
|
||||
{{- with .URL -}}<a href="{{ . }}" class="u-url url"{{ with $rel }} rel="{{ . }}"{{- end -}}{{ with $text }} title="{{ . }}"{{ end }}>{{- else -}}{{- with .Email -}}<a href="mailto:{{ . }}" class="email"{{ with $text }} title="{{ . }}"{{ end }}>{{- end -}}{{- end -}}
|
||||
{{- with .Image -}}<img class="u-photo photo" src="{{ . }}" alt="{{ $n }}">{{- else -}}<i class="far fa-user-circle" aria-hidden="true"></i>{{ end -}} 
|
||||
{{- with .Name -}}<span class="p-name fn">{{ . }}</span>{{ with $nick }} ({{- end -}}{{- end -}}
|
||||
{{- with .Nickname -}}<span class="p-nickname nickname">{{ . }}</span>{{- end -}}
|
||||
{{- with .Name -}}{{ with $nick }}){{- end -}}{{- end -}}
|
||||
{{- with .URL -}}</a>{{- else -}}{{- with .Email -}}</a>{{- end -}}{{- end -}}
|
||||
{{- with .Email }}
|
||||
<a href="mailto:{{ . }}" class="email"><span class="u-email">{{ . }}</span></a>
|
||||
{{- end -}}
|
||||
</span>
|
9
layouts/shortcodes/person.html
Normal file
9
layouts/shortcodes/person.html
Normal 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 -}}
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue