diff --git a/handler/article.go b/handler/article.go index 70cd250..331877d 100644 --- a/handler/article.go +++ b/handler/article.go @@ -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, }) } diff --git a/handler/index.go b/handler/index.go index 91234a4..b568287 100644 --- a/handler/index.go +++ b/handler/index.go @@ -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,