From 979740bebc03ebb47053c82d7cdb6d9831b0b372 Mon Sep 17 00:00:00 2001 From: xing Date: Mon, 19 Sep 2022 00:16:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- route/route.go | 4 +- templates/layout/footer.gohtml | 6 +- templates/layout/pagination.gohtml | 16 +- templates/layout/sidebar.gohtml | 114 +++++++------- templates/posts/detail.gohtml | 237 ++++++++++++++++------------- 5 files changed, 199 insertions(+), 178 deletions(-) diff --git a/route/route.go b/route/route.go index 40318ff..2b85082 100644 --- a/route/route.go +++ b/route/route.go @@ -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这边本身可以不用 diff --git a/templates/layout/footer.gohtml b/templates/layout/footer.gohtml index d99876c..e20eb25 100644 --- a/templates/layout/footer.gohtml +++ b/templates/layout/footer.gohtml @@ -1,7 +1,7 @@ {{define "layout/footer"}} -
- 自豪地采用WordPress -
+
+ 自豪地采用WordPress +
{{end}} \ No newline at end of file diff --git a/templates/layout/pagination.gohtml b/templates/layout/pagination.gohtml index 0d6d34a..33bc4dd 100644 --- a/templates/layout/pagination.gohtml +++ b/templates/layout/pagination.gohtml @@ -1,10 +1,10 @@ {{define "layout/page"}} -{{if .pagination}} - -{{end}} + {{if .pagination}} + + {{end}} {{end}} \ No newline at end of file diff --git a/templates/layout/sidebar.gohtml b/templates/layout/sidebar.gohtml index 883ac38..972f38f 100644 --- a/templates/layout/sidebar.gohtml +++ b/templates/layout/sidebar.gohtml @@ -1,63 +1,65 @@ {{define "layout/sidebar" }} - {{end}} \ No newline at end of file diff --git a/templates/posts/detail.gohtml b/templates/posts/detail.gohtml index d72daf3..a5df592 100644 --- a/templates/posts/detail.gohtml +++ b/templates/posts/detail.gohtml @@ -1,133 +1,152 @@ {{template "layout/base" .}} {{define "content"}} -
-
+
+
+
+
+

{{.post.PostTitle}}

-
+
+ {{.post.PostContent|unescaped}} +
-
-

{{.post.PostTitle}}

- -
- {{.post.PostContent|unescaped}} -
- - -
+
发布于 - - {{if .post.CategoriesHtml}} - + {{if .post.CategoriesHtml}} + 分类 {{.post.CategoriesHtml|unescaped}} - {{end}} + {{end}} - {{if .post.TagsHtml}} - + {{if .post.TagsHtml}} + 标签 {{.post.TagsHtml|unescaped}} + {{end}} +
+ + +
+ +
+ +

+ 《{{.post.PostTitle}}》上有1条评论

+ + +
    +
  1. + +
  2. +
+ + {{if .canComment}} +
+

发表回复 + + + +

+
+

+ 您的电子邮箱地址不会被公开。 + +

+

+ +

+

+ +

+ +

+

+ +

+ + + +

+
+
{{end}} - - +
-
+
-
+ +
+
{{end}}