Add & use timeago lib

This commit is contained in:
Hubert Van De Walle 2020-04-23 16:11:42 +02:00
parent 20daa71d51
commit 06699d2624
4 changed files with 38 additions and 28 deletions

View File

@ -14,9 +14,9 @@
</div> </div>
</div> </div>
<div class="mt-auto" v-if="!!updatedAt"> <div class="mt-auto" v-if="updatedAt">
<v-divider/> <v-divider/>
<v-card-subtitle>{{ updatedAt }}</v-card-subtitle> <v-card-subtitle>Last updated {{ updatedAt }}</v-card-subtitle>
</div> </div>
</v-card> </v-card>
</template> </template>
@ -41,7 +41,7 @@
default: null, default: null,
}, },
}, },
}; }
</script> </script>
<style> <style>

View File

@ -1,51 +1,48 @@
<template> <template>
<v-container fluid> <v-container fluid>
<v-row dense <v-row dense align-content="stretch" align="stretch">
align-content="stretch"
align="stretch"
>
<v-col <v-col
v-for="(note, index) in notes" v-for="(note, index) in notes"
:key="index" :key="index"
cols="12" sm="6" md="4" xl="3" cols="12"
class="viewer"> sm="6"
md="4"
xl="3"
class="viewer"
>
<v-hover v-slot:default="{ hover }"> <v-hover v-slot:default="{ hover }">
<Note <Note
:hover="hover" :hover="hover"
:title="note.title" :title="note.title"
:tags="note.tags" :tags="note.tags"
:updated-at="note.updatedAt" :updated-at="format(note.updatedAt)"
> >
{{ note.content }} {{ note.content }}
</Note> </Note>
</v-hover> </v-hover>
</v-col> </v-col>
</v-row> </v-row>
<v-btn to="/create" fab fixed bottom right large color="accent"> <v-btn to="/create" fab fixed bottom right large color="accent">
<v-icon>mdi-plus</v-icon> <v-icon>mdi-plus</v-icon>
</v-btn> </v-btn>
</v-container> </v-container>
</template> </template>
<script> <script>
import Note from '@/components/Note' import Note from '@/components/Note';
import { format } from 'timeago.js';
export default { export default {
name: "notes", name: 'notes',
title: "Notes", title: 'Notes',
components: { components: { Note },
Note,
},
data: () => ({ data: () => ({
notes: [] notes: [],
}), }),
methods: { format },
mounted() { mounted() {
this.$axios.get('/notes') this.$axios.get('/notes').then(e => (this.notes = e.data));
.then(e => this.notes = e.data) },
} };
}
</script> </script>

5
package.json Normal file
View File

@ -0,0 +1,5 @@
{
"dependencies": {
"timeago.js": "^4.0.2"
}
}

8
yarn.lock Normal file
View File

@ -0,0 +1,8 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
timeago.js@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/timeago.js/-/timeago.js-4.0.2.tgz#724e8c8833e3490676c7bb0a75f5daf20e558028"
integrity sha512-a7wPxPdVlQL7lqvitHGGRsofhdwtkoSXPGATFuSOA2i1ZNQEPLrGnj68vOp2sOJTCFAQVXPeNMX/GctBaO9L2w==