From 93a6002290e6e8375e344d8f717b7a5adeeb146e Mon Sep 17 00:00:00 2001
From: Cell <1024@lruihao.cn>
Date: Mon, 11 Apr 2022 15:43:14 +0800
Subject: [PATCH] :sparkles: Feat: add download icon for downloadable links
(#96)
---
CHANGELOG.md | 2 +-
.../index.en.md | 8 ++++++--
.../index.zh-cn.md | 6 +++++-
layouts/partials/plugin/link.html | 16 +++++++++++++---
4 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index badd8c04..a367cc29 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,7 +12,7 @@ All notable changes to this project will be documented in this file.
- :bug: Fix: fix some header css bug ([#31](https://github.com/Lruihao/FixIt/issues/31))
- :sparkles: Feat: enhance link render ([#96](https://github.com/Lruihao/FixIt/issues/96))
- Add external icon for external links automatically
- - Add download icon for card links
+ - Add download icon for downloadable links
- :sparkles: Style: add some common CSS styles Class ([#101](https://github.com/Lruihao/FixIt/issues/101))
- :memo: Docs: revised theme documentation
- :zap: Perf: remove third-party library clipboard.js ([#84](https://github.com/Lruihao/FixIt/issues/84))
diff --git a/exampleSite/content/posts/theme-documentation-extended-shortcodes/index.en.md b/exampleSite/content/posts/theme-documentation-extended-shortcodes/index.en.md
index ae10cd26..db0ff3f4 100644
--- a/exampleSite/content/posts/theme-documentation-extended-shortcodes/index.en.md
+++ b/exampleSite/content/posts/theme-documentation-extended-shortcodes/index.en.md
@@ -150,12 +150,16 @@ The rendered output looks like this:
Example `link` input with download attribute:
```go-html-template
-{{* link href="/music/Wavelength.mp3" content="Wavelength" title="Download Wavelength.mp3" download="Wavelength.mp3" */>}}
+{{* link href="/music/Wavelength.mp3" content="Wavelength.mp3" title="Download Wavelength.mp3" download="Wavelength.mp3" */>}}
+
+{{* link href="/music/Wavelength.mp3" content="Wavelength.mp3" title="Download Wavelength.mp3" download="Wavelength.mp3" card=true */>}}
```
The rendered output looks like this:
-{{< link href="/music/Wavelength.mp3" content="Wavelength" title="Download Wavelength.mp3" download="Wavelength.mp3" >}}
+{{< link href="/music/Wavelength.mp3" content="Wavelength.mp3" title="Download Wavelength.mp3" download="Wavelength.mp3" >}}
+
+{{< link href="/music/Wavelength.mp3" content="Wavelength.mp3" title="Download Wavelength.mp3" download="Wavelength.mp3" card=true >}}
## 3 image {#image}
diff --git a/exampleSite/content/posts/theme-documentation-extended-shortcodes/index.zh-cn.md b/exampleSite/content/posts/theme-documentation-extended-shortcodes/index.zh-cn.md
index dc66eb29..6d4f6494 100644
--- a/exampleSite/content/posts/theme-documentation-extended-shortcodes/index.zh-cn.md
+++ b/exampleSite/content/posts/theme-documentation-extended-shortcodes/index.zh-cn.md
@@ -153,11 +153,15 @@ This is a **right-aligned** paragraph.
```go-html-template
{{* link href="/music/Wavelength.mp3" content="Wavelength" title="Download Wavelength.mp3" download="Wavelength.mp3" */>}}
+
+{{* link href="/music/Wavelength.mp3" content="Wavelength.mp3" title="Download Wavelength.mp3" download="Wavelength.mp3" card=true */>}}
```
呈现的输出效果如下:
-{{< link href="/music/Wavelength.mp3" content="Wavelength" title="Download Wavelength.mp3" download="Wavelength.mp3" >}}
+{{< link href="/music/Wavelength.mp3" content="Wavelength.mp3" title="Download Wavelength.mp3" download="Wavelength.mp3" >}}
+
+{{< link href="/music/Wavelength.mp3" content="Wavelength.mp3" title="Download Wavelength.mp3" download="Wavelength.mp3" card=true >}}
## 3 image {#image}
diff --git a/layouts/partials/plugin/link.html b/layouts/partials/plugin/link.html
index 8127b594..582e521c 100644
--- a/layouts/partials/plugin/link.html
+++ b/layouts/partials/plugin/link.html
@@ -31,8 +31,14 @@
{{- with .Content -}}
{{- . | safeHTML -}}
{{- end -}}
- {{ if (.ExternalIcon | default false) | and $external }}
- {{ dict "Class" "fas fa-external-link-alt fa-fw fa-xs" | partial "plugin/icon.html" }}
+ {{- if (.ExternalIcon | default false) | and $external }}
+ {{ if .Download }}
+ {{ dict "Class" "fas fa-cloud-download-alt fa-fw fa-xs" | partial "plugin/icon.html" }}
+ {{- else -}}
+ {{ dict "Class" "fas fa-external-link-alt fa-fw fa-xs" | partial "plugin/icon.html" }}
+ {{- end -}}
+ {{- else if .Download }}
+ {{ dict "Class" "fas fa-download fa-fw fa-xs" | partial "plugin/icon.html" }}
{{- end -}}
{{- else -}}
@@ -53,7 +59,11 @@
-
+ {{- if .Download -}}
+
+ {{- else -}}
+
+ {{- end -}}
{{- end -}}
\ No newline at end of file