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

refactor(theme): new sidebar match algorithm and export SidebarList UI only component #1780

Merged
merged 2 commits into from
Feb 7, 2025

Conversation

SoonIter
Copy link
Member

@SoonIter SoonIter commented Jan 26, 2025

Summary

1. refactor sidebar matchPath algorithm, the old one is too hard to understand

now

assumes that user's sidebar is as below

sidebar: {
    "/guide/": [
        {
            "text": "指南",
            "items": [
                {
                    "text": "快速上手",
                    "link": "/guide/quick-start"
                },
                {
                    "text": "安装",
                    "link": "/guide/install"
                }
            ],
            "link": "",
            "collapsed": false,
            "collapsible": true
        }
    ]
}

the route which hits matchPath("/guide/", currentPathname) /guide/* would be shown

e.g: under '/guide/quick-start.html' would show the sidebar["/guide"]

before

if route hits one item in this config

e.g: "/guide/quick-start/index.html" hits {"text": "快速上手", "link": "/guide/quick-start" }

and sidebar["/guide"] would be shown

In fact, the new algorithm will be more fast in performance, and I think there aren't cases that's not be covered

2. extract SidebarList UI only component for better maintainability and someone wants to customize sidebar UI

Copy link

netlify bot commented Jan 26, 2025

Deploy Preview for aquamarine-blini-95325f ready!

Name Link
🔨 Latest commit dafb8df
🔍 Latest deploy log https://app.netlify.com/sites/aquamarine-blini-95325f/deploys/67a483c6b47d64000873a001
😎 Deploy Preview https://deploy-preview-1780--aquamarine-blini-95325f.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 67 (🔴 down 14 from production)
Accessibility: 97 (no change from production)
Best Practices: 92 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@SoonIter SoonIter marked this pull request as ready for review February 6, 2025 09:50
@SoonIter SoonIter changed the title refactor: update sidebar refactor(theme): new sidebar match algorithm Feb 6, 2025
@SoonIter SoonIter changed the title refactor(theme): new sidebar match algorithm refactor(theme): new sidebar match algorithm and export SidebarList UI only component Feb 6, 2025
@SoonIter SoonIter merged commit ea3b304 into main Feb 7, 2025
20 checks passed
@SoonIter SoonIter deleted the refactor-sidebar branch February 7, 2025 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants