feat: SSR 三栏右栏热门帖与 aside widgets

EOF

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-29 15:19:32 +08:00
parent f76d3e3bf8
commit 959a2c3a2e
12 changed files with 386 additions and 35 deletions

View File

@@ -12,6 +12,7 @@
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
<label class="j13-check"><input type="checkbox" name="nav_show" value="1"{{if .NavShow}} checked{{end}}/> 导航显示友链入口</label>
<label class="j13-check"><input type="checkbox" name="footer_show" value="1"{{if .FooterShow}} checked{{end}}/> 页脚显示友链入口</label>
<label class="j13-check"><input type="checkbox" name="aside_show" value="1"{{if .AsideShow}} checked{{end}}/> 侧栏显示友链</label>
<label class="j13-check"><input type="checkbox" name="reciprocal_check" value="1"{{if .ReciprocalCheck}} checked{{end}}/> 启用回链检测</label>
<button type="submit">保存设置</button>
</form>

View File

@@ -7,6 +7,7 @@
<main class="j13-main">
{{template "home/feed" .}}
</main>
{{template "shared/right_aside" .}}
</div>
{{template "base/footer" .}}
{{end}}

View File

@@ -7,6 +7,7 @@
<main class="j13-main">
{{template "post/body" .}}
</main>
{{template "shared/right_aside" .}}
</div>
{{template "base/footer" .}}
{{end}}

View File

@@ -0,0 +1,74 @@
{{define "shared/right_aside"}}
<aside class="j13-aside j13-aside--right" aria-label="侧栏">
<section class="j13-widget">
<h2 class="j13-widget__title">热门讨论</h2>
{{if .RightAside.HotPosts}}
<ul class="j13-widget__list">
{{range .RightAside.HotPosts}}
<li><a href="{{postURL .ID}}">{{.Title}}</a></li>
{{end}}
</ul>
{{else}}
<p class="j13-widget__empty">暂无热门帖</p>
{{end}}
</section>
{{range .RightAside.Widgets}}
<section class="j13-widget">
{{if eq .Kind "tag_cloud"}}
<h2 class="j13-widget__title">标签</h2>
{{if .Tags}}
<ul class="j13-widget__tags">
{{range .Tags}}
<li><a href="/?tag={{queryEscape .Name}}">{{.Name}}</a><span class="j13-widget__count">{{.Count}}</span></li>
{{end}}
</ul>
{{else}}
<p class="j13-widget__empty">暂无标签</p>
{{end}}
{{else if eq .Kind "recent_comments"}}
<h2 class="j13-widget__title">最新评论</h2>
{{if .Comments}}
<ul class="j13-widget__list">
{{range .Comments}}
<li>
<a href="{{postURL .PostID}}">{{.Excerpt}}</a>
<span class="j13-widget__meta">{{.Author}} · {{.PostTitle}}</span>
</li>
{{end}}
</ul>
{{else}}
<p class="j13-widget__empty">暂无评论</p>
{{end}}
{{else if eq .Kind "recent_users"}}
<h2 class="j13-widget__title">新用户</h2>
{{if .Users}}
<ul class="j13-widget__list">
{{range .Users}}
<li><a href="/user/{{.ID}}">{{.Nickname}}</a></li>
{{end}}
</ul>
{{else}}
<p class="j13-widget__empty">暂无用户</p>
{{end}}
{{else if eq .Kind "friend_links"}}
<h2 class="j13-widget__title">友链</h2>
{{if .FriendLinks}}
<ul class="j13-widget__list j13-widget__links">
{{range .FriendLinks}}
<li>
<a href="{{.URL}}" target="_blank" rel="noopener noreferrer">
{{if .Logo}}<img src="{{.Logo}}" alt="" class="j13-widget__logo"/>{{end}}
{{.Name}}
</a>
</li>
{{end}}
</ul>
<p class="j13-widget__more"><a href="/links">全部友链</a></p>
{{else}}
<p class="j13-widget__empty">暂无友链 · <a href="/links">去看看</a></p>
{{end}}
{{end}}
</section>
{{end}}
</aside>
{{end}}