This repository was archived by the owner on May 13, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +33
-3
lines changed Expand file tree Collapse file tree 5 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,23 @@ module.exports = {
27
27
28
28
## Options
29
29
30
+ ### dateFormat
31
+
32
+ - Type: `string'
33
+ - Default: 'ddd MMM DD YYYY'
34
+
35
+ You can find all available formats [ here] ( https://github.com/iamkun/dayjs/blob/dev/docs/en/API-reference.md#displaying )
36
+
37
+ e.g.
38
+
39
+ ``` js
40
+ module .exports = {
41
+ themeConfig: {
42
+ dateFormat: ' YYYY-MM-DD'
43
+ }
44
+ }
45
+ ```
46
+
30
47
### nav
31
48
32
49
- Type: ` Array<{ text: string, link: string }> `
Original file line number Diff line number Diff line change @@ -3,6 +3,10 @@ module.exports = {
3
3
description : 'This is a blog example built by VuePress' ,
4
4
theme : require . resolve ( '../../' ) ,
5
5
themeConfig : {
6
+ /**
7
+ * Ref: https://vuepress-theme-blog.ulivz.com/#dateFormat
8
+ */
9
+ dateFormat : 'YYYY-MM-DD' ,
6
10
/**
7
11
* Ref: https://vuepress-theme-blog.ulivz.com/#nav
8
12
*/
Original file line number Diff line number Diff line change 21
21
22
22
<div v-if =" page.frontmatter.date" class =" ui-post-date" >
23
23
<ClockIcon />
24
- <span >{{ resovlePostDate (page.frontmatter.date) }}</span >
24
+ <span >{{ resolvePostDate (page.frontmatter.date) }}</span >
25
25
</div >
26
26
</div >
27
27
</div >
37
37
/* global THEME_BLOG_PAGINATION_COMPONENT */
38
38
39
39
import Vue from ' vue'
40
+ import dayjs from ' dayjs'
40
41
import { NavigationIcon , ClockIcon } from ' vue-feather-icons'
41
42
import {
42
43
Pagination ,
@@ -76,8 +77,10 @@ export default {
76
77
return Vue .component (n) || Pagination
77
78
},
78
79
79
- resovlePostDate (date ) {
80
- return new Date (date .replace (/ \- / g , ' /' ).trim ()).toDateString ()
80
+ resolvePostDate (date ) {
81
+ return dayjs (date).format (
82
+ this .$themeConfig .dateFormat || ' ddd MMM DD YYYY'
83
+ )
81
84
},
82
85
},
83
86
}
Original file line number Diff line number Diff line change 47
47
"@vuepress/plugin-nprogress" : " 1.0.0" ,
48
48
"@vuepress/plugin-pwa" : " 1.0.0" ,
49
49
"@vuepress/plugin-search" : " 1.0.0" ,
50
+ "dayjs" : " ^1.8.19" ,
50
51
"remove-markdown" : " ^0.3.0" ,
51
52
"vue-feather-icons" : " ^4.21.0"
52
53
},
Original file line number Diff line number Diff line change @@ -2973,6 +2973,11 @@ dateformat@^3.0.0:
2973
2973
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae"
2974
2974
integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==
2975
2975
2976
+ dayjs@^1.8.19 :
2977
+ version "1.8.19"
2978
+ resolved "https://registry.npm.taobao.org/dayjs/download/dayjs-1.8.19.tgz#5117dc390d8f8e586d53891dbff3fa308f51abfe"
2979
+ integrity sha1-URfcOQ2PjlhtU4kdv/P6MI9Rq/4=
2980
+
2976
2981
de-indent@^1.0.2 :
2977
2982
version "1.0.2"
2978
2983
resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"
You can’t perform that action at this time.
0 commit comments