Sermon dates

This commit is contained in:
2025-10-02 09:09:02 -04:00
parent 27fcedfcd5
commit a70393b375
2 changed files with 34 additions and 22 deletions

View File

@@ -2,7 +2,7 @@
<div class="bg-white rounded-lg shadow-md hover:shadow-lg transition-shadow overflow-hidden"> <div class="bg-white rounded-lg shadow-md hover:shadow-lg transition-shadow overflow-hidden">
<div class="p-6"> <div class="p-6">
<h3 class="text-xl font-semibold text-gray-900 mb-2">{{ sermon.title }}</h3> <h3 class="text-xl font-semibold text-gray-900 mb-2">{{ sermon.title }}</h3>
<p class="text-sm text-gray-500 mb-4">{{ formatDate(sermon.date) }}</p> <p class="text-sm text-gray-500 mb-4">{{ formatDate(sermon.displayDate || sermon.date) }}</p>
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<NuxtLink <NuxtLink
@@ -24,6 +24,7 @@ interface Sermon {
slug: string slug: string
title: string title: string
date: string date: string
displayDate?: string
bible_references: string bible_references: string
personal_appliance: string personal_appliance: string
pastors_challenge: string pastors_challenge: string

View File

@@ -153,28 +153,39 @@ const upcomingSermons = computed(() => {
const today = new Date() const today = new Date()
today.setHours(0, 0, 0, 0) today.setHours(0, 0, 0, 0)
return activeSermons.value.filter((s: any) => { return activeSermons.value
// Check primary date .map((s: any) => {
const sermonDate = new Date(s.date + 'T00:00:00') // Check primary date
sermonDate.setHours(0, 0, 0, 0) const sermonDate = new Date(s.date + 'T00:00:00')
if (sermonDate.getTime() > today.getTime()) return true sermonDate.setHours(0, 0, 0, 0)
// Check additional dates if they exist // If primary date is in the future, use it
if (s.dates) { if (sermonDate.getTime() > today.getTime()) {
try { return { ...s, displayDate: s.date }
const additionalDates = JSON.parse(s.dates)
return additionalDates.some((dateStr: string) => {
const additionalDate = new Date(dateStr + 'T00:00:00')
additionalDate.setHours(0, 0, 0, 0)
return additionalDate.getTime() > today.getTime()
})
} catch {
return false
} }
}
// Check additional dates if they exist
return false if (s.dates) {
}) try {
const additionalDates = JSON.parse(s.dates)
// Find the first future date from additional dates
const futureDate = additionalDates.find((dateStr: string) => {
const additionalDate = new Date(dateStr + 'T00:00:00')
additionalDate.setHours(0, 0, 0, 0)
return additionalDate.getTime() > today.getTime()
})
if (futureDate) {
return { ...s, displayDate: futureDate }
}
} catch {
return null
}
}
return null
})
.filter((s: any) => s !== null)
}) })
// Get archived sermons only for the previous sermons dropdown // Get archived sermons only for the previous sermons dropdown