fix(cms): add _resolve parameter to getCalendarItems for comprehensive data retrieval
- Updated getCalendarItems function to include the _resolve parameter set to "all", ensuring all related data is fetched. - Refined getHref function in DeadlineBannerBlock.svelte to simplify link handling by directly checking for the url property.
This commit is contained in:
@@ -676,6 +676,7 @@ export async function getCalendarItems(
|
|||||||
const base = getBaseUrl();
|
const base = getBaseUrl();
|
||||||
const url = new URL(`${base}/api/content/calendar_item`);
|
const url = new URL(`${base}/api/content/calendar_item`);
|
||||||
url.searchParams.set("_per_page", "1000");
|
url.searchParams.set("_per_page", "1000");
|
||||||
|
url.searchParams.set("_resolve", "all");
|
||||||
if (options?.locale) url.searchParams.set("_locale", options.locale);
|
if (options?.locale) url.searchParams.set("_locale", options.locale);
|
||||||
const res = await fetch(url.toString());
|
const res = await fetch(url.toString());
|
||||||
if (!res.ok) return [];
|
if (!res.ok) return [];
|
||||||
|
|||||||
@@ -71,10 +71,7 @@
|
|||||||
|
|
||||||
function getHref(link: DeadlineBannerBlockData["link"]): string {
|
function getHref(link: DeadlineBannerBlockData["link"]): string {
|
||||||
if (typeof link === "string" && link) return link;
|
if (typeof link === "string" && link) return link;
|
||||||
if (link && typeof link === "object") {
|
if (link && typeof link === "object" && link.url) return link.url;
|
||||||
if (link.url) return link.url;
|
|
||||||
if (link._slug) return `/post/${encodeURIComponent(link._slug)}`;
|
|
||||||
}
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
const href = $derived(getHref(linkValue));
|
const href = $derived(getHref(linkValue));
|
||||||
|
|||||||
Reference in New Issue
Block a user