From 97965ab99ea450170424beefcd5127e95ea0244d Mon Sep 17 00:00:00 2001 From: nuno-aac Date: Fri, 10 Nov 2023 10:42:04 +0000 Subject: [PATCH 1/2] Fix table of contents --- .../TableOfContents/blocksToTOC.ts | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) 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); }; From 7286fcea68296abf3e4a48657eb458af60e94728 Mon Sep 17 00:00:00 2001 From: nuno-aac Date: Mon, 13 Nov 2023 11:07:26 +0000 Subject: [PATCH 2/2] Update backlog header --- workspaces/cms-config/src/collections/roadmapPosts.ts | 2 +- .../src/pages/roadmap/@slug/(components)/RoadmapPost.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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 = {