fix tocitem serialization error (#56348)
This commit is contained in:
@@ -122,7 +122,7 @@ async function getTocItems(node: Tree, context: Context, opts: Options): Promise
|
|||||||
node.childPages.filter(filterHidden).map(async (child) => {
|
node.childPages.filter(filterHidden).map(async (child) => {
|
||||||
const { page } = child
|
const { page } = child
|
||||||
const title = await page.renderProp('rawTitle', context, { textOnly: true })
|
const title = await page.renderProp('rawTitle', context, { textOnly: true })
|
||||||
const octicon = page.octicon ? page.octicon : null
|
const octicon = page.octicon ?? null
|
||||||
const category = page.category ? page.category : null
|
const category = page.category ? page.category : null
|
||||||
const complexity = page.complexity ? page.complexity : null
|
const complexity = page.complexity ? page.complexity : null
|
||||||
const industry = page.industry ? page.industry : null
|
const industry = page.industry ? page.industry : null
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ export const CategoryLanding = () => {
|
|||||||
<CookBookArticleCard
|
<CookBookArticleCard
|
||||||
title={item.title}
|
title={item.title}
|
||||||
description={item.intro!}
|
description={item.intro!}
|
||||||
icon={item.octicon}
|
icon={item.octicon ?? undefined}
|
||||||
tags={[
|
tags={[
|
||||||
...(item.industry || []),
|
...(item.industry || []),
|
||||||
...(item.category || []),
|
...(item.category || []),
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
export type BaseTocItem = {
|
export type BaseTocItem = {
|
||||||
fullPath: string
|
fullPath: string
|
||||||
title: string
|
title: string
|
||||||
intro?: string
|
intro?: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid octicon types that match the CookBookArticleCard component
|
// Valid octicon types that match the CookBookArticleCard component
|
||||||
@@ -23,19 +23,19 @@ export type ValidOcticon =
|
|||||||
|
|
||||||
// Extended type for child TOC items with additional metadata
|
// Extended type for child TOC items with additional metadata
|
||||||
export type ChildTocItem = BaseTocItem & {
|
export type ChildTocItem = BaseTocItem & {
|
||||||
octicon?: ValidOcticon
|
octicon?: ValidOcticon | null
|
||||||
category?: string[]
|
category?: string[] | null
|
||||||
complexity?: string[]
|
complexity?: string[] | null
|
||||||
industry?: string[]
|
industry?: string[] | null
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main TOC item type that can contain children
|
// Main TOC item type that can contain children
|
||||||
export type TocItem = BaseTocItem & {
|
export type TocItem = BaseTocItem & {
|
||||||
childTocItems?: ChildTocItem[]
|
childTocItems?: ChildTocItem[]
|
||||||
octicon?: ValidOcticon
|
octicon?: ValidOcticon | null
|
||||||
category?: string[]
|
category?: string[] | null
|
||||||
complexity?: string[]
|
complexity?: string[] | null
|
||||||
industry?: string[]
|
industry?: string[] | null
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type alias for article card components
|
// Type alias for article card components
|
||||||
@@ -90,11 +90,11 @@ export function mapRawTocItemToTocItem(raw: RawTocItem): TocItem {
|
|||||||
return {
|
return {
|
||||||
fullPath: raw.fullPath,
|
fullPath: raw.fullPath,
|
||||||
title: raw.title,
|
title: raw.title,
|
||||||
intro: raw.intro || undefined,
|
intro: raw.intro || null,
|
||||||
octicon: isValidOcticon(raw.octicon) ? raw.octicon : undefined,
|
octicon: isValidOcticon(raw.octicon) ? raw.octicon : null,
|
||||||
category: raw.category || undefined,
|
category: raw.category || null,
|
||||||
complexity: raw.complexity || undefined,
|
complexity: raw.complexity || null,
|
||||||
industry: raw.industry || undefined,
|
industry: raw.industry || null,
|
||||||
childTocItems: raw.childTocItems?.map(mapRawTocItemToTocItem),
|
childTocItems: raw.childTocItems?.map(mapRawTocItemToTocItem),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ export function mapRawTocItemToSimpleTocItem(raw: RawTocItem): SimpleTocItem {
|
|||||||
return {
|
return {
|
||||||
fullPath: raw.fullPath,
|
fullPath: raw.fullPath,
|
||||||
title: raw.title,
|
title: raw.title,
|
||||||
intro: raw.intro || undefined,
|
...(raw.intro && { intro: raw.intro }),
|
||||||
childTocItems: raw.childTocItems?.map((child) => ({
|
childTocItems: raw.childTocItems?.map((child) => ({
|
||||||
fullPath: child.fullPath,
|
fullPath: child.fullPath,
|
||||||
title: child.title,
|
title: child.title,
|
||||||
|
|||||||
Reference in New Issue
Block a user