-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[docs] Localize the table of contents #14548
Conversation
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.
I suppose this was discussed privately? Could you add at least a short summary what the problem was and how you solved this? I see some regex was changed but without code comment or PR description the reason/intention of this change will be lost over time.
It was mentioned in the other TOC PR discussion here.
The clue is in the title :D The current regex doesn't work for unicode, due to \W stripping non ascii characters, so instead we filter common non-word characters 'manually'. The replacement regex is list of symbols to filter. Nothing more complicated than that. |
This comment has been minimized.
This comment has been minimized.
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.
Wow, I'm shocked by the simplicity of the code. It would have been a nightmare without the hook API 😳 ! The way we can memoize and derivate values is gold.
clearTimeout(unsetClickedRef.current); | ||
window.removeEventListener('hashchange', handleHashChange); | ||
}; | ||
}, [false]); |
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.
}, [false]); | |
}, []); |
Something might be wrong with the new hash logic: It would be great to add a test, it's not something we want to see regressions on (it might partially break existing links). |
The problem also existed in the old hash logic. Thanks for fixing it. I have also tweaked the logic slightly to better match the old output. The test was a great help in making sure the change didn't introduce a regression. 👍 |
That's odd. The tests that codecov is complaining about are for a file unrelated to this PR ( |
@@ -129,6 +128,21 @@ function getItemsClient(items) { | |||
return itemsClient; | |||
} | |||
|
|||
function useThrottledOnScroll(callback, delay) { |
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.
It sounds like we might be able to get rid of react-event-listener :) https://bundlephobia.com/result?p=react-event-listener@0.6.6.
The codecov issue is solved on next. |
@mbrookes Well done :) |
I have followed (at least) the PR section of the contributing guide.
Display the localized TOC instead of English
Localize the TOC heading: "Contents" ->
t('tableOfContents')
Render valid hashes for UTF8 characters rather than stripping them out
Refactor using hooks