File tree 2 files changed +9
-4
lines changed
2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -4,13 +4,20 @@ module.exports = (options = {}, context) => ({
4
4
extendPageData ( $page ) {
5
5
const { transformer } = options
6
6
const timestamp = getGitLastUpdatedTimeStamp ( $page . _filePath )
7
+ const $lang = $page . _computed . $lang
7
8
if ( timestamp ) {
8
- const lastUpdated = typeof transformer === 'function' ? transformer ( timestamp ) : timestamp
9
+ const lastUpdated = typeof transformer === 'function'
10
+ ? transformer ( timestamp , $lang )
11
+ : defaultTransformer ( timestamp , $lang )
9
12
$page . lastUpdated = lastUpdated
10
13
}
11
14
}
12
15
} )
13
16
17
+ function defaultTransformer ( timestamp , lang ) {
18
+ return new Date ( timestamp ) . toLocaleString ( lang )
19
+ }
20
+
14
21
function getGitLastUpdatedTimeStamp ( filePath ) {
15
22
let lastUpdated
16
23
try {
Original file line number Diff line number Diff line change @@ -73,9 +73,7 @@ export default {
73
73
},
74
74
75
75
lastUpdated () {
76
- if (this .$page .lastUpdated ) {
77
- return new Date (this .$page .lastUpdated ).toLocaleString (this .$lang )
78
- }
76
+ return this .$page .lastUpdated
79
77
},
80
78
81
79
lastUpdatedText () {
You can’t perform that action at this time.
0 commit comments