-
Notifications
You must be signed in to change notification settings - Fork 271
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
feat(docs): the official website adds API anchor function #2366
Conversation
WalkthroughThe changes in this pull request focus on improving the Changes
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
[e2e-test-warn] The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug". Please make sure you've read our contributing guide |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- examples/sites/src/views/components/components.vue (4 hunks)
🧰 Additional context used
🔇 Additional comments (3)
examples/sites/src/views/components/components.vue (3)
251-251
: LGTM: Route handling implementation is correct.The addition of route handling using the Vue Router's composition API is well implemented.
Also applies to: 283-284
316-316
: LGTM: Tab initialization logic is sound.The activeTab state is properly initialized based on the route hash, providing a good user experience by maintaining the selected tab across page refreshes.
Line range hint
347-376
: LGTM: API anchor links implementation is well-structured.The getApiAnchorLinks function effectively:
- Generates hierarchical anchor links for API documentation
- Properly handles grouping and nesting of links
- Maintains a clean structure for navigation
onTabsClick: (data) => { | ||
router.push(`#${data.name}`) | ||
scrollToLayoutTop() |
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.
🛠️ Refactor suggestion
Consider conditional scroll behavior for tab switching.
The current implementation always scrolls to the top when switching tabs. This might not be the desired behavior when switching to the API tab, as users might want to maintain their scroll position.
Consider updating the implementation to only scroll when necessary:
onTabsClick: (data) => {
router.push(`#${data.name}`)
- scrollToLayoutTop()
+ if (data.name !== 'api') {
+ scrollToLayoutTop()
+ }
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
onTabsClick: (data) => { | |
router.push(`#${data.name}`) | |
scrollToLayoutTop() | |
onTabsClick: (data) => { | |
router.push(`#${data.name}`) | |
if (data.name !== 'api') { | |
scrollToLayoutTop() | |
} |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- examples/sites/src/views/components/components.vue (6 hunks)
🧰 Additional context used
🔇 Additional comments (3)
examples/sites/src/views/components/components.vue (3)
133-133
: LGTM: Well-structured conditional rendering of API tab.The condition effectively prevents the API tab from showing during tests or when no APIs are available.
251-251
: LGTM: Proper implementation of route-based tab activation.The changes correctly implement route-based tab activation using Vue Router's composition API, which is essential for the API anchor functionality.
Also applies to: 283-284, 316-316
622-624
: Previous review comment is still applicable.The current implementation forces scrolling to top when switching tabs, which might not be the desired behavior for the API tab.
// 切换组件时tabs激活页变成demos | ||
state.activeTab = 'demos' |
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.
🛠️ Refactor suggestion
Consider preserving the active tab based on URL hash.
When switching components, the code always resets to the 'demos' tab. This might not be the desired behavior when users navigate via API anchor links or switch components while viewing API documentation.
Consider this implementation:
-state.activeTab = 'demos'
+state.activeTab = route.hash === '#api' ? 'api' : 'demos'
Committable suggestion was skipped due to low confidence.
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
New Features
Bug Fixes