mirror of
https://github.com/nunocoracao/blowfish.git
synced 2025-05-20 05:31:54 +02:00
+sociallink shortcode
This commit is contained in:
parent
18ac12ea3c
commit
cf15d7c83d
2 changed files with 58 additions and 12 deletions
|
@ -577,6 +577,28 @@ You can see some additional Mermaid examples on the [diagrams and flowcharts sam
|
|||
|
||||
<br/><br/><br/>
|
||||
|
||||
## Social Link
|
||||
|
||||
`sociallink` creates an anchor link for author socials from the config file, using the name param.
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
| Parameter | Description |
|
||||
| ----------- | ----------------------------------------------------------------- |
|
||||
| `name` | **Required.** Name of the social link as mentioned in config file |
|
||||
| `showIcon` | `showIcon=true` will add icon to the anchor text. Default: false |
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
**Example**
|
||||
|
||||
```md
|
||||
{{</* sociallink name="github" showIcon=true */>}}Github{{</* /sociallink */>}}
|
||||
```
|
||||
|
||||
**Output**
|
||||
{{< sociallink name="github" showIcon=true >}}Github{{< /sociallink >}}
|
||||
|
||||
<br/><br/><br/>
|
||||
|
||||
## Swatches
|
||||
|
||||
`swatches` outputs a set of up to three different colors to showcase color elements like a color palette. This shortcode takes the `HEX` codes of each color and creates the visual elements for each.
|
||||
|
|
24
layouts/shortcodes/sociallink.html
Normal file
24
layouts/shortcodes/sociallink.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
{{ $name := .Get "name" }}
|
||||
{{ if not $name }} {{ errorf "Sociallink shortcode: name param not found" }} {{ end }}
|
||||
{{ $url := false }}
|
||||
{{ with .Site.Author.links }}
|
||||
{{ range $links := . }}
|
||||
{{ range $s_name, $s_url := $links }}
|
||||
{{ if eq $s_name $name }} {{ $url = $s_url }} {{ end }}
|
||||
{{ end }}
|
||||
{{ if $url }} {{ break }} {{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if $url }}
|
||||
<a
|
||||
href="{{ $url | safeURL }}"
|
||||
target="_blank"
|
||||
aria-label="{{ $name | title }}"
|
||||
rel="me noopener noreferrer"
|
||||
>
|
||||
{{ if .Get "showIcon" }}<span class="inline-block" style="vertical-align:text-top;" >{{ partial "icon.html" $name }} </span>{{ end }}
|
||||
{{ .Inner | markdownify }}
|
||||
</a>
|
||||
{{ else }}
|
||||
{{ errorf "Sociallink shortcode: link not found" $name }}
|
||||
{{ end }}
|
Loading…
Add table
Reference in a new issue