-
-
Notifications
You must be signed in to change notification settings - Fork 247
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
Add Table of Contents component to documentation layout #1471
base: main
Are you sure you want to change the base?
Conversation
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1471 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 396 396
Branches 106 106
=========================================
Hits 396 396 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@techmannih thanks for PR, pls. have a look to my review comments
useEffect(() => { | ||
const mainContent = document.getElementById('main-content'); | ||
const elements = mainContent | ||
? mainContent.querySelectorAll('h1, h2, h3, h4') | ||
: []; | ||
const newHeadings: { id: string; text: string; level: number }[] = []; | ||
elements.forEach((el) => { | ||
const text = el.textContent || ''; | ||
if (text.trim().toLowerCase() === 'on this page') return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@techmannih here you're using core javascript, instead use react features to get the same results
{/* Main Content (Children) */} | ||
<div | ||
id='main-content' | ||
className='col-span-4 md:col-span-2 lg:col-span-2 lg:mt-20 lg:w-5/6 mx-4 md:mx-0' | ||
> | ||
{children} | ||
</div> | ||
|
||
{/* TOC */} | ||
<div className='sticky top-16 hidden lg:block'> | ||
<TOC /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls. remove comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename the component with much sensible name. Avoid using short forms
What kind of change does this PR introduce?
Add Table of Contents component to documentation layout
Issue Number: