Fixed no shortcode

This commit is contained in:
cdricms
2025-02-11 10:21:45 +01:00
parent 2c2be9fdba
commit f84f7fcf8b
2 changed files with 10 additions and 9 deletions

View File

@@ -15,7 +15,7 @@ export default async function Home() {
const res = await fetch(query);
videos = await res.json();
}
const hero = await getShortcode("hero_image");
const hero = await getShortcode("foo");
const systemEvolution = await getShortcode("evolution_systeme");
const fondations = await getShortcode("fondements");
const todaysPrinciples = await getShortcode("aujourdhui");
@@ -23,7 +23,7 @@ export default async function Home() {
<main>
<Hero
background={
hero.media?.url ??
hero?.media?.url ??
"https://shadcnblocks.com/images/block/placeholder-2.svg"
}
/>
@@ -46,7 +46,7 @@ export default async function Home() {
title="Les Fondements de Latosa Escrima Concepts"
position="left"
image={
fondations.media?.url ??
fondations?.media?.url ??
"https://shadcnblocks.com/images/block/placeholder-2.svg"
}
>
@@ -85,7 +85,7 @@ export default async function Home() {
title="LÉvolution du Système"
position="right"
image={
systemEvolution.media?.url ??
systemEvolution?.media?.url ??
"https://shadcnblocks.com/images/block/placeholder-2.svg"
}
>
@@ -133,7 +133,7 @@ export default async function Home() {
title="Les Principes du Système Aujourdhui"
position="left"
image={
todaysPrinciples.media?.url ??
todaysPrinciples?.media?.url ??
"https://shadcnblocks.com/images/block/placeholder-2.svg"
}
>

View File

@@ -1,13 +1,14 @@
import IShortcode from "@/interfaces/IShortcode";
import request from "./request";
export default async function getShortcode(code: string): Promise<IShortcode> {
export default async function getShortcode(
code: string,
): Promise<IShortcode | null> {
const res = await request<IShortcode>(`/shortcodes/${code}`, {
method: "GET",
requiresAuth: false,
});
if (res.status === "Error" || !res.data)
throw new Error("Shortcode doesn't exist.");
if (res.status === "Error") throw new Error("Shortcode doesn't exist.");
return res.data;
return res.data ?? null;
}