Files
jiang13-forum/templates/home/feed.tmpl
freefire 6e7b46a2e9 feat: 首页门面 Feed 密度与侧栏分组
对齐 SPA 信息密度:头像/摘要/互动、高级搜索收起、浏览/板块分区。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-30 05:55:45 +08:00

81 lines
3.9 KiB
Cheetah

{{define "home/feed"}}
<section class="j13-feed">
<header class="j13-feed__header">
<h1 class="j13-feed__title">{{if .BoardName}}{{.BoardName}}{{else}}全部帖子{{end}}</h1>
<div class="j13-sort" role="navigation" aria-label="排序">
<a class="{{if eq .Sort "latest"}}is-active{{end}}" href="{{.SortHref "latest"}}">最新发帖</a>
<a class="{{if eq .Sort "reply"}}is-active{{end}}" href="{{.SortHref "reply"}}">最新回复</a>
<a class="{{if eq .Sort "hot"}}is-active{{end}}" href="{{.SortHref "hot"}}">热门讨论</a>
</div>
</header>
<details class="j13-search-advanced" id="search"{{if or .HasSearch .TitleOnly .SearchError}} open{{end}}>
<summary class="j13-search-advanced__summary">高级搜索</summary>
<form class="j13-search j13-search--toolbar" method="get" action="{{.FormAction}}" role="search">
{{if and .Sort (ne .Sort "latest")}}<input type="hidden" name="sort" value="{{.Sort}}"/>{{end}}
<div class="j13-search__row">
<label class="j13-search__field">
<span class="j13-search__label">关键词</span>
<input type="search" name="keyword" value="{{.Keyword}}" placeholder="标题或正文" autocomplete="off"/>
</label>
<label class="j13-search__field">
<span class="j13-search__label">标签</span>
<input type="text" name="tag" value="{{.Tag}}" placeholder="整枚标签" autocomplete="off"/>
</label>
<label class="j13-search__field">
<span class="j13-search__label">作者</span>
<input type="text" name="author" value="{{.Author}}" placeholder="用户名或昵称" autocomplete="off"/>
</label>
<label class="j13-search__check">
<input type="checkbox" name="title_only" value="1"{{if .TitleOnly}} checked{{end}}/>
仅标题
</label>
<button type="submit" class="j13-btn">搜索</button>
</div>
{{if .SearchError}}<p class="j13-search__err" role="alert">{{.SearchError}}</p>{{end}}
</form>
</details>
{{if not .Posts}}
<p class="j13-empty">{{if .SearchError}}请调整搜索条件后重试。{{else if .HasSearch}}未找到匹配帖子。{{else}}暂无帖子。{{end}}</p>
{{else}}
<ul class="j13-post-list">
{{range .Posts}}
<li class="j13-post-item">
<div class="j13-post-item__avatar">
{{if .AvatarURL}}
<img src="{{.AvatarURL}}" alt="" width="40" height="40"/>
{{else}}
<span class="j13-post-item__mark" aria-hidden="true">{{.AuthorMark}}</span>
{{end}}
</div>
<div class="j13-post-item__body">
<div class="j13-post-item__byline">
{{if .AuthorHref}}<a href="{{.AuthorHref}}">{{.AuthorName}}</a>{{else}}<span>{{.AuthorName}}</span>{{end}}
<span class="j13-post-item__time">{{.CreatedLabel}}</span>
</div>
<a class="j13-post-item__title" href="{{.Href}}"{{if $.OpenPostsInNewTab}} target="_blank" rel="noopener"{{end}}>{{.Title}}</a>
{{if .Excerpt}}<p class="j13-post-item__excerpt">{{.Excerpt}}</p>{{end}}
<div class="j13-post-item__meta">
{{if .Pinned}}<span class="j13-tag j13-tag--pin">置顶</span>{{end}}
{{if .Featured}}<span class="j13-tag j13-tag--feat">精华</span>{{end}}
{{if .BoardName}}<span class="j13-tag">{{.BoardName}}</span>{{end}}
</div>
</div>
<div class="j13-post-item__stats" aria-label="互动">
<span title="回复"><strong>{{.CommentCount}}</strong> 回复</span>
<span title="赞"><strong>{{.LikeCount}}</strong> 赞</span>
<span title="阅读"><strong>{{.ViewCount}}</strong> 阅读</span>
</div>
</li>
{{end}}
</ul>
{{end}}
{{if or .HasPrev .HasMore}}
<nav class="j13-pager">
{{if .HasPrev}}<a href="{{.PageHref .PrevPage}}">上一页</a>{{end}}
<span>第 {{.Page}} 页</span>
{{if .HasMore}}<a href="{{.PageHref .NextPage}}">下一页</a>{{end}}
</nav>
{{end}}
</section>
{{end}}