diff --git a/src/lib/strapi.ts b/src/lib/strapi.ts index f8c3b63..5b38707 100644 --- a/src/lib/strapi.ts +++ b/src/lib/strapi.ts @@ -29,6 +29,39 @@ export const createRecord = async (endpoint: string, data: T) => { } }; +/** + * The following GETs a record by ID from the Strapi API + * @param endpoint - The endpoint to fetch from + * @param id - The ID of the record to fetch + * @returns The record fetched + */ +export const getRecordById = async (endpoint: string, id: string) => { + try { + const response = await fetch(`${markketplace.STRAPI_URL}/api/${endpoint}/${id}`); + return response.json(); + } + catch (error) { + console.error('Record fetch failed:', error); + return false; + } +}; + +/** + * The following GETs a record by slug from the Strapi API + * @param endpoint + * @param slug + * @returns + */ +export const getRecordBySlug = async (endpoint: string, slug: string) => { + try { + const response = await fetch(`${markketplace.STRAPI_URL}/api/${endpoint}?filters[slug]=${slug}`); + return response.json(); + } catch (error) { + console.error('Record fetch failed:', error); + return false; + } +}; + /** * Fetches data from the Strapi API * @param endpoint - The endpoint to fetch from diff --git a/src/pages/events/[slug].astro b/src/pages/events/[slug].astro index f62441f..95590db 100644 --- a/src/pages/events/[slug].astro +++ b/src/pages/events/[slug].astro @@ -137,7 +137,15 @@ const selectedImage = ) } - {}} /> + { + !event?.data?.SEO?.metaUrl && ( + {}} + /> + ) + }