update
This commit is contained in:
@@ -27,6 +27,7 @@ type Article struct {
|
|||||||
Conf ArticleConf
|
Conf ArticleConf
|
||||||
Content string
|
Content string
|
||||||
Path string
|
Path string
|
||||||
|
Date string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Article) GetArticleById(id string) (*Article, error) {
|
func (a *Article) GetArticleById(id string) (*Article, error) {
|
||||||
@@ -59,6 +60,7 @@ func (a *Article) GetArticleByPath(path string) (*Article, error) {
|
|||||||
t, err := time.Parse("2006-1-2 15:04", articleConf["date"])
|
t, err := time.Parse("2006-1-2 15:04", articleConf["date"])
|
||||||
if err == nil {
|
if err == nil {
|
||||||
a.Conf.Time = t.Unix()
|
a.Conf.Time = t.Unix()
|
||||||
|
a.Date = time.Unix(a.Conf.Time, 0).Format("2006-01-02 15:04")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +76,7 @@ func (a *Article) GetArticleByPath(path string) (*Article, error) {
|
|||||||
mtime := info.ModTime()
|
mtime := info.ModTime()
|
||||||
a.Conf.Time = mtime.Unix()
|
a.Conf.Time = mtime.Unix()
|
||||||
a.Content = parts[0]
|
a.Content = parts[0]
|
||||||
|
a.Date = time.Unix(a.Conf.Time, 0).Format("2006-01-02 15:04")
|
||||||
}
|
}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@@ -92,6 +95,7 @@ func GetArticle(c *gin.Context) {
|
|||||||
c.HTML(200, "article.html", gin.H{
|
c.HTML(200, "article.html", gin.H{
|
||||||
"content": template.HTML(string(output)),
|
"content": template.HTML(string(output)),
|
||||||
"title": article.Conf.Title,
|
"title": article.Conf.Title,
|
||||||
|
"date": article.Date,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -49,10 +49,12 @@ func Index(c *gin.Context) {
|
|||||||
prevPage = p + 1
|
prevPage = p + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
title := os.Getenv("HOME_TITLE")
|
||||||
|
|
||||||
c.HTML(200, "index.html", gin.H{
|
c.HTML(200, "index.html", gin.H{
|
||||||
"list": list,
|
"list": list,
|
||||||
"total": total,
|
"total": total,
|
||||||
"title": "Home",
|
"title": title,
|
||||||
"page": p,
|
"page": p,
|
||||||
"nextPage": nextPage,
|
"nextPage": nextPage,
|
||||||
"prevPage": prevPage,
|
"prevPage": prevPage,
|
||||||
|
|||||||
Reference in New Issue
Block a user