Skip to content

Commit

Permalink
rereview
Browse files Browse the repository at this point in the history
  • Loading branch information
calldelegation committed Sep 27, 2024
1 parent eeb0828 commit f623c75
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/lib/md-doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,12 @@ export class Doc {
DOCS_DIRECTORY,
`../src/generated/sidebar-links/${configSlug}.json`
);
const links = JSON.parse(readFileSync(linksPath, 'utf8'));

// Explicitly type 'links' as 'SidebarLinkItem[]'
const links = JSON.parse(
readFileSync(linksPath, 'utf8')
) as SidebarLinkItem[];

if (
(configSlug === 'guides' || configSlug === 'nightly-guides') &&
guideName
Expand All @@ -215,14 +220,14 @@ export class Doc {

const key = slug.split('/')[0].replace(/-/g, '_');

// TypeScript can now infer 'link' as 'SidebarLinkItem'
const guideLink = links.find((link) => link.key === key);

if (guideLink && guideLink.submenu) {
if (guideLink?.submenu) {
return guideLink.submenu as SidebarLinkItem[];
} else {
console.warn(`No guide link found for key: ${key}`);
return [];
}
console.warn(`No guide link found for key: ${key}`);
return [];
}
return links as SidebarLinkItem[];
}
Expand Down

0 comments on commit f623c75

Please sign in to comment.