Skip to content

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

Merged
SoonIter merged 2 commits intomainfrom
refactor-sidebar
Feb 7, 2025
Merged

refactor(theme): new sidebar match algorithm and export SidebarList UI only component#1780
SoonIter merged 2 commits intomainfrom
refactor-sidebar

Conversation

@SoonIter
Copy link
Copy Markdown
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

@netlify
Copy link
Copy Markdown

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
@SoonIter SoonIter deleted the refactor-sidebar branch February 7, 2025 03:35
@SoonIter SoonIter mentioned this pull request Feb 7, 2025
2 tasks
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