-
Notifications
You must be signed in to change notification settings - Fork 4
Hide Updates section when no updates #32
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis pull request introduces conditional rendering and asynchronous data fetching across multiple components in the website application. The changes focus on dynamically displaying blog updates, ensuring that navigation and content sections only render when actual blog content is available. The modifications enhance the user interface by preventing the display of empty or unnecessary sections, creating a more responsive and context-aware layout. Changes
Sequence DiagramsequenceDiagram
participant User
participant RootLayout
participant HomePage
participant BlogPage
participant DataSource
RootLayout->>DataSource: getAllBlogs()
DataSource-->>RootLayout: blogs array
RootLayout->RootLayout: Determine hasUpdates
RootLayout->>HomePage: Render with update status
HomePage->>DataSource: Fetch blogs
DataSource-->>HomePage: Blog entries
HomePage->HomePage: Conditional rendering
User->>HomePage: View page
Possibly related PRs
Poem
🪧 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 (
|
| ))} | ||
| {blogs.length === 0 ? ( | ||
| <p className="text-left text-lg text-gray-600"> | ||
| No updates yet! Check back soon. 😊 |
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.
I moved this here because this page is still accessible directly and will likely get indexed by the search engines
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: 0
🧹 Nitpick comments (2)
apps/website/app/blog/page.tsx (1)
20-41: **Consistent mapping for blog entries **The mapping logic is correct and concise. One potential enhancement is to incorporate graceful handling in case a blog is missing a required field (e.g., slug or date). For instance, adding optional chaining or a fallback value can guard against future data errors.
apps/website/app/layout.tsx (1)
64-74: **Filtering and mapping nav items **Using a type guard to filter out falsy items is a clean approach when constructing the navigation array. As an alternative, you could preprocess this list earlier or define a typed array of menu items for clarity. For example:
- .filter((item): item is string => Boolean(item)) + .filter(Boolean) // If item is strictly a string or null, this might sufficeThis reduces verbosity while maintaining type safety if your environment and linter rules allow.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
apps/website/app/blog/page.tsx(1 hunks)apps/website/app/layout.tsx(3 hunks)apps/website/app/page.tsx(1 hunks)
🔇 Additional comments (5)
apps/website/app/blog/page.tsx (1)
15-19: **Helpful user feedback with a friendly message **
This conditional block for displaying "No updates yet! Check back soon. 😊" provides a clear, user-friendly message when there are no updates. Great job on improving the user experience by making it obvious that new content is forthcoming.
apps/website/app/layout.tsx (3)
7-7: **Import statement for blog data fetching **
Good job ensuring that the getAllBlogs method is available for asynchronous data retrieval. This makes the layout more dynamic while centralizing data access.
27-32: **Async function and boolean cast **
Converting RootLayout into an async function is a great approach for pre-fetching data. The double-bang (!!) operator is a concise way to transform the blog count into a boolean. However, consider properly handling potential errors from getAllBlogs(), such as with a try/catch block, especially if external dependencies or network issues can arise.
Do you want a sample snippet demonstrating robust error handling?
59-59: **Conditional menu item for updates **
Conditionally rendering the "Updates" menu item based on blog availability neatly prevents navigation clutter when no updates exist. This approach aligns perfectly with the PR objective of hiding sections that have no content.
apps/website/app/page.tsx (1)
423-467: **Effective conditional rendering of the Latest Updates section **
Wrapping the entire "Latest Updates" card in a {blogs.length > 0 && (...)} block ensures users aren’t shown an empty updates section. This aligns with the overall UX goal of hiding sections with no content. Nicely done!
sid597
left a comment
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.
Agree
@sid597 As we are unsure when the first update will come, I think we should hide the section until we get the first update.
Summary by CodeRabbit
New Features
Bug Fixes
Chores