2
2
export type BaseTocItem = {
3
3
fullPath : string
4
4
title : string
5
- intro ?: string
5
+ intro ?: string | null
6
6
}
7
7
8
8
// Valid octicon types that match the CookBookArticleCard component
@@ -23,19 +23,19 @@ export type ValidOcticon =
23
23
24
24
// Extended type for child TOC items with additional metadata
25
25
export type ChildTocItem = BaseTocItem & {
26
- octicon ?: ValidOcticon
27
- category ?: string [ ]
28
- complexity ?: string [ ]
29
- industry ?: string [ ]
26
+ octicon ?: ValidOcticon | null
27
+ category ?: string [ ] | null
28
+ complexity ?: string [ ] | null
29
+ industry ?: string [ ] | null
30
30
}
31
31
32
32
// Main TOC item type that can contain children
33
33
export type TocItem = BaseTocItem & {
34
34
childTocItems ?: ChildTocItem [ ]
35
- octicon ?: ValidOcticon
36
- category ?: string [ ]
37
- complexity ?: string [ ]
38
- industry ?: string [ ]
35
+ octicon ?: ValidOcticon | null
36
+ category ?: string [ ] | null
37
+ complexity ?: string [ ] | null
38
+ industry ?: string [ ] | null
39
39
}
40
40
41
41
// Type alias for article card components
@@ -90,11 +90,11 @@ export function mapRawTocItemToTocItem(raw: RawTocItem): TocItem {
90
90
return {
91
91
fullPath : raw . fullPath ,
92
92
title : raw . title ,
93
- intro : raw . intro || undefined ,
94
- octicon : isValidOcticon ( raw . octicon ) ? raw . octicon : undefined ,
95
- category : raw . category || undefined ,
96
- complexity : raw . complexity || undefined ,
97
- industry : raw . industry || undefined ,
93
+ intro : raw . intro || null ,
94
+ octicon : isValidOcticon ( raw . octicon ) ? raw . octicon : null ,
95
+ category : raw . category || null ,
96
+ complexity : raw . complexity || null ,
97
+ industry : raw . industry || null ,
98
98
childTocItems : raw . childTocItems ?. map ( mapRawTocItemToTocItem ) ,
99
99
}
100
100
}
@@ -104,7 +104,7 @@ export function mapRawTocItemToSimpleTocItem(raw: RawTocItem): SimpleTocItem {
104
104
return {
105
105
fullPath : raw . fullPath ,
106
106
title : raw . title ,
107
- intro : raw . intro || undefined ,
107
+ ... ( raw . intro && { intro : raw . intro } ) ,
108
108
childTocItems : raw . childTocItems ?. map ( ( child ) => ( {
109
109
fullPath : child . fullPath ,
110
110
title : child . title ,
0 commit comments