summaryrefslogtreecommitdiffstats
path: root/layouts/shortcodes/recent-posts.html
blob: a666a4c6d4d0e704730b5a05b4829e2713392177 (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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
{{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }} {{
$recent := first 6 $pages.ByDate.Reverse }}

<style>
  .item-link {
      word-wrap: break-word;
      white-space: normal;
  }
  .recent-list {
      margin: 0;
  }
  .post-meta {
      margin-bottom: 5px;
  }
  .recent-item {
      position: relative;
      margin-bottom: 8px;
      flex-shrink: 0;
  }
  .split {
      margin: 0;
      padding: 0;
      display: inline;
  }
  .recent-posts-item {
      margin-top: 0;
      margin-bottom: 35px;

  }
  .recent-post-title {
      margin-top: 2px;
      margin-bottom: -10px;

  }
  @media (max-width: 720px) {
      .post-date {
	  min-width: auto;
	  font-size: 1.05em;
      }
      .item-link {
	  white-space: normal; /* 允许换行 */
	  word-wrap: break-word; /* 强制长单词/链接换行 */
	  overflow: visible; /* 取消隐藏 */
	  text-overflow: clip; /* 取消省略号 */
      }
  }
  .category-link {
      font-size: 0.9em;
  }
  .recent-empty {
      text-align: center;
      font-style: italic;
  }
</style>

<div class="recent-posts">

  {{ if $recent }}
  {{ range $index, $page := $recent }}
  <div class="recent-posts-item">
    <h3 class="recent-post-title">
      <a href="{{ .RelPermalink }}" class="item-link">{{ .Title }}</a>
    </h3>

{{ if ne (.Params.showMeta | default true) false }}
<div class="post-meta">

    <div class="post-meta-item post-date">
        <time class="dt-published" datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">
            {{ .Date.Format "January 02, 2006" }}
        </time>
    </div>

    <div class="post-meta-item post-category">

        {{ range .Params.categories }}
        {{ $url := printf "/categories/%s/" (. | urlize) }}
•
        <a href="{{ $url }}" class="category-link">{{ . }}</a>
        {{ end }}
    </div>
</div>
{{ end }}







    <!-- <div class="post-meta"> -->
    <!--   <span class="post-date"> -->
    <!--     <time datetime='{{ .Date.Format "Jan 02, 2006" }}'>{{- .Date.Format (default "Jan 02, 2006" .Site.Params.dateFormat) -}}•</time> -->


    <!--   </span> -->
    <!--   {{ with .Params.categories }} -->
    <!--   {{ range . }} -->
    <!--   {{ $category := . }} -->
    <!--   {{ with $.Site.GetPage (printf "categories/%s" $category) }} -->
    <!--   <a href="{{ .Permalink }}" class="category-link">{{ .Title }}</a> -->
    <!--   {{ else }} -->
    <!--   <a href="{{ "categories/" | relLangURL}}{{ $category | urlize}}" class="category-link">{{ $category }}</a> -->
    <!--   {{ end }} -->
    <!--   {{ end }} -->
    <!--   {{ end }} -->
    <!-- </div> -->
  </div>
  {{ end }}
  {{ else }}
  <div class="recent-empty">暂无文章</div>
  

</div>

{{ end }}

<!-- <div class="recent-posts"> -->
  <!-- {{ range $index, $page := $recent }} -->
  <!-- {{ end }} -->
  <!-- </div> -->

<!-- <div class="recent-posts"> -->
  <!--   {{ if $recent }} {{ range $index, $page := $recent }} -->
  <!--   <div class="recent-posts-item"> -->
    <!--     <h2 class="recent-post-title post-title"> -->
      <!--       <a href="{{ .RelPermalink }}" class="item-link">{{ .Title }}</a> -->
      <!--     </h2> -->
    <!--     <div class="summary">{{ .Summary }}</div> -->

    <!--     {{ partial "post_meta.html" . }} -->

    <!--   {{ if not (eq (add $index 1) (len $recent)) }} {{ end }} {{ end }} {{ else }} -->
    <!--   <div class="recent-empty">暂无文章</div> -->
    <!--   {{ end }} -->
    <!-- </div> -->