模板格式化
This commit is contained in:
parent
147d382a1a
commit
979740bebc
|
@ -26,8 +26,8 @@ func SetupRouter() *gin.Engine {
|
|||
},
|
||||
})
|
||||
reader := templates.NewFsTemplate(r.FuncMap)
|
||||
reader.AddTemplate("index", "posts/index.html", "layout/*.html")
|
||||
reader.AddTemplate("detail", "posts/detail.html", "layout/*.html")
|
||||
reader.AddTemplate("index", "posts/index.gohtml", "layout/*.gohtml")
|
||||
reader.AddTemplate("detail", "posts/detail.gohtml", "layout/*.gohtml")
|
||||
r.HTMLRender = reader
|
||||
r.Use(middleware.SetStaticFileCache)
|
||||
//gzip 因为一般会用nginx做反代时自动使用gzip,所以go这边本身可以不用
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{{define "layout/footer"}}
|
||||
|
||||
<div class="site-info">
|
||||
<a href="https://cn.wordpress.org/" class="imprint">自豪地采用WordPress</a>
|
||||
</div>
|
||||
<div class="site-info">
|
||||
<a href="https://cn.wordpress.org/" class="imprint">自豪地采用WordPress</a>
|
||||
</div>
|
||||
|
||||
{{end}}
|
|
@ -1,10 +1,10 @@
|
|||
{{define "layout/page"}}
|
||||
{{if .pagination}}
|
||||
<nav class="navigation pagination" aria-label="文章">
|
||||
<h2 class="screen-reader-text">文章导航</h2>
|
||||
<div class="nav-links">
|
||||
{{.pagination|unescaped}}
|
||||
</div>
|
||||
</nav>
|
||||
{{end}}
|
||||
{{if .pagination}}
|
||||
<nav class="navigation pagination" aria-label="文章">
|
||||
<h2 class="screen-reader-text">文章导航</h2>
|
||||
<div class="nav-links">
|
||||
{{.pagination|unescaped}}
|
||||
</div>
|
||||
</nav>
|
||||
{{end}}
|
||||
{{end}}
|
|
@ -1,63 +1,65 @@
|
|||
{{define "layout/sidebar" }}
|
||||
<div id="widget-area" class="widget-area" role="complementary">
|
||||
<aside id="search-2" class="widget widget_search">
|
||||
<form role="search" method="get" class="search-form" action="/">
|
||||
<label>
|
||||
<span class="screen-reader-text">搜索:</span>
|
||||
<input type="search" class="search-field" placeholder="搜索…" value="{{.search}}" name="s">
|
||||
</label>
|
||||
<input type="submit" class="search-submit screen-reader-text" value="搜索">
|
||||
</form>
|
||||
</aside>
|
||||
<aside id="recent-posts-2" class="widget widget_recent_entries">
|
||||
<h2 class="widget-title">近期文章</h2>
|
||||
<nav aria-label="近期文章">
|
||||
<ul>
|
||||
{{range $k,$v:=.recentPosts}}
|
||||
<li>
|
||||
<a href="/p/{{$v.Id}}">{{$v.PostTitle}}</a>
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
<div id="widget-area" class="widget-area" role="complementary">
|
||||
<aside id="search-2" class="widget widget_search">
|
||||
<form role="search" method="get" class="search-form" action="/">
|
||||
<label>
|
||||
<span class="screen-reader-text">搜索:</span>
|
||||
<input type="search" class="search-field" placeholder="搜索…" value="{{.search}}" name="s">
|
||||
</label>
|
||||
<input type="submit" class="search-submit screen-reader-text" value="搜索">
|
||||
</form>
|
||||
</aside>
|
||||
<aside id="recent-posts-2" class="widget widget_recent_entries">
|
||||
<h2 class="widget-title">近期文章</h2>
|
||||
<nav aria-label="近期文章">
|
||||
<ul>
|
||||
{{range $k,$v:=.recentPosts}}
|
||||
<li>
|
||||
<a href="/p/{{$v.Id}}">{{$v.PostTitle}}</a>
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
|
||||
</nav>
|
||||
</aside>
|
||||
<aside id="recent-comments-2" class="widget widget_recent_comments"><h2 class="widget-title">近期评论</h2>
|
||||
<nav aria-label="近期评论">
|
||||
<ul id="recentcomments"></ul>
|
||||
</nav>
|
||||
</aside>
|
||||
<aside id="archives-2" class="widget widget_archive"><h2 class="widget-title">归档</h2>
|
||||
<nav aria-label="归档">
|
||||
<ul>
|
||||
{{range $k,$v := .archives}}
|
||||
<li><a href="/p/date/{{$v.Year}}/{{$v.Month|printf "%02s"}}">{{$v.Year}}年{{$v.Month}}月</a></li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</nav>
|
||||
</aside>
|
||||
<aside id="recent-comments-2" class="widget widget_recent_comments"><h2 class="widget-title">近期评论</h2>
|
||||
<nav aria-label="近期评论">
|
||||
<ul id="recentcomments"></ul>
|
||||
</nav>
|
||||
</aside>
|
||||
<aside id="archives-2" class="widget widget_archive"><h2 class="widget-title">归档</h2>
|
||||
<nav aria-label="归档">
|
||||
<ul>
|
||||
{{range $k,$v := .archives}}
|
||||
<li><a href="/p/date/{{$v.Year}}/{{$v.Month|printf "%02s"}}">{{$v.Year}}年{{$v.Month}}月</a>
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
|
||||
</nav>
|
||||
</aside>
|
||||
<aside id="categories-2" class="widget widget_categories"><h2 class="widget-title">分类</h2>
|
||||
<nav aria-label="分类">
|
||||
<ul>
|
||||
{{range $k,$v := .categories}}
|
||||
<li class="cat-item cat-item-{{$v.WpTerms.TermId}}"><a href="/p/category/{{$v.Name}}">{{$v.Name}}</a>
|
||||
{{end}}
|
||||
</ul>
|
||||
</nav>
|
||||
</aside>
|
||||
<aside id="categories-2" class="widget widget_categories"><h2 class="widget-title">分类</h2>
|
||||
<nav aria-label="分类">
|
||||
<ul>
|
||||
{{range $k,$v := .categories}}
|
||||
<li class="cat-item cat-item-{{$v.WpTerms.TermId}}"><a
|
||||
href="/p/category/{{$v.Name}}">{{$v.Name}}</a>
|
||||
{{end}}
|
||||
</ul>
|
||||
|
||||
</nav>
|
||||
</aside>
|
||||
<aside id="meta-2" class="widget widget_meta"><h2 class="widget-title">其他操作</h2>
|
||||
<nav aria-label="其他操作">
|
||||
<ul>
|
||||
<li><a href="https://www.xloyy.com/wp-login.php">登录</a></li>
|
||||
<li><a href="https://www.xloyy.com/feed">条目feed</a></li>
|
||||
<li><a href="https://www.xloyy.com/comments/feed">评论feed</a></li>
|
||||
</nav>
|
||||
</aside>
|
||||
<aside id="meta-2" class="widget widget_meta"><h2 class="widget-title">其他操作</h2>
|
||||
<nav aria-label="其他操作">
|
||||
<ul>
|
||||
<li><a href="https://www.xloyy.com/wp-login.php">登录</a></li>
|
||||
<li><a href="https://www.xloyy.com/feed">条目feed</a></li>
|
||||
<li><a href="https://www.xloyy.com/comments/feed">评论feed</a></li>
|
||||
|
||||
<li><a href="https://cn.wordpress.org/">WordPress.org</a></li>
|
||||
</ul>
|
||||
<li><a href="https://cn.wordpress.org/">WordPress.org</a></li>
|
||||
</ul>
|
||||
|
||||
</nav>
|
||||
</aside>
|
||||
</div>
|
||||
</nav>
|
||||
</aside>
|
||||
</div>
|
||||
{{end}}
|
|
@ -1,133 +1,152 @@
|
|||
{{template "layout/base" .}}
|
||||
{{define "content"}}
|
||||
<div id="primary" class="content-area">
|
||||
<main id="main" class="site-main">
|
||||
<div id="primary" class="content-area">
|
||||
<main id="main" class="site-main">
|
||||
<article id="post-{{.post.Id}}"
|
||||
class="post-{{.post.Id}} post type-post status-publish format-standard hentry category-uncategorized">
|
||||
|
||||
<header class="entry-header">
|
||||
<h1 class="entry-title">{{.post.PostTitle}}</h1></header><!-- .entry-header -->
|
||||
|
||||
<article id="post-{{.post.Id}}" class="post-{{.post.Id}} post type-post status-publish format-standard hentry category-uncategorized">
|
||||
<div class="entry-content">
|
||||
{{.post.PostContent|unescaped}}
|
||||
</div><!-- .entry-content -->
|
||||
|
||||
<header class="entry-header">
|
||||
<h1 class="entry-title">{{.post.PostTitle}}</h1> </header><!-- .entry-header -->
|
||||
|
||||
<div class="entry-content">
|
||||
{{.post.PostContent|unescaped}}
|
||||
</div><!-- .entry-content -->
|
||||
|
||||
|
||||
<footer class="entry-footer">
|
||||
<footer class="entry-footer">
|
||||
<span class="posted-on">
|
||||
<span class="screen-reader-text">发布于 </span>
|
||||
<a href="/p/{{.post.Id}}" rel="bookmark">
|
||||
<time class="entry-date published updated" datetime="{{.post.PostDateGmt}}">{{.post.PostDate|dateCh}}
|
||||
<time class="entry-date published updated"
|
||||
datetime="{{.post.PostDateGmt}}">{{.post.PostDate|dateCh}}
|
||||
</time>
|
||||
</a>
|
||||
</span>
|
||||
{{if .post.CategoriesHtml}}
|
||||
<span class="cat-links">
|
||||
{{if .post.CategoriesHtml}}
|
||||
<span class="cat-links">
|
||||
<span class="screen-reader-text">分类 </span>
|
||||
{{.post.CategoriesHtml|unescaped}}
|
||||
</span>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{if .post.TagsHtml}}
|
||||
<span class="tags-links">
|
||||
{{if .post.TagsHtml}}
|
||||
<span class="tags-links">
|
||||
<span class="screen-reader-text">标签 </span>
|
||||
{{.post.TagsHtml|unescaped}}
|
||||
</span>
|
||||
{{end}}
|
||||
</footer>
|
||||
<!-- .entry-footer -->
|
||||
|
||||
</article><!-- #post-1 -->
|
||||
|
||||
<div id="comments" class="comments-area">
|
||||
|
||||
<h2 class="comments-title">
|
||||
《{{.post.PostTitle}}》上有1条评论 </h2>
|
||||
|
||||
|
||||
<ol class="comment-list">
|
||||
<li id="comment-1" class="comment even thread-even depth-1">
|
||||
<article id="div-comment-1" class="comment-body">
|
||||
<footer class="comment-meta">
|
||||
<div class="comment-author vcard">
|
||||
<img alt=""
|
||||
src="http://1.gravatar.com/avatar/d7a973c7dab26985da5f961be7b74480?s=56&d=mm&r=g"
|
||||
srcset="http://1.gravatar.com/avatar/d7a973c7dab26985da5f961be7b74480?s=112&d=mm&r=g 2x"
|
||||
class="avatar avatar-56 photo" height="56" width="56" loading="lazy">
|
||||
<b class="fn">
|
||||
<a href="https://cn.wordpress.org/" rel="external nofollow ugc"
|
||||
class="url">一位WordPress评论者</a>
|
||||
</b>
|
||||
<span class="says">说道:</span></div><!-- .comment-author -->
|
||||
|
||||
<div class="comment-metadata">
|
||||
<a href="/p/1#comment-1">
|
||||
<time datetime="2022-08-19T09:26:37+08:00">2022年 8月 19日 上午9:26</time>
|
||||
</a></div><!-- .comment-metadata -->
|
||||
|
||||
</footer><!-- .comment-meta -->
|
||||
|
||||
<div class="comment-content">
|
||||
<p>您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 <a
|
||||
href="https://cn.gravatar.com/">Gravatar</a>。</p>
|
||||
</div><!-- .comment-content -->
|
||||
|
||||
<div class="reply">
|
||||
<a rel="nofollow" class="comment-reply-link"
|
||||
href="/p/1?replytocom=1#respond" data-commentid="1" data-postid="1"
|
||||
data-belowelement="div-comment-1" data-respondelement="respond"
|
||||
data-replyto="回复给一位WordPress评论者"
|
||||
aria-label="回复给一位WordPress评论者">回复</a>
|
||||
</div>
|
||||
</article><!-- .comment-body -->
|
||||
</li><!-- #comment-## -->
|
||||
</ol><!-- .comment-list -->
|
||||
|
||||
{{if .canComment}}
|
||||
<div id="respond" class="comment-respond">
|
||||
<h3 id="reply-title" class="comment-reply-title">发表回复
|
||||
<small>
|
||||
<a rel="nofollow" id="cancel-comment-reply-link" href="/p/{{.post.Id}}#respond" style="display:none;">取消回复</a>
|
||||
</small>
|
||||
</h3>
|
||||
<form action="/wp-comments-post.php" method="post" id="commentform" class="comment-form"
|
||||
novalidate="">
|
||||
<p class="comment-notes">
|
||||
<span id="email-notes">您的电子邮箱地址不会被公开。</span>
|
||||
<span class="required-field-message" aria-hidden="true">必填项已用<span class="required" aria-hidden="true">*</span>标注</span>
|
||||
</p>
|
||||
<p class="comment-form-comment">
|
||||
<label for="comment">评论 <span class="required" aria-hidden="true">*</span></label>
|
||||
<textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required=""></textarea></p>
|
||||
<p class="comment-form-author">
|
||||
<label for="author">显示名称 <span class="required" aria-hidden="true">*</span></label>
|
||||
<input id="author" name="author" type="text" value="" size="30" maxlength="245"
|
||||
required=""></p>
|
||||
<p class="comment-form-email">
|
||||
<label for="email">电子邮箱地址 <span class="required" aria-hidden="true">*</span></label>
|
||||
<input id="email" name="email" type="email" value="" size="30" maxlength="100"
|
||||
aria-describedby="email-notes" required="">
|
||||
</p>
|
||||
<p class="comment-form-url"><label for="url">网站地址</label>
|
||||
<input id="url" name="url" type="url" value="" size="30" maxlength="200"></p>
|
||||
<p class="comment-form-cookies-consent">
|
||||
<input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes">
|
||||
<label for="wp-comment-cookies-consent">在此浏览器中保存我的显示名称、邮箱地址和网站地址,以便下次评论时使用。</label>
|
||||
</p>
|
||||
<p class="form-submit">
|
||||
<input name="submit" type="submit" id="submit" class="submit" value="发表评论">
|
||||
<input type="hidden" name="comment_post_ID" value="{{.post.Id}}" id="comment_post_ID">
|
||||
<input type="hidden" name="comment_parent" id="comment_parent" value="0">
|
||||
</p>
|
||||
</form>
|
||||
</div><!-- #respond -->
|
||||
{{end}}
|
||||
</footer>
|
||||
<!-- .entry-footer -->
|
||||
</div><!-- .comments-area -->
|
||||
|
||||
</article><!-- #post-1 -->
|
||||
<nav class="navigation post-navigation" aria-label="文章">
|
||||
<h2 class="screen-reader-text">文章导航</h2>
|
||||
|
||||
<div id="comments" class="comments-area">
|
||||
<div class="nav-links">
|
||||
{{if gt .prev.Id 0}}
|
||||
<div class="nav-previous">
|
||||
<a href="/p/{{.prev.Id}}" rel="prev">
|
||||
<span class="meta-nav" aria-hidden="true">上一篇</span>
|
||||
<span class="screen-reader-text">上篇文章:</span>
|
||||
<span class="post-title">{{.prev.PostTitle}}</span></a>
|
||||
</div>
|
||||
{{end}}
|
||||
{{if gt .next.Id 0}}
|
||||
<div class="nav-next">
|
||||
<a href="/p/{{.next.Id}}" rel="next">
|
||||
<span class="meta-nav" aria-hidden="true">下一篇</span>
|
||||
<span class="screen-reader-text">下篇文章:</span>
|
||||
<span class="post-title">{{.next.PostTitle}}</span></a>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<h2 class="comments-title">
|
||||
《{{.post.PostTitle}}》上有1条评论 </h2>
|
||||
|
||||
|
||||
<ol class="comment-list">
|
||||
<li id="comment-1" class="comment even thread-even depth-1">
|
||||
<article id="div-comment-1" class="comment-body">
|
||||
<footer class="comment-meta">
|
||||
<div class="comment-author vcard">
|
||||
<img alt="" src="http://1.gravatar.com/avatar/d7a973c7dab26985da5f961be7b74480?s=56&d=mm&r=g" srcset="http://1.gravatar.com/avatar/d7a973c7dab26985da5f961be7b74480?s=112&d=mm&r=g 2x" class="avatar avatar-56 photo" height="56" width="56" loading="lazy"> <b class="fn"><a href="https://cn.wordpress.org/" rel="external nofollow ugc" class="url">一位WordPress评论者</a></b><span class="says">说道:</span> </div><!-- .comment-author -->
|
||||
|
||||
<div class="comment-metadata">
|
||||
<a href="/p/1#comment-1"><time datetime="2022-08-19T09:26:37+08:00">2022年 8月 19日 上午9:26</time></a> </div><!-- .comment-metadata -->
|
||||
|
||||
</footer><!-- .comment-meta -->
|
||||
|
||||
<div class="comment-content">
|
||||
<p>您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 <a href="https://cn.gravatar.com/">Gravatar</a>。</p>
|
||||
</div><!-- .comment-content -->
|
||||
|
||||
<div class="reply"><a rel="nofollow" class="comment-reply-link" href="/p/1?replytocom=1#respond" data-commentid="1" data-postid="1" data-belowelement="div-comment-1" data-respondelement="respond" data-replyto="回复给一位WordPress评论者" aria-label="回复给一位WordPress评论者">回复</a></div> </article><!-- .comment-body -->
|
||||
</li><!-- #comment-## -->
|
||||
</ol><!-- .comment-list -->
|
||||
|
||||
{{if .canComment}}
|
||||
<div id="respond" class="comment-respond">
|
||||
<h3 id="reply-title" class="comment-reply-title">发表回复
|
||||
<small>
|
||||
<a rel="nofollow"
|
||||
id="cancel-comment-reply-link" href="/p/{{.post.Id}}#respond"
|
||||
style="display:none;">取消回复</a>
|
||||
</small>
|
||||
</h3>
|
||||
<form action="/wp-comments-post.php" method="post" id="commentform" class="comment-form" novalidate="">
|
||||
<p class="comment-notes"><span id="email-notes">您的电子邮箱地址不会被公开。</span> <span
|
||||
class="required-field-message" aria-hidden="true">必填项已用<span class="required"
|
||||
aria-hidden="true">*</span>标注</span>
|
||||
</p>
|
||||
<p class="comment-form-comment"><label for="comment">评论 <span class="required" aria-hidden="true">*</span></label>
|
||||
<textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525"
|
||||
required=""></textarea></p>
|
||||
<p class="comment-form-author"><label for="author">显示名称 <span class="required"
|
||||
aria-hidden="true">*</span></label>
|
||||
<input id="author" name="author" type="text" value="" size="30" maxlength="245" required=""></p>
|
||||
<p class="comment-form-email"><label for="email">电子邮箱地址 <span class="required"
|
||||
aria-hidden="true">*</span></label>
|
||||
<input id="email" name="email" type="email" value="" size="30" maxlength="100"
|
||||
aria-describedby="email-notes" required=""></p>
|
||||
<p class="comment-form-url"><label for="url">网站地址</label>
|
||||
<input id="url" name="url" type="url" value="" size="30" maxlength="200"></p>
|
||||
<p class="comment-form-cookies-consent">
|
||||
<input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes">
|
||||
<label for="wp-comment-cookies-consent">在此浏览器中保存我的显示名称、邮箱地址和网站地址,以便下次评论时使用。</label>
|
||||
</p>
|
||||
<p class="form-submit"><input name="submit" type="submit" id="submit" class="submit" value="发表评论">
|
||||
<input type="hidden" name="comment_post_ID" value="{{.post.Id}}" id="comment_post_ID">
|
||||
<input type="hidden" name="comment_parent" id="comment_parent" value="0">
|
||||
</p>
|
||||
</form>
|
||||
</div><!-- #respond -->
|
||||
{{end}}
|
||||
</div><!-- .comments-area -->
|
||||
|
||||
<nav class="navigation post-navigation" aria-label="文章">
|
||||
<h2 class="screen-reader-text">文章导航</h2>
|
||||
|
||||
<div class="nav-links">
|
||||
{{if gt .prev.Id 0}}
|
||||
<div class="nav-previous">
|
||||
<a href="/p/{{.prev.Id}}" rel="prev">
|
||||
<span class="meta-nav" aria-hidden="true">上一篇</span>
|
||||
<span class="screen-reader-text">上篇文章:</span>
|
||||
<span class="post-title">{{.prev.PostTitle}}</span></a>
|
||||
</div>
|
||||
{{end}}
|
||||
{{if gt .next.Id 0}}
|
||||
<div class="nav-next">
|
||||
<a href="/p/{{.next.Id}}" rel="next">
|
||||
<span class="meta-nav" aria-hidden="true">下一篇</span>
|
||||
<span class="screen-reader-text">下篇文章:</span>
|
||||
<span class="post-title">{{.next.PostTitle}}</span></a>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
</main><!-- .site-main -->
|
||||
</div>
|
||||
</nav>
|
||||
</main><!-- .site-main -->
|
||||
</div>
|
||||
{{end}}
|
||||
|
|
Loading…
Reference in New Issue
Block a user