blob: 232c959353e29ad3ed24a6687aa35064b687fcd2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
{{ define "main" }}
<article class="relative">
{{ partial "components/logo" (dict
"link" "cards"
"class" "round-sticker absolute -top-4 -right-4 w-16 h-16 z-1 -rotate-5"
"imageClass" "w-full"
) }}
{{ partial "items/card" (dict "context" .) }}
{{- /* 查询引用了这个卡片的文章 */ -}}
{{- $currentCard := .File.BaseFileName -}} <!-- 获取当前卡片的文件名 -->
{{- $referencedBy := slice -}} <!-- 初始化一个空数组 -->
{{- range .Site.Pages }}
{{- if and (isset .Params "related_cards") (in .Params.related_cards $currentCard) }}
{{- $referencedBy = $referencedBy | append . }}
{{- end }}
{{- end }}
{{- /* 如果有文章引用这个卡片,就显示它们 */ -}}
{{ if gt (len $referencedBy) 0 }}
<section class="related-posts post-content my-5">
<h2 class="text-5 text-secondary m-0">引用了本卡片的文章</h2>
<ul class="my-4">
{{- range $referencedBy }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
</li>
{{- end }}
</ul>
</section>
{{ end }}
</article>
{{ end }}
|