@@ -3,6 +3,7 @@ import Link from "next/link";
3
3
import NewsSection from "@/components/Strapi/Sections/NewsSection" ;
4
4
import Card from "@/components/Strapi/Common/Card" ;
5
5
import { CardContent , GenericContentEntry } from "@/types/strapi" ;
6
+ import List from "../Common/List" ;
6
7
7
8
type ContentProps = {
8
9
entries : GenericContentEntry [ ] ;
@@ -12,31 +13,40 @@ export default function PageContent({ entries }: ContentProps) {
12
13
if ( ! ( "type" in entry ) ) {
13
14
return (
14
15
< div key = { uuid } className = "text-white" >
15
- sth. went wrong
16
+ < p > The fetched component has no defined type. Pls have a look in the strapi backend and change your component definition accordingly </ p >
16
17
</ div >
17
18
) ;
18
19
}
19
20
20
- if ( entry . type === "Card" || entry . type === "Plain" || entry . type === "Accordion" ) {
21
- return (
22
- < div key = { uuid } className = "[&:not(:last-child)]:mb-32" >
23
- { renderTextSection ( entry ) }
24
- </ div >
25
- ) ;
26
- } else if ( entry . type === "Primary" || entry . type === "CTA" || entry . type === "Secondary" ) {
27
- return (
28
- < div key = { uuid } className = "[&:not(:last-child)]:mb-32" >
29
- < Link className = "btn-primary block w-fit mr-0 ml-auto" href = { entry . url } >
21
+ switch ( entry . type ) {
22
+ case "Card" :
23
+ case "Plain" :
24
+ case "Accordion" :
25
+ return (
26
+ < div key = { uuid } className = "[&:not(:last-child)]:mb-32" >
27
+ { renderTextSection ( entry ) }
28
+ </ div >
29
+ ) ;
30
+ case "News" :
31
+ return (
32
+ < div key = { uuid } className = "[&:not(:last-child)]:mb-32" >
33
+ < NewsSection news = { entry } />
34
+ </ div >
35
+ ) ;
36
+ case "CTA" :
37
+ case "Primary" :
38
+ case "Secondary" :
39
+ return (
40
+ < Link key = { uuid } className = "btn-primary [&:not(:last-child)]:mb-32" href = { entry . url } >
30
41
{ entry . text }
31
42
</ Link >
32
- </ div >
33
- ) ;
34
- } else if ( entry . type === "News" ) {
35
- return (
36
- < div key = { uuid } className = "[&:not(:last-child)]:mb-32" >
37
- < NewsSection news = { entry } />
38
- </ div >
39
- ) ;
43
+ ) ;
44
+ case "List" :
45
+ return (
46
+ < div className = "[&:not(:last-child)]:mb-32" >
47
+ < List key = { uuid } list = { entry . items } />
48
+ </ div >
49
+ ) ;
40
50
}
41
51
} ;
42
52
@@ -51,5 +61,5 @@ export default function PageContent({ entries }: ContentProps) {
51
61
}
52
62
} ;
53
63
54
- return < > { entries . map ( entry => renderContent ( crypto . randomUUID ( ) , entry ) ) } </ > ;
64
+ return entries . map ( entry => renderContent ( crypto . randomUUID ( ) , entry ) ) ;
55
65
}
0 commit comments