[TASK-7545] fix(footer): make docs external link#567
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe changes in this pull request involve modifications to the Changes
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 (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (2)
src/components/Global/Footer/consts.ts (1)
Line range hint
1-50: Consider extracting duplicate URLs to constants.The docs URL 'https://docs.peanut.to' appears in both
SOCIALSandLINKSarrays. Consider extracting common URLs to shared constants to improve maintainability.import * as icons from '@/assets/icons' +const EXTERNAL_URLS = { + DOCS: 'https://docs.peanut.to', + TWITTER: 'https://twitter.com/peanutprotocol', + DISCORD: 'https://discord.gg/BX9Ak7AW28', + GITHUB: 'https://github.com/peanutprotocol/', +} + export const SOCIALS = [ { name: 'twitter', - url: 'https://twitter.com/peanutprotocol', + url: EXTERNAL_URLS.TWITTER, logoSrc: icons.TWITTER_ICON.src, }, // ... other socials with similar changes { name: 'gitbook', - url: 'https://docs.peanut.to', + url: EXTERNAL_URLS.DOCS, logoSrc: icons.GITBOOK_ICON.src, }, ] export const LINKS = [ { name: 'Docs', - url: 'https://docs.peanut.to', + url: EXTERNAL_URLS.DOCS, }, // ... rest of the links ]src/components/Global/Footer/index.tsx (1)
Line range hint
12-36: Consider unifying external link handling.The component handles external links differently between SOCIALS (hardcoded
target="_blank") and LINKS (conditional target). Consider extracting this logic into a shared utility function for consistency.+const getExternalLinkProps = (url: string) => ({ + target: url.startsWith('http') ? '_blank' : undefined, + rel: url.startsWith('http') ? 'noopener noreferrer' : undefined, +}); + const Footer = () => { return ( // ... {_consts.SOCIALS.map((social) => ( <Link key={social.name} href={social.url} - target="_blank" + {...getExternalLinkProps(social.url)} > ))} // ... {_consts.LINKS.map((link) => ( <Link key={link.name} href={link.url} - target={link.url.startsWith('http') ? '_blank' : undefined} + {...getExternalLinkProps(link.url)} > ))} // ... ); };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/components/Global/Footer/consts.ts(1 hunks)src/components/Global/Footer/index.tsx(1 hunks)
🔇 Additional comments (1)
src/components/Global/Footer/consts.ts (1)
29-29: LGTM! URL change aligns with external docs strategy.
The change from relative to absolute URL is consistent with the existing external docs URL pattern in the SOCIALS constant.
| <Link | ||
| key={link.name} | ||
| href={link.url} | ||
| target={link.url.startsWith('http') ? '_blank' : undefined} |
There was a problem hiding this comment.
Add security attributes for external links.
When opening links in new tabs using target="_blank", it's important to include rel="noopener noreferrer" to prevent potential security vulnerabilities.
-target={link.url.startsWith('http') ? '_blank' : undefined}
+target={link.url.startsWith('http') ? '_blank' : undefined}
+rel={link.url.startsWith('http') ? 'noopener noreferrer' : undefined}📝 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.
| target={link.url.startsWith('http') ? '_blank' : undefined} | |
| target={link.url.startsWith('http') ? '_blank' : undefined} | |
| rel={link.url.startsWith('http') ? 'noopener noreferrer' : undefined} |
Summary by CodeRabbit
New Features
Bug Fixes