@@ -8,6 +8,7 @@ import { callHook } from '../init/lifecycle'
8
8
import { getBasePath , getPath , isAbsolutePath } from '../route/util'
9
9
import { isPrimitive } from '../util/core'
10
10
import { isMobile } from '../util/env'
11
+ import tinydate from 'tinydate'
11
12
12
13
function executeScript ( ) {
13
14
const script = dom . findAll ( '.markdown-section>script' )
@@ -21,6 +22,16 @@ function executeScript () {
21
22
} , 0 )
22
23
}
23
24
25
+ function formatUpdated ( html , updated , fn ) {
26
+ updated = typeof fn === 'function'
27
+ ? fn ( updated )
28
+ : typeof fn === 'string'
29
+ ? tinydate ( fn ) ( new Date ( updated ) )
30
+ : updated
31
+
32
+ return html . replace ( / { d o c s i f y - u p d a t e d } / g, updated )
33
+ }
34
+
24
35
function renderMain ( html ) {
25
36
if ( ! html ) {
26
37
// TODO: Custom 404 page
@@ -97,9 +108,11 @@ export function renderMixin (proto) {
97
108
getAndActive ( 'nav' )
98
109
}
99
110
100
- proto . _renderMain = function ( text ) {
111
+ proto . _renderMain = function ( text , opt ) {
101
112
callHook ( this , 'beforeEach' , text , result => {
102
- const html = this . isHTML ? result : markdown ( result )
113
+ let html = this . isHTML ? result : markdown ( result )
114
+ html = formatUpdated ( html , opt . updatedAt , this . config . formatUpdated )
115
+
103
116
callHook ( this , 'afterEach' , html , text => renderMain . call ( this , text ) )
104
117
} )
105
118
}
0 commit comments