diff options
| author | verdant <im@verdant.ee> | 2026-07-22 00:03:22 +0800 |
|---|---|---|
| committer | verdant <im@verdant.ee> | 2026-07-22 00:03:22 +0800 |
| commit | 0bdecf2d39bb2a0a0cdedecd24864b4122e5cb35 (patch) | |
| tree | d8db0e36d779f70f563ac8e45f68a8bec1634225 /layouts | |
| parent | d5cfd5b0cdb9615b626a6a8fa43bb3175ebc78a7 (diff) | |
| download | blog-0bdecf2d39bb2a0a0cdedecd24864b4122e5cb35.tar.gz blog-0bdecf2d39bb2a0a0cdedecd24864b4122e5cb35.zip | |
Rewrite shortcode recent-posts
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/shortcodes/recent-posts.html | 53 |
1 files changed, 37 insertions, 16 deletions
diff --git a/layouts/shortcodes/recent-posts.html b/layouts/shortcodes/recent-posts.html index 4c3a784..5bd7f3c 100644 --- a/layouts/shortcodes/recent-posts.html +++ b/layouts/shortcodes/recent-posts.html @@ -1,25 +1,46 @@ -{{ $mode := 2 }} + {{ $mode := 2 }} + {{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }} + {{ $recent := first 15 $pages.ByDate.Reverse }} + <div class="recent-posts"> - {{ if $recent }} - <ul class="posts-list {{ if eq $mode 1 }}with-summary{{ else }}title-only{{ end }}" style="list-style: none;padding-left: 1;"> - {{ range $index, $post := $recent }} - <li> + {{ if $recent }} + + <ul class="posts-list {{ if eq $mode 1 }}with-summary{{ else }}title-only{{ end }}" style="list-style: none;padding-left: 1;"> + + + {{ range $index, $post := $recent }} + + <li> + + + <time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2006-01-02" }}</time> + + + <span class="post-link-wrapper"> + + <a href="{{ .RelPermalink }}" class="post-title">{{ .Title }}</a> + + </span> + + + </li> + + {{ end }} + + + </ul> + + {{ else }} + + <p class="posts-empty">暂无随笔 / No posts found.</p> + + {{ end }} - <time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2006-01-02" }}</time> +</div> - <span class="post-link-wrapper"> - <a href="{{ .RelPermalink }}" class="post-title">{{ .Title }}</a> - </span> - </li> - {{ end }} - </ul> - {{ else }} - <p class="posts-empty">暂无随笔 / No posts found.</p> - {{ end }} -</div> |
