Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: table of contents links not working #3560

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/TOC.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default function TOC({ className, cssBreakingPoint = 'xl', toc, contentSe
</div>
<div className={`${!open && 'hidden'} ${cssBreakingPoint === 'xl' ? 'xl:block' : 'lg:block'}`}>
<Scrollspy
items={tocItems.map((item) => item.slug)}
items={tocItems.map((item) => (item.slug ? item.slug : item.slugWithATag))}
currentClassName='text-primary-500 font-bold'
componentTag='div'
rootEl={contentSelector}
Expand All @@ -85,7 +85,7 @@ export default function TOC({ className, cssBreakingPoint = 'xl', toc, contentSe
<a
className={`pl-${2 ** (item.lvl - 1)} font-normal mb-1 block font-sans text-sm
text-gray-900 antialiased transition duration-100 ease-in-out hover:underline`}
href={`#${item.slug}`}
href={`#${(item.slug ? item.slug : item.slugWithATag)}`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove unnecessary parentheses to fix formatting.

The conditional logic is correct, but the extra parentheses are causing formatting issues.

-href={`#${(item.slug ? item.slug : item.slugWithATag)}`}
+href={`#${item.slug ? item.slug : item.slugWithATag}`}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
href={`#${(item.slug ? item.slug : item.slugWithATag)}`}
href={`#${item.slug ? item.slug : item.slugWithATag}`}
🧰 Tools
🪛 eslint

[error] 88-88: Replace (item.slug·?·item.slug·:·item.slugWithATag) with item.slug·?·item.slug·:·item.slugWithATag

(prettier/prettier)

🪛 GitHub Actions: PR testing - if Node project

[error] 88-88: Prettier formatting error: Extra parentheses in expression '(item.slug ? item.slug : item.slugWithATag)'

key={index}
data-testid='TOC-Link'
>
Expand Down
Loading