Created
December 24, 2020 12:07
-
-
Save noxify/c65c95d752be0ca2fff863bb0256d731 to your computer and use it in GitHub Desktop.
Reactive Calendar filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /src/pages/Calendar.vue | |
// --> http://localhost:8080/calendar | |
<template> | |
<div> | |
<datetime v-model="date"></datetime> | |
<ul> | |
<li v-for="event in filteredList" :key="event.id"> | |
{{ event.node.summary }} | |
</li> | |
</ul> | |
</div> | |
</template> | |
<page-query> | |
query { | |
allGoogleCalendar { | |
edges { | |
node { | |
summary | |
start { | |
timestamp | |
} | |
} | |
} | |
} | |
} | |
</page-query> | |
<script> | |
import { Datetime } from 'vue-datetime'; | |
import 'vue-datetime/dist/vue-datetime.css'; | |
import moment from 'moment'; | |
export default { | |
data() { | |
return { | |
date: moment().format() | |
} | |
}, | |
components: { | |
datetime: Datetime | |
}, | |
computed: { | |
filteredList() { | |
return this.$page.allGoogleCalendar.edges.filter(element => { | |
return element.node.start.timestamp >= moment(this.date).unix(); | |
}); | |
} | |
}, | |
} | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
siteName: 'Gridsome', | |
plugins: [ | |
{ | |
use: '@jammeryhq/gridsome-source-google-calendar', | |
options: { | |
calendarId: '[email protected]', | |
apiKey: 'XXX' | |
}, | |
}, | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "google-calendar", | |
"private": true, | |
"scripts": { | |
"build": "gridsome build", | |
"develop": "gridsome develop", | |
"explore": "gridsome explore" | |
}, | |
"dependencies": { | |
"@jammeryhq/gridsome-source-google-calendar": "github:jammeryhq/gridsome-source-google-calendar", | |
"gridsome": "^0.7.0", | |
"luxon": "^1.25.0", | |
"vue-datetime": "^1.0.0-beta.14", | |
"weekstart": "^1.0.1", | |
"moment": "2.29.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment