Fixed no shortcode
This commit is contained in:
@@ -15,7 +15,7 @@ export default async function Home() {
|
|||||||
const res = await fetch(query);
|
const res = await fetch(query);
|
||||||
videos = await res.json();
|
videos = await res.json();
|
||||||
}
|
}
|
||||||
const hero = await getShortcode("hero_image");
|
const hero = await getShortcode("foo");
|
||||||
const systemEvolution = await getShortcode("evolution_systeme");
|
const systemEvolution = await getShortcode("evolution_systeme");
|
||||||
const fondations = await getShortcode("fondements");
|
const fondations = await getShortcode("fondements");
|
||||||
const todaysPrinciples = await getShortcode("aujourdhui");
|
const todaysPrinciples = await getShortcode("aujourdhui");
|
||||||
@@ -23,7 +23,7 @@ export default async function Home() {
|
|||||||
<main>
|
<main>
|
||||||
<Hero
|
<Hero
|
||||||
background={
|
background={
|
||||||
hero.media?.url ??
|
hero?.media?.url ??
|
||||||
"https://shadcnblocks.com/images/block/placeholder-2.svg"
|
"https://shadcnblocks.com/images/block/placeholder-2.svg"
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
@@ -46,7 +46,7 @@ export default async function Home() {
|
|||||||
title="Les Fondements de Latosa Escrima Concepts"
|
title="Les Fondements de Latosa Escrima Concepts"
|
||||||
position="left"
|
position="left"
|
||||||
image={
|
image={
|
||||||
fondations.media?.url ??
|
fondations?.media?.url ??
|
||||||
"https://shadcnblocks.com/images/block/placeholder-2.svg"
|
"https://shadcnblocks.com/images/block/placeholder-2.svg"
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -85,7 +85,7 @@ export default async function Home() {
|
|||||||
title="L’Évolution du Système"
|
title="L’Évolution du Système"
|
||||||
position="right"
|
position="right"
|
||||||
image={
|
image={
|
||||||
systemEvolution.media?.url ??
|
systemEvolution?.media?.url ??
|
||||||
"https://shadcnblocks.com/images/block/placeholder-2.svg"
|
"https://shadcnblocks.com/images/block/placeholder-2.svg"
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -133,7 +133,7 @@ export default async function Home() {
|
|||||||
title="Les Principes du Système Aujourd’hui"
|
title="Les Principes du Système Aujourd’hui"
|
||||||
position="left"
|
position="left"
|
||||||
image={
|
image={
|
||||||
todaysPrinciples.media?.url ??
|
todaysPrinciples?.media?.url ??
|
||||||
"https://shadcnblocks.com/images/block/placeholder-2.svg"
|
"https://shadcnblocks.com/images/block/placeholder-2.svg"
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import IShortcode from "@/interfaces/IShortcode";
|
import IShortcode from "@/interfaces/IShortcode";
|
||||||
import request from "./request";
|
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}`, {
|
const res = await request<IShortcode>(`/shortcodes/${code}`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
requiresAuth: false,
|
requiresAuth: false,
|
||||||
});
|
});
|
||||||
if (res.status === "Error" || !res.data)
|
if (res.status === "Error") throw new Error("Shortcode doesn't exist.");
|
||||||
throw new Error("Shortcode doesn't exist.");
|
|
||||||
|
|
||||||
return res.data;
|
return res.data ?? null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user