Skip to content

Conversation

meetp90
Copy link

@meetp90 meetp90 commented Oct 3, 2025

This commit includes four refactoring improvements to enhance code maintainability and type safety:

  1. Extract TabListItem component

    • Moved inline list item JSX to separate TabListItem component
    • Improves code organization and testability
    • File: packages/docusaurus-theme-classic/src/theme/Tabs/TabListItem.tsx
  2. Make TOC highlight selectors configurable

    • Added headingAnchorClassName and navbarSelector to TOCHighlightConfig
    • Removes hardcoded class dependencies for better theme customization
    • File: packages/docusaurus-theme-common/src/hooks/useTOCHighlight.ts
  3. Improve NavbarItem types with discriminated unions

    • Replaced loose type definition with proper discriminated unions
    • Better type safety, autocomplete, and compile-time error detection
    • File: packages/docusaurus-theme-common/src/utils/useThemeConfig.ts
  4. Use path.posix.relative() in sidebar generator

    • Replaced manual string manipulation with Node.js built-in utility
    • Better maintainability and correctness
    • File: packages/docusaurus-plugin-content-docs/src/sidebars/generator.ts

All changes are backward compatible and all existing tests pass.

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

Test Plan

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

This commit includes four refactoring improvements to enhance code maintainability and type safety:

1. Extract TabListItem component
   - Moved inline list item JSX to separate TabListItem component
   - Improves code organization and testability
   - File: packages/docusaurus-theme-classic/src/theme/Tabs/TabListItem.tsx

2. Make TOC highlight selectors configurable
   - Added headingAnchorClassName and navbarSelector to TOCHighlightConfig
   - Removes hardcoded class dependencies for better theme customization
   - File: packages/docusaurus-theme-common/src/hooks/useTOCHighlight.ts

3. Improve NavbarItem types with discriminated unions
   - Replaced loose type definition with proper discriminated unions
   - Better type safety, autocomplete, and compile-time error detection
   - File: packages/docusaurus-theme-common/src/utils/useThemeConfig.ts

4. Use path.posix.relative() in sidebar generator
   - Replaced manual string manipulation with Node.js built-in utility
   - Better maintainability and correctness
   - File: packages/docusaurus-plugin-content-docs/src/sidebars/generator.ts

All changes are backward compatible and all existing tests pass.
Copy link

meta-cla bot commented Oct 3, 2025

Hi @meetp90!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

This commit includes four refactoring improvements to enhance code maintainability and type safety:

1. Extract TabListItem component
   - Moved inline list item JSX to separate TabListItem component
   - Improves code organization and testability
   - File: packages/docusaurus-theme-classic/src/theme/Tabs/TabListItem.tsx

2. Make TOC highlight selectors configurable
   - Added headingAnchorClassName and navbarSelector to TOCHighlightConfig
   - Removes hardcoded class dependencies for better theme customization
   - File: packages/docusaurus-theme-common/src/hooks/useTOCHighlight.ts

3. Improve NavbarItem types with discriminated unions
   - Replaced loose type definition with proper discriminated unions
   - Better type safety, autocomplete, and compile-time error detection
   - File: packages/docusaurus-theme-common/src/utils/useThemeConfig.ts

4. Use path.posix.relative() in sidebar generator
   - Replaced manual string manipulation with Node.js built-in utility
   - Better maintainability and correctness
   - File: packages/docusaurus-plugin-content-docs/src/sidebars/generator.ts

All changes are backward compatible and all existing tests pass.
@meta-cla meta-cla bot added the CLA Signed Signed Facebook CLA label Oct 3, 2025
@meetp90 meetp90 force-pushed the refactor/code-quality-improvements branch from c0fa1d7 to 135f6ff Compare October 3, 2025 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant