diff options
Diffstat (limited to 'layouts/_shortcodes')
| -rw-r--r-- | layouts/_shortcodes/aplayer.html | 9 | ||||
| -rw-r--r-- | layouts/_shortcodes/book.html | 17 | ||||
| -rw-r--r-- | layouts/_shortcodes/bookcard.html | 28 | ||||
| -rw-r--r-- | layouts/_shortcodes/callout.html | 6 | ||||
| -rw-r--r-- | layouts/_shortcodes/card.html | 29 | ||||
| -rw-r--r-- | layouts/_shortcodes/gallery.html | 3 | ||||
| -rw-r--r-- | layouts/_shortcodes/img.html | 25 | ||||
| -rw-r--r-- | layouts/_shortcodes/link.html | 14 | ||||
| -rw-r--r-- | layouts/_shortcodes/postcount.html | 1 | ||||
| -rw-r--r-- | layouts/_shortcodes/quotecard.html | 3 | ||||
| -rw-r--r-- | layouts/_shortcodes/right.html | 1 | ||||
| -rw-r--r-- | layouts/_shortcodes/sidenote.html | 4 | ||||
| -rw-r--r-- | layouts/_shortcodes/wordcount.html | 5 |
13 files changed, 145 insertions, 0 deletions
diff --git a/layouts/_shortcodes/aplayer.html b/layouts/_shortcodes/aplayer.html new file mode 100644 index 00000000..84c83002 --- /dev/null +++ b/layouts/_shortcodes/aplayer.html @@ -0,0 +1,9 @@ +<div + class="lazy-aplayer" + data-name="{{ .Get "name" }}" + data-artist="{{ .Get "artist" }}" + data-url="{{ .Get "url" }}" + data-cover="{{ .Get "cover" }}" + {{ with .Get "id" }}data-id="{{ . }}"{{ end }} + style="margin: 1rem 0;" +></div> diff --git a/layouts/_shortcodes/book.html b/layouts/_shortcodes/book.html new file mode 100644 index 00000000..6cb0c8e8 --- /dev/null +++ b/layouts/_shortcodes/book.html @@ -0,0 +1,17 @@ +<div class="book-showcase"> + <div class="book-cover"> + <a href="{{ .Get "cover" }}" data-fancybox> + <img class="lazy" src="{{ .Get "cover" }}" loading="lazy" /> + </a> + </div> + <div class="book-description"> + <div class="book-description-header"> + <h3 class="book-title" id="book-{{ .Get "title" }}">{{ .Get "title" }}</h3> + <p>分数:{{ .Get "rating" }}</p> + </div> + <div> + + {{ .Inner | markdownify }} + </div> + </div> +</div> diff --git a/layouts/_shortcodes/bookcard.html b/layouts/_shortcodes/bookcard.html new file mode 100644 index 00000000..27d96001 --- /dev/null +++ b/layouts/_shortcodes/bookcard.html @@ -0,0 +1,28 @@ +{{- $books := where .Site.Pages "Section" "library" -}} +{{- $book := index (where $books "File.BaseFileName" (.Get 0)) 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 }} diff --git a/layouts/_shortcodes/callout.html b/layouts/_shortcodes/callout.html new file mode 100644 index 00000000..62112390 --- /dev/null +++ b/layouts/_shortcodes/callout.html @@ -0,0 +1,6 @@ +<div class="callout"> + <div class="callout-icon">{{ index .Params 1 }}</div> + <div class="callout-text"> + {{ index .Params 0 | markdownify }} + </div> +</div>
\ No newline at end of file diff --git a/layouts/_shortcodes/card.html b/layouts/_shortcodes/card.html new file mode 100644 index 00000000..a860b72c --- /dev/null +++ b/layouts/_shortcodes/card.html @@ -0,0 +1,29 @@ +{{- $card := .Site.GetPage (printf "cards/%s" (.Get 0)) -}} +{{- $hideHeader := .Get 1 | default "false" | lower -}} + +{{- if $card }} + <div class="card"> + <a href="{{ $card.Permalink }}" class="card-corner"></a> <!-- 右上角折角 --> + + {{- if ne $hideHeader "true" }} + <div class="card-header"> + <h3 class="card-title">{{ $card.Title }}</h3> + {{- if $card.Params.tags }} + <p class="card-tags"> + {{- range $card.Params.tags }} + <a href="{{ "/tags/" | relURL }}{{ . | urlize }}" class="card-tag">#{{ . }}</a> + {{- end }} + </p> + {{- end }} + </div> + {{- end }} + + <div class="card-content"> + {{- with $card.Content }} + {{ . }} + {{- end }} + </div> + </div> +{{- else }} + <p style="color: red;">⚠️ 无法找到卡片: {{ .Get 0 }}</p> +{{- end }} diff --git a/layouts/_shortcodes/gallery.html b/layouts/_shortcodes/gallery.html new file mode 100644 index 00000000..ce456e05 --- /dev/null +++ b/layouts/_shortcodes/gallery.html @@ -0,0 +1,3 @@ +<div class="gallery{{ with .Get "class" }} {{ . }}{{ end }}"> + {{ .Inner | markdownify | safeHTML }} +</div> diff --git a/layouts/_shortcodes/img.html b/layouts/_shortcodes/img.html new file mode 100644 index 00000000..01d0684b --- /dev/null +++ b/layouts/_shortcodes/img.html @@ -0,0 +1,25 @@ +<!-- image --> +<figure {{ with .Get "class" }}class="{{ . }}"{{ end }}> +{{ with .Get "link" }}<a href="{{ . }}">{{ end }} + <a href="{{ .Get "src" }}" data-fancybox {{ if isset .Params "title" }} data-caption="{{.Get "title" }}" {{ end }}> + <img + class="lazy" + loading="lazy" + src="{{ .Get "src" }}" + {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" }}{{ end }}"{{ end }} + /> + </a> + {{ if .Get "link" }}</a>{{ end }} + {{ if or (or (.Get "title") (.Get "caption")) (.Get "attr") }} + <figcaption>{{ if isset .Params "title" }} + <h4>{{ .Get "title" | markdownify }}</h4>{{ end }} + {{ if or (.Get "caption") (.Get "attr") }}<p> + {{ .Get "caption" }} + {{ with .Get "attrlink" }}<a href="{{ . }}"> {{ end }} + {{ .Get "attr" }} + {{ if .Get "attrlink" }}</a> {{ end }} + </p> {{ end }} + </figcaption> +{{ end }} +</figure> +<!-- image --> diff --git a/layouts/_shortcodes/link.html b/layouts/_shortcodes/link.html new file mode 100644 index 00000000..1b9c4f79 --- /dev/null +++ b/layouts/_shortcodes/link.html @@ -0,0 +1,14 @@ +<a href="{{.Get "link" }}" target="_blank" + class="{{ if (.Get "type") }}{{ .Get "type" }}-link{{ else }}blog-link{{ end }}"> + {{ if and (isset .Params "image") .Params.image }} + <div class="link-image"> + <img src="{{ .Params.image }}" class="no-fancybox" alt="{{ .Params.title }}" /> + </div> + {{ end }} + {{ if ne (.Get "type") "podcast" }} + <div class="link-content"> + <h4>{{.Get "title" }}</h4> + <p>{{.Get "description" }}</p> + </div> + {{ end }} +</a> diff --git a/layouts/_shortcodes/postcount.html b/layouts/_shortcodes/postcount.html new file mode 100644 index 00000000..68da6893 --- /dev/null +++ b/layouts/_shortcodes/postcount.html @@ -0,0 +1 @@ +{{ len (where .Site.RegularPages "Section" "posts") }} diff --git a/layouts/_shortcodes/quotecard.html b/layouts/_shortcodes/quotecard.html new file mode 100644 index 00000000..dfaf04e2 --- /dev/null +++ b/layouts/_shortcodes/quotecard.html @@ -0,0 +1,3 @@ +<div class="quote-card" {{ with .Get "rotate" }}style="transform: rotate({{. }}deg)"{{ end }}> + {{ .Inner | markdownify }} +</div>
\ No newline at end of file diff --git a/layouts/_shortcodes/right.html b/layouts/_shortcodes/right.html new file mode 100644 index 00000000..775dcc04 --- /dev/null +++ b/layouts/_shortcodes/right.html @@ -0,0 +1 @@ +<p style="text-align: right">{{ index .Params 0 | markdownify }}</p> diff --git a/layouts/_shortcodes/sidenote.html b/layouts/_shortcodes/sidenote.html new file mode 100644 index 00000000..bf2a87d3 --- /dev/null +++ b/layouts/_shortcodes/sidenote.html @@ -0,0 +1,4 @@ +<div class="sidenote"> + <h4 class="sidenote-title">{{ index .Params 0 | markdownify }}</h4> + <div class="sidenote-content">{{ index .Params 1 | markdownify }}</div> +</div> diff --git a/layouts/_shortcodes/wordcount.html b/layouts/_shortcodes/wordcount.html new file mode 100644 index 00000000..3b302b82 --- /dev/null +++ b/layouts/_shortcodes/wordcount.html @@ -0,0 +1,5 @@ +{{ $total := 0 }} +{{ range where .Site.RegularPages "Section" "posts" }} + {{ $total = add $total .WordCount }} +{{ end }} +{{ $total }} |
