feat: add more links to pages - #22
Conversation
Summary by BeetleThis PR enhances the DevHub website by adding extensive internal linking throughout the documentation pages and implementing smart link handling. The changes transform static documentation into an interconnected knowledge base, making navigation more intuitive and improving the user experience. Additionally, the PR adds URL hash-based highlighting for rules and introduces new redirect configurations for GitHub repositories and discussions. 📁 File Changes Summary (Consolidated across all commits):
Total Changes: 5 files changed, +122 additions, -86 deletions 🗺️ Walkthrough:graph TD
A["User visits documentation page"] --> B["PageClient renders content"]
B --> C{"Link type detection"}
C -->|"External HTTPS link"| D["LinkPreviewCard with newTab=true"]
C -->|"Redirect source link"| D
C -->|"Internal page link"| E["LinkPreviewCard with newTab=false"]
D --> F["Opens in new tab"]
E --> G["Opens in same tab"]
H["User visits /rules#06"] --> I["useEffect detects hash"]
I --> J["setActiveRule state updated"]
J --> K["Rule 06 highlighted with enhanced border"]
L["User clicks /repos shorthand"] --> M["redirects.config.ts processes"]
M --> N["Redirects to GitHub org repositories"]
style D fill:#4f46e5,stroke:#6366f1,color:#fff
style E fill:#10b981,stroke:#34d399,color:#fff
style K fill:#f59e0b,stroke:#fbbf24,color:#fff
🎯 Key Changes:
📊 Impact Assessment:
⚙️ SettingsSeverity Threshold: 📖 User Guide
|
| href={linkMatch[2]} | ||
| newTab={ | ||
| linkMatch[2].startsWith("https") || | ||
| redirects[0].sources.includes(linkMatch[2]) |
There was a problem hiding this comment.
Hardcoded array index redirects[0] will cause a runtime error if the redirects array is empty. This is a critical bug that will crash the page rendering.
Confidence: 5/5
Suggested Fix
| redirects[0].sources.includes(linkMatch[2]) | |
| redirects[0]?.sources.includes(linkMatch[2]) | |
Use optional chaining (?.) to safely access the first redirect's sources, or better yet, check if redirects array has elements before accessing. If redirects is empty, this will return undefined which is falsy, preventing the crash.
Alternatively, consider flattening all sources from all redirects:
redirects.some(redirect => redirect.sources.includes(linkMatch[2]))Prompt for AI
Copy this prompt to your AI IDE to fix this issue locally:
In app/pages/[slug]/PageClient.tsx around line 64, there's a hardcoded array access
redirects[0].sources.includes(linkMatch[2]) that will throw a runtime error if the
redirects array is empty; replace it with redirects[0]?.sources.includes(linkMatch[2])
using optional chaining, or better yet, use redirects.some(redirect =>
redirect.sources.includes(linkMatch[2])) to check all redirect sources instead of
just the first one.
|
Note Linting checks passed successfully 🎉 All formatting and code quality checks are clean. You're good to merge 🚀 |
Added more links for references and overlays