diff --git a/workspaces/cms-config/src/collections/roadmapPosts.ts b/workspaces/cms-config/src/collections/roadmapPosts.ts index fcc985b9c6..1bf636112b 100644 --- a/workspaces/cms-config/src/collections/roadmapPosts.ts +++ b/workspaces/cms-config/src/collections/roadmapPosts.ts @@ -15,7 +15,7 @@ export const roadmapStagesFields = [ icon: BiBullseye }, { - label: "Backlog", + label: "Details are WIP", value: "backlog", icon: AiOutlineAppstore }, diff --git a/workspaces/website/src/pages/(components)/TableOfContents/blocksToTOC.ts b/workspaces/website/src/pages/(components)/TableOfContents/blocksToTOC.ts index b1fd558ce6..d6265d1d9a 100644 --- a/workspaces/website/src/pages/(components)/TableOfContents/blocksToTOC.ts +++ b/workspaces/website/src/pages/(components)/TableOfContents/blocksToTOC.ts @@ -1,10 +1,20 @@ import remarkParse from "remark-parse"; import { unified } from "unified"; import { Index } from "unist-util-index"; - import { TopLevelBlock } from "@starknet-io/cms-data/src/pages"; import { HeadingData } from "./TableOfContents"; +/** + * `Node`type. + */ + +type Node = { + children: Node[]; + depth: number; + type: string; + value: string; +} + export function blocksToTOC(blocks: readonly TopLevelBlock[] = [], level: number, tableOfContents: HeadingData[] = []): readonly HeadingData[] { blocks.forEach((block) => { if(block.type === 'page_header'){ @@ -50,18 +60,21 @@ export function blocksToTOC(blocks: readonly TopLevelBlock[] = [], level: number .use(() => { return (tree: any) => { const typeIndex = new Index("type", tree); - const headings = typeIndex.get("heading"); - - const headingItems: HeadingData[] = headings.map((node: any) => { - const textNode = node.children.find((n: any) => { - return n.type === "text"; + const headings = typeIndex.get("heading") as Node[]; + const headingItems = headings.map(node => { + const textNode = node?.children?.find(child => { + return (child.type === "text" || child.type === "strong") && node.depth < 4; }); + if (!textNode) { + return null; + } + return { - title: textNode?.value ?? "", - level + title: textNode?.value ?? textNode?.children[0].value ?? "", + level: node.depth - 1 }; - }); + }).filter(heading => !!heading) as HeadingData[]; tableOfContents.push(...headingItems); }; diff --git a/workspaces/website/src/pages/roadmap/@slug/(components)/RoadmapPost.tsx b/workspaces/website/src/pages/roadmap/@slug/(components)/RoadmapPost.tsx index b54f2c859c..ef26ffd0b0 100644 --- a/workspaces/website/src/pages/roadmap/@slug/(components)/RoadmapPost.tsx +++ b/workspaces/website/src/pages/roadmap/@slug/(components)/RoadmapPost.tsx @@ -32,7 +32,7 @@ interface KeyValuePairs { const stages: KeyValuePairs = { "building-now": "Building now", "building-next": "Building next", - "backlog": "Backlog", + "backlog": "Details are WIP", }; export type RoadmapPostProps = {