Skip to content

Commit 8a52735

Browse files
committed
Refactor code
1 parent c676e59 commit 8a52735

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

app/components/atoms/ArticleCardContentDataPublishedAt.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
</template>
44

55
<script>
6-
import moment from 'moment'
6+
import { formatDate } from '~/utils/article'
77
88
export default {
99
props: {
@@ -14,9 +14,7 @@ export default {
1414
},
1515
computed: {
1616
formettedPublishedAt() {
17-
return moment(this.publishedAt, 'X')
18-
.locale('ja')
19-
.format('L')
17+
return formatDate(this.publishedAt)
2018
}
2119
}
2220
}

app/components/atoms/ArticleSubInfos.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<script>
1313
import { BigNumber } from 'bignumber.js'
14-
import moment from 'moment'
14+
import { formatDate } from '~/utils/article'
1515
1616
export default {
1717
props: {
@@ -26,9 +26,7 @@ export default {
2626
},
2727
computed: {
2828
formettedPublishedAt() {
29-
return moment(this.publishedAt, 'X')
30-
.locale('ja')
31-
.format('L')
29+
return formatDate(this.publishedAt)
3230
},
3331
formattedTokenAmount() {
3432
if (this.tokenAmount === undefined) return

app/utils/article.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable no-undef */
2+
import moment from 'moment'
23

34
export function getThumbnails(images) {
45
return images
@@ -33,3 +34,9 @@ export function showEmbedTweet({ $axios }) {
3334
iframely.load()
3435
})
3536
}
37+
38+
export function formatDate(date) {
39+
return moment(date, 'X')
40+
.locale('ja')
41+
.format('L')
42+
}

0 commit comments

Comments
 (0)