Feat: add feature post reward support (#216)

This commit is contained in:
Cell
2022-10-27 17:06:49 +08:00
parent 54650f62db
commit ffbdc5ba98
21 changed files with 213 additions and 1 deletions
+1
View File
@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
> Snapshot: <>
- :sparkles: Feat: add feature post reward support ([#216](https://github.com/hugo-fixit/FixIt/issues/216))
- :sparkles: Feat: add params to close wordcount and readingTime in post ([#209](https://github.com/hugo-fixit/FixIt/issues/209))
- :truck: Feat: migrate parameter `params.autoBookmark` to `params.page.autoBookmark` ([#55](https://github.com/hugo-fixit/FixIt/issues/55))
- :zap: Perf: optimize close comment feature when the post has expired ([#204](https://github.com/hugo-fixit/FixIt/issues/204))
+1
View File
@@ -381,6 +381,7 @@
}
}
@import '../_partials/_single/reward';
@import '../_partials/_single/footer';
@import '../_partials/_single/comment';
}
+73
View File
@@ -0,0 +1,73 @@
.reward-container {
margin: 1rem;
padding: 1em 0;
text-align: center;
.comment {
margin: 0.5rem 0;
}
button {
display: inline-block;
box-sizing: border-box;
cursor: pointer;
outline: none;
color: lighten($reward-color, 5%);
border: 2px solid lighten($reward-color, 10%);
border-radius: $global-border-radius;
transition: 0.3s;
padding: 0.6rem 1rem;
background-color: $global-background-color;
vertical-align: text-top;
&:focus~.post-reward {
display: block;
}
&:focus,
&:active,
&:hover {
color: #ffffff;
border-color: $reward-color;
background-color: $reward-color;
[data-theme='dark'] & {
color: #ffffff;
border-color: $reward-color-dark;
background-color: $reward-color-dark;
}
}
[data-theme='dark'] & {
color: $reward-color;
border-color: lighten($reward-color, 5%);
background-color: $global-background-color-dark;
}
}
}
.post-reward {
display: none;
padding-top: 20px;
div {
display: inline-block;
span {
display: block;
}
&:hover span[data-animation] {
animation: jackInTheBox 0.8s infinite linear;
// The animation may affect :hover of img in dark mode
pointer-events: none;
}
}
img {
display: inline-block;
margin: .8em 2em 0;
max-width: 100%;
width: $reward-img-width;
}
}
+7
View File
@@ -99,6 +99,13 @@ $table-thead-color-dark: #20252b !default;
// Color of the blockquote
$blockquote-color: #697681 !default;
$blockquote-color-dark: #9ba3aa !default;
// Color of reward
$reward-color: tomato !default;
$reward-color-dark: darken($reward-color, 5%) !default;
// Width of reward image
$reward-img-width: 180px !default;
// ========== Single Content ========== //
// ========== Pagination ========== //
+10
View File
@@ -410,6 +410,16 @@
scale = true
# whether to add FullscreenControl
fullscreen = true
# FixIt 0.2.17 | NEW Donate (Sponsor) settings
[params.page.reward]
enable = false
animation = false
# comment = "Buy me a coffee"
[params.page.reward.way]
# wechatpay = "/images/wechatpay.png"
# alipay = "/images/alipay.png"
# paypal = "/images/paypal.png"
# bitcoin = "/images/bitcoin.png"
# FixIt 0.2.0 | CHANGED social share links in post page
[params.page.share]
enable = true
+1 -1
Submodule docs updated: d59c1b0a8d...7dc7eb171d
+7
View File
@@ -209,6 +209,13 @@ other = "Passwort"
[encryptyAgain]
other = "" # waitting for translation
[reward]
donate = ""
wechatpay = ""
alipay = ""
paypal = ""
bitcoin = ""
# === posts/single.html ===
# === 404.html ===
+7
View File
@@ -206,6 +206,13 @@ other = "Password"
[encryptyAgain]
other = "Encrypt again"
[reward]
donate = "Donate"
wechatpay = "WeChat Pay"
alipay = "Alipay"
paypal = "PayPal"
bitcoin = "Bitcoin"
# === posts/single.html ===
# === 404.html ===
+7
View File
@@ -209,6 +209,13 @@ other = "Contraseña"
[encryptyAgain]
other = "" # waitting for translation
[reward]
donate = ""
wechatpay = ""
alipay = ""
paypal = ""
bitcoin = ""
# === posts/single.html ===
# === 404.html ===
+7
View File
@@ -206,6 +206,13 @@ other = "Mot de passe"
[encryptyAgain]
other = "" # waitting for translation
[reward]
donate = ""
wechatpay = ""
alipay = ""
paypal = ""
bitcoin = ""
# === posts/single.html ===
# === 404.html ===
+7
View File
@@ -209,6 +209,13 @@ other = "Password"
[encryptyAgain]
other = "" # waitting for translation
[reward]
donate = ""
wechatpay = ""
alipay = ""
paypal = ""
bitcoin = ""
# === posts/single.html ===
# === 404.html ===
+7
View File
@@ -206,6 +206,13 @@ other = "Hasło"
[encryptyAgain]
other = "" # waitting for translation
[reward]
donate = ""
wechatpay = ""
alipay = ""
paypal = ""
bitcoin = ""
# === posts/single.html ===
# === 404.html ===
+7
View File
@@ -209,6 +209,13 @@ other = "Contrasinha"
[encryptyAgain]
other = "" # waitting for translation
[reward]
donate = ""
wechatpay = ""
alipay = ""
paypal = ""
bitcoin = ""
# === posts/single.html ===
# === 404.html ===
+7
View File
@@ -209,6 +209,13 @@ other = "Parolă"
[encryptyAgain]
other = "" # waitting for translation
[reward]
donate = ""
wechatpay = ""
alipay = ""
paypal = ""
bitcoin = ""
# === posts/single.html ===
# === 404.html ===
+7
View File
@@ -209,6 +209,13 @@ other = "арготизм"
[encryptyAgain]
other = "" # waitting for translation
[reward]
donate = ""
wechatpay = ""
alipay = ""
paypal = ""
bitcoin = ""
# === posts/single.html ===
# === 404.html ===
+7
View File
@@ -206,6 +206,13 @@ other = "Паролица"
[encryptyAgain]
other = "" # waitting for translation
[reward]
donate = ""
wechatpay = ""
alipay = ""
paypal = ""
bitcoin = ""
# === posts/single.html ===
# === 404.html ===
+7
View File
@@ -208,6 +208,13 @@ other = "Mật khẩu"
[encryptyAgain]
other = "" # waitting for translation
[reward]
donate = ""
wechatpay = ""
alipay = ""
paypal = ""
bitcoin = ""
# === posts/single.html ===
# === 404.html ===
+7
View File
@@ -210,6 +210,13 @@ other = "密码"
[encryptyAgain]
other = "重新加密"
[reward]
donate = "赞赏"
wechatpay = "微信"
alipay = "支付宝"
paypal = "贝宝"
bitcoin = "比特币"
# === posts/single.html ===
# === 404.html ===
+7
View File
@@ -210,6 +210,13 @@ other = "密碼"
[encryptyAgain]
other = "重新加密"
[reward]
donate = "讚賞"
wechatpay = "微信"
alipay = "支付寶"
paypal = "PayPal"
bitcoin = "比特幣"
# === posts/single.html ===
# === 404.html ===
+26
View File
@@ -0,0 +1,26 @@
{{- $params := .Scratch.Get "params" -}}
{{- $author := $params.author | default .Site.Author.name -}}
{{- $reward := $params.reward -}}
{{- if eq $reward true -}}
{{- $reward = dict "enable" true | merge .Site.Params.page.reward -}}
{{- else if eq $reward false -}}
{{- $reward = dict "enable" false -}}
{{- end -}}
{{- if $reward.enable -}}
<div class="reward-container">
<div class="comment">{{- $reward.comment -}}</div>
<button>{{- T "reward.donate" -}}</button>
<div class="post-reward">
{{- range $way, $image := $reward.way -}}
{{- with T (printf "reward.%v" $way) -}}
{{- $way = . -}}
{{- end -}}
<div>
<img src="{{ $image }}" alt="{{ $author }} {{ $way }}">
<span{{- if $reward.animation }} data-animation{{- end -}}>{{- $way -}}</span>
</div>
{{- end -}}
</div>
</div>
{{- end -}}
+3
View File
@@ -191,6 +191,9 @@
{{- end -}}
</div>
{{- /* Donate (Sponsor) */ -}}
{{- partial "single/reward.html" . -}}
{{- /* Footer */ -}}
{{- partial "single/footer.html" . -}}