wendal / gor

Golang编写的静态博客引擎
599 stars 147 forks source link

生成sitemap时 lastmod 时间格式问题 #116

Closed snaigle closed 6 years ago

snaigle commented 6 years ago

plugins.go 文件中 128行

    for _, id := range post_ids {
        f.WriteString("\t<url>\n")
        post := posts[id]
        f.WriteString("\t\t<loc>")
        xml.Escape(f, []byte(production_url_base))
        xml.Escape(f, []byte(post.Url()))
        f.WriteString("</loc>\n")
        f.WriteString(fmt.Sprintf("\t\t<lastmod>%s</lastmod>\n", post["date"])) // 是否应该抹除呢? 考虑中
        f.WriteString("\t\t<changefreq>weekly</changefreq>\n")
        f.WriteString("\t</url>\n")
    }

post["date"] 在sitemap中格式可为 2006-01-022006-01-02T15:04:05+08:00等 而实际 post["date"] 可能会为 2006-01-02 15:04:05(在 payload.go中解析post时兼容了这种写法) ,这里生成sitemap是没办法被搜索引擎解析的。

解决方案可以使用 post["_date"].format 来生成合法的 lastmod值

wendal commented 6 years ago

来个pull request可以吗?

snaigle commented 6 years ago

117 已提交

wendal commented 6 years ago

好的, 已merge