Skip to content

Commit

Permalink
feat: add the externalLinkIcon parameter to show or hide the icons af…
Browse files Browse the repository at this point in the history
…ter external links
  • Loading branch information
razonyang committed Feb 25, 2023
1 parent a00df08 commit 0a06f03
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ viewer = true # Image Viewer
# backgroundImage = ['/images/bg-light.png', '/images/bg-dark.png']
# rss = "home" # link the RSS button to homepage all the times.

# externalLinkIcon = false

[sidebar]
# fixed = true
# archives = true # Enable archives widget
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ The site parameters are located in `config/_default/params.toml` by default.
| `fullWidthInSections` | Object | - | Specify the full width for particular sections, such as `posts`, `docs`.
| `fixedHeader` | Boolean | `true` | Turn on/off fixed header.
| `reward` | Object | - | [Reward Widget]({{< ref "/docs/widgets/reward" >}}), AKA Buy Me a Coffee Widget.
| `externalLinkIcon` | Boolean | `true` | Whether to show the icons after the external links.
| `share` | Object | - | Share buttons
| `share.addThis` | String | - | [AddThis](https://www.addthis.com)'s `pubid`.
| `fontSize` | Object | Font Sizes | Comment or remove this parameter to disable font size switcher.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ authors = ["RazonYang"]
| `fullWidthInSections` | Object | - | 为特定的 section 定义全宽,如:`posts`, `docs`
| `fixedHeader` | Boolean | `true` | 是否固定头部
| `reward` | Object | - | [打赏小部件]({{< ref "/docs/widgets/reward" >}}),又称 Buy Me a Coffee 小部件。
| `externalLinkIcon` | Boolean | `true` | 是否显示外部链接后的图标。
| `share` | Object | - | 分享按钮
| `share.addThis` | String | - | [AddThis](https://www.addthis.com) `pubid`
| `fontSize` | Object | 字体大小 | 注释或删除此参数可以禁用字体大小切换器。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ authors = ["RazonYang"]
| `fullWidthInSections` | Object | - | 爲特定的 section 定義全寬,如:`posts`, `docs`
| `fixedHeader` | Boolean | `true` | 是否固定頭部
| `reward` | Object | - | [打賞小部件]({{< ref "/docs/widgets/reward" >}}),又稱 Buy Me a Coffee 小部件。
| `externalLinkIcon` | Boolean | `true` | 是否顯示外部鏈接後的圖標。
| `share` | Object | - | 分享按鈕
| `share.addThis` | String | - | [AddThis](https://www.addthis.com) `pubid`
| `fontSize` | Object | 字體大小 | 註釋或刪除此參數可以禁用字體大小切換器。
Expand Down
5 changes: 4 additions & 1 deletion layouts/_default/_markup/render-link.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
{{- $destHost := (urls.Parse .Destination).Host -}}
{{- $external := and (ne $destHost "") (ne $destHost (urls.Parse .Page.Site.BaseURL).Host) -}}
<a href="{{ $dest | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if $external }} target="_blank" rel="noopener noreferrer"{{ end }}>
{{- .Text | safeHTML -}}{{- if $external -}}<i class="fas fa-external-link-square-alt ms-1"></i>{{- end -}}
{{- .Text | safeHTML -}}
{{- if and $external (default true site.Params.externalLinkIcon) -}}
<i class="fas fa-external-link-square-alt ms-1"></i>
{{- end -}}
</a>

0 comments on commit 0a06f03

Please sign in to comment.