提交 c059faa6 编写于 作者: U ULIVZ

fix($theme-default): shouldn't transform date string at client side (close: #1035)

Move the transformation to $plugin-last-updated, BTW, expose `lang` as the 2nd argument
上级 d3384682
......@@ -4,13 +4,20 @@ module.exports = (options = {}, context) => ({
extendPageData ($page) {
const { transformer } = options
const timestamp = getGitLastUpdatedTimeStamp($page._filePath)
const $lang = $page._computed.$lang
if (timestamp) {
const lastUpdated = typeof transformer === 'function' ? transformer(timestamp) : timestamp
const lastUpdated = typeof transformer === 'function'
? transformer(timestamp, $lang)
: defaultTransformer(timestamp, $lang)
$page.lastUpdated = lastUpdated
}
}
})
function defaultTransformer (timestamp, lang) {
return new Date(timestamp).toLocaleString(lang)
}
function getGitLastUpdatedTimeStamp (filePath) {
let lastUpdated
try {
......
......@@ -73,9 +73,7 @@ export default {
},
lastUpdated () {
if (this.$page.lastUpdated) {
return new Date(this.$page.lastUpdated).toLocaleString(this.$lang)
}
return this.$page.lastUpdated
},
lastUpdatedText () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册