A Hugo theme component with reward-log or sponsor-log shortcode.

来源:hugo-fixit/shortcode-rewards
网站:https://lruihao.cn/reward/

目录

shortcode-rewards

A Hugo theme component with reward-log or sponsor-log shortcode.

Demo

Requirements

Developed based on the FixIt Timeline plugin.

  • v2 requires FixIt v1.0.x
  • v1 requires FixIt v0.4.x

Install Component

The installation method is the same as installing a theme. There are several ways to install, choose one, for example, install through Hugo Modules:

1
2
3
4
5
[module]
  [[module.imports]]
    path = "github.com/hugo-fixit/FixIt"
+ [[module.imports]]
+   path = "github.com/hugo-fixit/shortcode-rewards/v2"

Configuration

In order to Inject the partial shortcode-rewards.html into the custom-head through the custom block opened by the FixIt theme in the layouts/partials/custom.html file, you need to fill in the following necessary configurations:

1
2
3
4
5
[params]
  [params.custom_partials]
    # ... other partials
    head = [ "inject/shortcode-rewards.html" ]
    # ... other partials

Usage

First, create the reward-log.yml file and edit your data:

1
cp themes/shortcode-rewards/reward_log.yml.example data/reward_log.yml

If your site is multilingual, you can create a reward_log.en.yml file for English and reward_log.zh-cn.yml for Chinese.

Next, use the reward-log shortcode in any page:

1
{{< reward-log >}}

注意

For compatibility with older versions, sponsor-log shortcode can also be used, and the corresponding data file is sponsor_log.yml.

Params

Shortcode

The reward-log shortcode has the following named parameters, and the positional parameters ordered from top to bottom:

ParameterDescriptionTypeOptional valuesDefault
reversewhether the node is ascending or descendingboolean-true
placementposition of timestampstringtop / bottombottom
animationwhether to enable animationboolean-false
sizenode sizestringsmall / medium / largemedium
nodenode stylestringcircle / dotcircle
width# container widthstring--
height# container heightstring--
class# container classnamestring--

Parameters marked with # only support named parameters.

Data

The reward_log.yml file has the following fields:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# The sponsor logs data format is as follows
# currency: [CNY, USD, EUR, ...] https://gohugo.io/functions/lang/formatcurrency/
# origin: [alipay, bitcoin, paypal, wechatpay, ...]

message: Thanks all!
currency: CNY
symbol: ¥
# The sponsor logs inherit the FixIt Timeline events
logs:
  - date: "2006-01-02 15:04:05"
    sponsor: Cell
    money: 50
    origin: alipay
    remark: "Come on!"

References


相关内容

Buy me a coffee
hugo-fixit 支付宝支付宝
hugo-fixit 微信微信

发现新版本

当前站点有新版本可用。