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