评论变为ajax加载 和提交
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
<link rel="icon" href="/static/images/favicon.ico" type="image/x-icon">
|
||||
<link rel="stylesheet" href="/static/css/style.css">
|
||||
<link rel="stylesheet" href="/static/css/layui.css">
|
||||
<script src="/static/js/frontend.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -60,9 +60,9 @@
|
||||
|
||||
{{if .ShowComments}}
|
||||
<section class="comments-section" id="comments">
|
||||
<h3>评论 ({{.CommentCount}})</h3>
|
||||
<h3>评论 (<span id="comment-count">{{.CommentCount}}</span>)</h3>
|
||||
|
||||
<form class="comment-form" action="/comment" method="POST">
|
||||
<form class="comment-form" action="/api/comments" method="POST">
|
||||
<input type="hidden" name="post_id" value="{{.Post.ID}}">
|
||||
<div class="form-group">
|
||||
<input type="text" name="author" placeholder="昵称" required>
|
||||
@@ -80,50 +80,12 @@
|
||||
</form>
|
||||
|
||||
<div class="comments-list">
|
||||
{{range .Comments}}
|
||||
<div class="comment-item" id="comment-{{.ID}}">
|
||||
<div class="comment-header">
|
||||
<span class="comment-author">
|
||||
{{if .Website}}
|
||||
<a href="{{.Website}}" target="_blank">{{.Author}}</a>
|
||||
{{else}}
|
||||
{{.Author}}
|
||||
{{end}}
|
||||
</span>
|
||||
<span class="comment-date">{{.CreatedAt.Format "2006-01-02 15:04"}}</span>
|
||||
</div>
|
||||
<div class="comment-content">{{.Content}}</div>
|
||||
|
||||
{{if .Children}}
|
||||
<div class="comment-children">
|
||||
{{range .Children}}
|
||||
<div class="comment-item child" id="comment-{{.ID}}">
|
||||
<div class="comment-header">
|
||||
<span class="comment-author">{{.Author}}</span>
|
||||
<span class="comment-date">{{.CreatedAt.Format "2006-01-02 15:04"}}</span>
|
||||
</div>
|
||||
<div class="comment-content">{{.Content}}</div>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{else}}
|
||||
<p class="no-comments">暂无评论,来发表第一条评论吧!</p>
|
||||
{{end}}
|
||||
<!-- 评论由 AJAX 动态加载 -->
|
||||
</div>
|
||||
|
||||
{{if gt .CommentTotalPages 1}}
|
||||
<div class="pagination comment-pagination">
|
||||
{{if gt .CommentPage 1}}
|
||||
<a href="/post/{{.Post.Slug}}?cpage={{sub .CommentPage 1}}#comments" class="prev">← 上一页</a>
|
||||
{{end}}
|
||||
<span class="page-info">{{.CommentPage}} / {{.CommentTotalPages}}</span>
|
||||
{{if lt .CommentPage .CommentTotalPages}}
|
||||
<a href="/post/{{.Post.Slug}}?cpage={{add .CommentPage 1}}#comments" class="next">下一页 →</a>
|
||||
{{end}}
|
||||
<div class="pagination comment-pagination" style="display:none">
|
||||
<!-- 分页由 AJAX 动态渲染 -->
|
||||
</div>
|
||||
{{end}}
|
||||
</section>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
Reference in New Issue
Block a user