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