Skip to content

Commit

Permalink
Fix table of contents
Browse files Browse the repository at this point in the history
  • Loading branch information
nuno-aac committed Dec 6, 2023
1 parent 3390d8b commit 6c5a1ac
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion _data/pages/ambassadors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ id: 5ecdf9cf-d433-478a-a280-07e0f860534f
title: Ambassadors Program
show_title: true
template: narrow content
toc: false
hideToc: true
parent_page: 683db5f6-c625-4fe0-a2af-3c5b6af8c2c9
breadcrumbs: true
page_last_updated: true
Expand Down
6 changes: 3 additions & 3 deletions workspaces/cms-config/src/collections/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ export const pagesCollectionConfig = {
default: "content",
},
{
name: "toc",
label: "Show table of contents",
name: "hideToc",
label: "Hide table of content",
hint: "Applies only for the 'content' template type",
widget: "boolean",
default: true,
default: false,
required: false
},
{
Expand Down
2 changes: 1 addition & 1 deletion workspaces/cms-data/src/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export interface Page extends Meta {
readonly link: string;
readonly title: string;
readonly show_title?: boolean;
readonly toc?: boolean;
readonly hideToc?: boolean;
readonly template: "landing" | "content" | "narrow content";
readonly tocCustomTitle?: string;
readonly breadcrumbs: boolean;
Expand Down
2 changes: 1 addition & 1 deletion workspaces/website/src/pages/(components)/CMSPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default function CMSPage({
</Flex>
}
rightAside={
data.template === "content" ? (
data.template === "content" && !data.hideToc ? (
<TableOfContents headings={blocksToTOC(data.blocks, 1)} {...data.tocCustomTitle && { tocCustomTitle: data.tocCustomTitle }} />
) : null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export function blocksToTOC(blocks: readonly TopLevelBlock[] = [], level: number
tableOfContents.push(headingData);
blocksToTOC(block.blocks, level + 1, tableOfContents);
}
} else if (block.type === 'video_section') {
tableOfContents.push({
title: block["scaling-eth"].title,
level
});
} else if (block.type === "ordered_block") {
const sortedBlocks = Array.from(block.blocks || []).sort((a, b) => {
return a.title.localeCompare(b.title);
Expand Down

0 comments on commit 6c5a1ac

Please sign in to comment.