Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the externalLinkIcon parameter to show or hide the icons after external links #912

Merged
merged 1 commit into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>