Added formatting date function for last updated
This commit is contained in:
@@ -15,15 +15,19 @@ const homepageQuery = `{
|
||||
"position": member->position
|
||||
}
|
||||
},
|
||||
"_ohLastUpdated": *[_type=="officeHours"] | order(_updatedAt desc)[0]._updatedAt,
|
||||
"ohLastUpdated": *[_type=="officeHours"] | order(_updatedAt desc)[0]._updatedAt,
|
||||
"sponsors": *[_type=="sponsors"]{
|
||||
name,
|
||||
url,
|
||||
"logo": logo.asset->url+"?h=100&fm=webp"
|
||||
},
|
||||
"_sponsorsLastUpdated": *[_type=="sponsors"] | order(_updatedAt desc)[0]._updatedAt
|
||||
"sponsorsLastUpdated": *[_type=="sponsors"] | order(_updatedAt desc)[0]._updatedAt
|
||||
}`;
|
||||
|
||||
function formattingDate(date: Date) {
|
||||
return date.toISOString().slice(0, 10).replaceAll('-', '/');
|
||||
}
|
||||
|
||||
export const load = async ({ url }) => {
|
||||
/**
|
||||
* @description Response data type based on the combined query above.
|
||||
@@ -39,7 +43,7 @@ export const load = async ({ url }) => {
|
||||
allOHs: officeHourResp,
|
||||
sponsors: sponsorsResp,
|
||||
canonical: url.href,
|
||||
ohLastUpdated: homePageResp._ohLastUpdated ?? null,
|
||||
sponsorsLastUpdated: homePageResp._sponsorsLastUpdated ?? null
|
||||
ohLastUpdated: formattingDate(new Date(homePageResp.ohLastUpdated)),
|
||||
sponsorsLastUpdated: formattingDate(new Date(homePageResp.sponsorsLastUpdated))
|
||||
};
|
||||
};
|
||||
|
||||
@@ -72,12 +72,13 @@
|
||||
<p class="text-ecsess-200">
|
||||
Come visit us in our student lounge at ENGTR 1060 to grab a coffee (free), play Mario Kart, or
|
||||
just chat about anything!
|
||||
</p>
|
||||
{#if data.ohLastUpdated}
|
||||
<br />
|
||||
<span class="text-ecsess-200/70 mb-4 inline-block italic">
|
||||
Last updated: {new Date(data.ohLastUpdated).toISOString().slice(0, 10).replaceAll('-', '/')}
|
||||
Last updated: {data.ohLastUpdated}
|
||||
</span>
|
||||
{/if}
|
||||
</p>
|
||||
<OhSchedule allOhs={data.allOHs} />
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
Reference in New Issue
Block a user