From a1383d4667d3382ca7fea53daef61952463e0cf9 Mon Sep 17 00:00:00 2001
From: Rui Sousa <149320958+rccsousa@users.noreply.github.com>
Date: Fri, 11 Oct 2024 12:07:09 +0100
Subject: [PATCH] implement highlight error handling (#50)
why:
- component wasn't handling null/undefined highglights, breaking upon a
fresh install;
how:
- temporarily replaces the highlights with a placeholder;
- also updates `fetcher` with `cache: 'no-store'` as the iteration on
`main` does not handle new content properly;
---
src/app/(pages)/[slug]/page.tsx | 7 +++++--
src/app/_blocks/HubHead/Highlights/index.tsx | 2 +-
src/app/_utilities/fetcher.ts | 1 +
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/app/(pages)/[slug]/page.tsx b/src/app/(pages)/[slug]/page.tsx
index dabaaec..e58597a 100644
--- a/src/app/(pages)/[slug]/page.tsx
+++ b/src/app/(pages)/[slug]/page.tsx
@@ -17,11 +17,14 @@ import HubHead from '@/app/_blocks/HubHead'
export default async function Page({ params: { slug = 'home' } }) {
const articles = await fetcher({ query: ALL_CONTENT })
- const highglights = await fetchSettings()
+ const highlights = await fetchSettings()
+
+ console.log(articles)
+ console.log(highlights);
return (
<>
-
+
{/* Search Bar */}
diff --git a/src/app/_blocks/HubHead/Highlights/index.tsx b/src/app/_blocks/HubHead/Highlights/index.tsx
index 60db149..83866ae 100644
--- a/src/app/_blocks/HubHead/Highlights/index.tsx
+++ b/src/app/_blocks/HubHead/Highlights/index.tsx
@@ -19,7 +19,7 @@ export function Highlights({ content, main }) {
const { title, publishedAt, categories, authors } = content;
-
+ console.log(content === placeholder);
return (
<>
diff --git a/src/app/_utilities/fetcher.ts b/src/app/_utilities/fetcher.ts
index 97d189a..6f8ecd2 100644
--- a/src/app/_utilities/fetcher.ts
+++ b/src/app/_utilities/fetcher.ts
@@ -14,6 +14,7 @@ export async function fetcher(args: {
headers: {
'Content-Type': 'application/json',
},
+ cache: 'no-store',
body: JSON.stringify({
query: query,
...(variables && { variables: variables }),