diff options
| author | Eltrac <hi@guhub.cn> | 2025-03-27 13:10:06 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-03-27 13:10:06 +0800 |
| commit | 83f509dd79c381a8bb1254a5de14568c61bb92e2 (patch) | |
| tree | edf57e3b77b0ae2933de06dabf0167c0621f78b8 /layouts/shortcodes | |
| parent | 6576dc46469cdf1fb25cedf2699fe4ba7002a5ef (diff) | |
feat: add library section
Diffstat (limited to 'layouts/shortcodes')
| -rw-r--r-- | layouts/shortcodes/bookcard.html | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/layouts/shortcodes/bookcard.html b/layouts/shortcodes/bookcard.html new file mode 100644 index 00000000..fd7f81df --- /dev/null +++ b/layouts/shortcodes/bookcard.html @@ -0,0 +1,27 @@ +{{- $book := .Site.GetPage (printf "library/%s" (.Get 0)) -}} + +{{- if $book }} + <div class="markdown-body book-body"> + <div class="book-cover"> + <img class="no-fancybox" src="{{ $book.Params.cover }}" /> + </div> + <h3 class="book-title"> + <a href="{{ $book.Permalink }}">{{ $book.Title }}</a> + </h3> + + {{- $rating := $book.Params.rating -}} + {{- $fullStars := math.Floor $rating -}} + <div class="rating"> + <span>评分:</span> + {{- range seq $fullStars }} + <span class="star">★</span> + {{- end -}} + </div> + + <div class="book-content"> + {{ $book.Content }} + </div> + </div> +{{- else }} + <p style="color: red;">⚠️ 无法找到书评: {{ .Get 0 }}</p> +{{- end }} |
