feat: SSR 公开板块索引 /boards

EOF

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-29 06:53:20 +08:00
parent d4b29f5b7c
commit 2a46c01c85
13 changed files with 209 additions and 4 deletions

View File

@@ -9,6 +9,7 @@
</span>
</a>
<nav class="j13-nav">
<a href="/boards">板块</a>
{{if .ShowFriendLinksNav}}<a href="/links">友链</a>{{end}}
{{if .LoggedIn}}
<a href="/compose">发帖</a>

View File

@@ -0,0 +1,28 @@
{{define "boards/list"}}
{{template "base/head" .}}
{{template "base/navbar" .}}
<main class="j13-main j13-boards">
<h1>板块</h1>
{{template "base/alert" .}}
{{if .Items}}
<ul class="j13-boards__grid">
{{range .Items}}
<li>
<a class="j13-boards__card" href="/board/{{.ID}}" data-color="{{.ColorIndex}}">
<span class="j13-boards__dot" aria-hidden="true"></span>
<span class="j13-boards__body">
<strong>{{.Name}}</strong>
{{if .Icon}}<span class="j13-muted j13-boards__icon">{{.Icon}}</span>{{end}}
{{if .Description}}<span class="j13-boards__desc">{{.Description}}</span>{{end}}
<span class="j13-muted">{{.PostCount}} 帖</span>
</span>
</a>
</li>
{{end}}
</ul>
{{else}}
<p class="j13-empty">暂无板块。{{if .IsAdmin}}请前往 <a href="/admin/boards">后台</a> 创建。{{end}}</p>
{{end}}
</main>
{{template "base/footer" .}}
{{end}}

View File

@@ -2,5 +2,5 @@ package templates
import "embed"
//go:embed *.tmpl base/*.tmpl home/*.tmpl post/*.tmpl shared/*.tmpl status/*.tmpl auth/*.tmpl admin/*.tmpl profile/*.tmpl user/*.tmpl favorites/*.tmpl messages/*.tmpl links/*.tmpl
//go:embed *.tmpl base/*.tmpl home/*.tmpl post/*.tmpl shared/*.tmpl status/*.tmpl auth/*.tmpl admin/*.tmpl profile/*.tmpl user/*.tmpl favorites/*.tmpl messages/*.tmpl links/*.tmpl boards/*.tmpl
var FS embed.FS

View File

@@ -1,6 +1,7 @@
{{define "shared/board_aside"}}
<aside class="j13-aside j13-aside--left">
<a class="j13-aside__link{{if eq .ActiveBoard 0}} is-active{{end}}" href="/">全部帖子</a>
<a class="j13-aside__link{{if eq .Path "/boards"}} is-active{{end}}" href="/boards">全部板块</a>
<a class="j13-aside__link{{if and (eq .ActiveBoard 0) (ne .Path "/boards")}} is-active{{end}}" href="/">全部帖子</a>
{{range .Boards}}
<a class="j13-aside__link{{if eq $.ActiveBoard .ID}} is-active{{end}}" href="/board/{{.ID}}">{{.Name}}</a>
{{end}}