2023-07-17 19:11:13 +00:00
|
|
|
<script setup>
|
|
|
|
|
|
|
|
const events = await queryContent('event')
|
2023-08-29 05:35:49 +00:00
|
|
|
.sort({ priority: 1 })
|
|
|
|
.only(['title', 'slug', 'location', 'date', 'day', 'time', 'meetup', 'priority'])
|
2023-07-17 19:11:13 +00:00
|
|
|
.limit(3)
|
|
|
|
.find()
|
|
|
|
|
2024-01-16 05:12:01 +00:00
|
|
|
import { format, isPast, addDays } from "date-fns";
|
|
|
|
|
|
|
|
let formatDate = (date) => {
|
|
|
|
date = new Date(date)
|
|
|
|
return new Date(
|
|
|
|
date.valueOf() + date.getTimezoneOffset() * 60 * 1000
|
|
|
|
)
|
|
|
|
}
|
2023-07-17 19:11:13 +00:00
|
|
|
|
|
|
|
for (let i = 0; i < events.length; i++) {
|
2024-01-16 05:12:01 +00:00
|
|
|
|
|
|
|
let date = formatDate(events[i].date)
|
2023-11-29 04:07:09 +00:00
|
|
|
events[i].past = isPast(addDays(date, 1))
|
2024-01-16 05:12:01 +00:00
|
|
|
events[i].date = format(date, 'EEE, MMM d')
|
2023-08-29 05:35:49 +00:00
|
|
|
}
|
2023-08-23 03:53:32 +00:00
|
|
|
|
2023-08-29 05:35:49 +00:00
|
|
|
// peterfisher.me.uk/blog/javascript-sort-by-soonest-date-object/
|
|
|
|
|
|
|
|
// Used for login redirect
|
|
|
|
// ?action=attend&ref=' + event.slug
|
2023-07-17 19:11:13 +00:00
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="events" id="events">
|
|
|
|
<h4>Upcoming Events</h4>
|
|
|
|
<div v-bind:class="(event.past)?'event past':'event'" v-for="event in events" :key="event.slug">
|
|
|
|
<div class="info">
|
|
|
|
<NuxtLink :to="'/event/' + event.slug"><h5>{{ event.title }}</h5></NuxtLink>
|
|
|
|
<p class="location">{{ event.location }}</p>
|
2023-08-29 05:35:49 +00:00
|
|
|
<p>{{ event.date }} · {{ event.time }}</p>
|
2023-07-17 19:11:13 +00:00
|
|
|
</div>
|
2023-08-11 19:04:34 +00:00
|
|
|
<div v-bind:class="(event.meetup)?'attend both':'attend bottom'" >
|
2023-08-29 05:35:49 +00:00
|
|
|
<NuxtLink v-if="!event.past" href="/login" >Attend event</NuxtLink>
|
2023-08-11 19:04:34 +00:00
|
|
|
</div>
|
|
|
|
<div class="meetup bottom">
|
|
|
|
<NuxtLink v-if="event.meetup" target="_BLANK"
|
|
|
|
:to="'https://www.meetup.com/capitalregionbitcoinnetwork/events/' + event.meetup + '/'">Meetup.com</NuxtLink>
|
|
|
|
</div>
|
2023-07-17 19:11:13 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|