blob: e720d330adcf067f86aa0a86733980c9b6f0d7af (
plain) (
blame)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
<!-- 1: 展示标题摘要;2:标题列表 -->
{{ $mode := 2 }}
{{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }}
{{ $recent := first 20 $pages.ByDate.Reverse }}
{{ if eq $mode 1 }}
<style>
.recent-list {
list-style: none;
margin: 0;
padding: 0;
}
.recent-list li {
margin-bottom: 8px;
}
.recent-date {
font-family: monospace;
margin-right: 10px;
white-space: nowrap;
}
.recent-title {
word-wrap: break-word;
}
.recent-empty {
text-align: center;
font-style: italic;
}
@media (max-width: 720px) {
.recent-list li {
display: flex;
flex-wrap: wrap;
}
.recent-date {
width: auto;
margin-right: 0.5em;
}
}
.recent-posts {
margin-top: .8rem;
}
.recent-posts h2 {
margin-top: 1rem;
margin-bottom: 1rem;
}
</style>
<div class="recent-posts">
{{ if $recent }}
<ul class="recent-list">
{{ range $recent }}
<div class="recent-item">
<li>
<span class="recent-date">{{ .Date.Format "2006-01-02" }}</span>
<a href="{{ .RelPermalink }}" class="recent-title">{{ .Title }}</a>
</li>
<summary>
{{ .Summary }}
</summary>
</div>
{{ end }}
</ul>
{{ else }}
<div class="recent-empty">暂无文章</div>
{{ end }}
</div>
{{ end }}
{{ if eq $mode 2 }}
<style>
.recent-date {
display: inline-block;
margin-right: 0.4rem;
}
.recent-item-2 {
margin-bottom: .5rem;
}
.recent-title {
border-bottom: none !important;
}
</style>
<div class="recent-posts">
{{ range $recent }}
<div class="recent-item-2">
<span class="recent-date">{{ .Date.Format "2006-01-02" }}</span>
<a href="{{ .RelPermalink }}" class="recent-title">{{ .Title }}</a>
<br>
</div>
{{ end }}
</div>
{{ end }}
|