Skip to content

Commit

Permalink
implement highlight error handling (#50)
Browse files Browse the repository at this point in the history
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;
  • Loading branch information
rccsousa authored Oct 11, 2024
1 parent 0d7bdd0 commit a1383d4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/app/(pages)/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
<HubHead highlights={highglights} />
<HubHead highlights={highlights} />

{/* Search Bar */}
<SearchBar />
Expand Down
2 changes: 1 addition & 1 deletion src/app/_blocks/HubHead/Highlights/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function Highlights({ content, main }) {

const { title, publishedAt, categories, authors } = content;


console.log(content === placeholder);
return (
<>

Expand Down
1 change: 1 addition & 0 deletions src/app/_utilities/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
Expand Down

0 comments on commit a1383d4

Please sign in to comment.