From 0a06f03461991e49aa2064951001a7d295664919 Mon Sep 17 00:00:00 2001 From: razonyang Date: Sat, 25 Feb 2023 11:00:41 +0800 Subject: [PATCH] feat: add the externalLinkIcon parameter to show or hide the icons after external links --- exampleSite/config/_default/params.toml | 2 ++ exampleSite/content/docs/configuration/site-params/index.md | 1 + .../content/docs/configuration/site-params/index.zh-hans.md | 1 + .../content/docs/configuration/site-params/index.zh-hant.md | 1 + layouts/_default/_markup/render-link.html | 5 ++++- 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 68fbff768..1a7b9c2e4 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -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 diff --git a/exampleSite/content/docs/configuration/site-params/index.md b/exampleSite/content/docs/configuration/site-params/index.md index 7da7c5fda..b372ce638 100644 --- a/exampleSite/content/docs/configuration/site-params/index.md +++ b/exampleSite/content/docs/configuration/site-params/index.md @@ -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. diff --git a/exampleSite/content/docs/configuration/site-params/index.zh-hans.md b/exampleSite/content/docs/configuration/site-params/index.zh-hans.md index fb396d3ba..fff280b66 100644 --- a/exampleSite/content/docs/configuration/site-params/index.zh-hans.md +++ b/exampleSite/content/docs/configuration/site-params/index.zh-hans.md @@ -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 | 字体大小 | 注释或删除此参数可以禁用字体大小切换器。 diff --git a/exampleSite/content/docs/configuration/site-params/index.zh-hant.md b/exampleSite/content/docs/configuration/site-params/index.zh-hant.md index 08b9863c4..d7a2804c8 100644 --- a/exampleSite/content/docs/configuration/site-params/index.zh-hant.md +++ b/exampleSite/content/docs/configuration/site-params/index.zh-hant.md @@ -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 | 字體大小 | 註釋或刪除此參數可以禁用字體大小切換器。 diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index a21bc529f..9f290301f 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -6,5 +6,8 @@ {{- $destHost := (urls.Parse .Destination).Host -}} {{- $external := and (ne $destHost "") (ne $destHost (urls.Parse .Page.Site.BaseURL).Host) -}} - {{- .Text | safeHTML -}}{{- if $external -}}{{- end -}} + {{- .Text | safeHTML -}} + {{- if and $external (default true site.Params.externalLinkIcon) -}} + + {{- end -}} \ No newline at end of file