Skip to content

Conversation

@AnvayKharb
Copy link

@AnvayKharb AnvayKharb commented Oct 25, 2025

It Fixes: #4499
This pull request introduces pagination to the blog index page and improves the sorting and filtering logic for blog posts. Additionally, it clarifies documentation for the protocolVersion field in AsyncAPI server objects. Below are the most important changes grouped by theme:

Blog Index Page Improvements:-

  • Added pagination to the blog index, allowing users to navigate through posts with "Previous" and "Next" controls, and displaying the current page and total number of posts.
  • Refactored post sorting to use useMemo for performance, and ensured posts are sorted by featured status and date. Filtering now resets pagination to the first page.
  • Introduced a constant (POSTS_PER_PAGE) to configure the number of posts shown per page.

AsyncAPI Documentation Clarification:

  • Updated documentation to clarify that the protocolVersion field refers specifically to the version of the underlying communication protocol, not the AsyncAPI spec or application API version.

Summary by CodeRabbit

  • New Features

    • Added pagination to the blog page with Previous/Next navigation controls and page indicators for easier browsing of posts.
  • Documentation

    • Clarified protocol version field documentation to distinguish between underlying communication protocol versions and AsyncAPI specification versions, with relevant examples.

Add explicit clarification that `protocolVersion` refers to the version
of the underlying communication protocol (e.g., AMQP 0.9.1, MQTT 3.1.1),
not the AsyncAPI specification version or application API version.

Updates documentation in:
- markdown/docs/reference/specification/v3.0.0.md
- markdown/docs/concepts/asyncapi-document/structure.md

Closes ambiguity between protocol versioning and API versioning.
- Implement client-side pagination with 15 posts per page
- Add Previous/Next navigation controls with proper disabled states
- Reset pagination when filtering or clearing filters
- Maintain responsive design consistent with existing blog layout
- Display current page info and total post count
- Improve performance by only rendering visible posts
- Add pagination with Previous/Next buttons
- Display maximum 15 posts per page
- Use React state to track current page number
- Reset pagination when filters are applied
- Fix infinite re-render issue with useMemo optimization
- Maintain responsive design and existing functionality
@netlify
Copy link

netlify bot commented Oct 25, 2025

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 142fd33
🔍 Latest deploy log https://app.netlify.com/projects/asyncapi-website/deploys/68fcaa0ed7f3ed00080d80bf
😎 Deploy Preview https://deploy-preview-4505--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 25, 2025

Walkthrough

Documentation updates clarify the protocolVersion field in server objects with protocol-specific examples. TypeScript ambient declarations added for Next.js. Client-side pagination implemented for blog posts with state-based page management, filtering integration, and navigation controls.

Changes

Cohort / File(s) Summary
Documentation clarifications
markdown/docs/concepts/asyncapi-document/structure.md, markdown/docs/reference/specification/v3.0.0.md
Expanded protocolVersion field descriptions to clarify it represents the underlying communication protocol version (e.g., AMQP 0.9.1, MQTT 3.1.1, HTTP 2.0), distinguish it from AsyncAPI spec version or application API version, and note when to omit the field.
TypeScript environment declarations
next-env.d.ts
New ambient TypeScript declaration file containing Next.js type and route references with guidance not to edit manually.
Blog pagination feature
pages/blog/index.tsx
Added client-side pagination with configurable posts per page, state management for current page, memoized post sorting by date and featured flag, pagination handlers (Next/Previous), filter-aware page resets, conditional client-side rendering, and pagination UI controls with page indicators.

Sequence Diagram

sequenceDiagram
    actor User
    participant BlogPage as Blog Page
    participant State as React State
    participant Memo as useMemo
    
    User->>BlogPage: Load page / Change filter
    Note over BlogPage: Component mounts
    
    BlogPage->>State: Initialize currentPage = 1, isClient = false
    BlogPage->>Memo: Sort navItems by date & featured
    Memo-->>BlogPage: sortedPosts
    
    rect rgb(200, 220, 255)
    Note over BlogPage: useEffect activation
    BlogPage->>State: Set isClient = true
    end
    
    alt User clicks filter
        BlogPage->>State: Reset currentPage to 1
        BlogPage->>State: Update posts from filtered results
    else User clicks "Previous/Next"
        BlogPage->>State: Update currentPage
    else User clears filters
        BlogPage->>State: Reset currentPage to 1
    end
    
    rect rgb(200, 255, 200)
    Note over BlogPage: Compute pagination
    BlogPage->>Memo: Calculate currentPosts slice<br/>[startIndex...endIndex]
    Memo-->>BlogPage: currentPosts
    end
    
    alt isClient = true
        BlogPage-->>User: Render currentPosts + Pagination controls
    else isClient = false
        BlogPage-->>User: Render placeholder / empty
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Blog pagination logic: Review state management (isClient, currentPage), pagination calculations (totalPages, startIndex, endIndex), filter/clear handlers that reset pagination, and conditional rendering based on client flag.
  • useMemo sorting: Verify memoization strategy for sorting posts by date and featured flag, and ensure dependency array is correct.
  • Filter integration: Confirm that filter changes properly reset pagination to page 1 and recompute currentPosts.
  • Documentation updates: Lower complexity; focused clarifications on protocolVersion field semantics across two markdown files.

Possibly related issues

Possibly related PRs

Suggested labels

ready-to-merge, 📑 docs, area/docs

Suggested reviewers

  • derberg
  • quetzalliwrites
  • akshatnema
  • TRohit20
  • VaishnaviNandakumar

Poem

🐰 Hop along through pages now,
No more endless scrolls, oh wow!
Pagination guides the way,
Ten posts bright per sunny day.
Docs refined, types laid clear—
Better blogging brings us cheer! 🎉

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Linked Issues Check ⚠️ Warning The PR implements only partial requirements from issue #4499. The code adds client-side pagination with state management for current page, POSTS_PER_PAGE configuration, and Previous/Next navigation controls [#4499]. However, several key requirements are not addressed: URL query parameters (e.g., /blog?page=2) are not implemented, there is no evidence of getStaticProps/getStaticPaths for static generation or ISR, SEO features like canonical URLs and rel="prev"/"next" links are absent, clickable page numbers are not mentioned, tests are not included, and build scripts were not updated to support pagination. The implementation appears to be client-side only rather than the full technical solution outlined in the issue's acceptance criteria.
Out of Scope Changes Check ⚠️ Warning The pull request contains out-of-scope changes unrelated to the stated objective of adding blog pagination. The modifications to markdown/docs/concepts/asyncapi-document/structure.md and markdown/docs/reference/specification/v3.0.0.md expand documentation about the AsyncAPI protocolVersion field specification, which is independent of the blog pagination feature described in issue #4499. While the blog/index.tsx changes and next-env.d.ts are relevant to the blog feature, the documentation clarifications represent a separate documentation initiative that should have its own PR.
Title Check ⚠️ Warning The pull request title "chore: finding a good open governance model for AsyncAPI" is entirely unrelated to the actual changes in the changeset. The PR implements blog pagination with sorting and filtering logic, adds a Next.js TypeScript configuration file, and clarifies the protocolVersion field documentation in AsyncAPI specifications. The title mentions an open governance model, which is not addressed in any of these changes. A developer scanning the commit history would be misled by this title, as it describes a topic not present in the changeset. Update the pull request title to accurately reflect the main changes. A more appropriate title would be something like "feat: add blog pagination with sorting and filtering" or "chore: improve blog page with pagination and documentation updates" that correctly summarizes the primary changes across blog functionality and documentation improvements.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@asyncapi-bot
Copy link
Contributor

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 38
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 100
🔴 PWA 33

Lighthouse ran on https://deploy-preview-4505--asyncapi-website.netlify.app/

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (1)
pages/blog/index.tsx (1)

27-29: Refactor: The posts state and its update logic appear redundant.

The useEffect at lines 47-51 copies sortedPosts into the posts state, but this creates an unnecessary extra render cycle. Consider using sortedPosts directly throughout the component instead of maintaining a separate posts state. This would simplify the code and improve performance.

Apply this refactor:

-  const [posts, setPosts] = useState<IBlogPost[]>([]);
   const [isClient, setIsClient] = useState(false);
   const [currentPage, setCurrentPage] = useState(1);
+  const [filteredPosts, setFilteredPosts] = useState<IBlogPost[]>([]);

   // Memoize sorted posts to prevent unnecessary re-renders
   const sortedPosts = useMemo(() => {
     if (!navItems || navItems.length === 0) return [];
     
     return [...navItems].sort((i1: IBlogPost, i2: IBlogPost) => {
       const i1Date = new Date(i1.date);
       const i2Date = new Date(i2.date);

       if (i1.featured && !i2.featured) return -1;
       if (!i1.featured && i2.featured) return 1;

       return i2Date.getTime() - i1Date.getTime();
     });
   }, [navItems]);

-  // Update posts when sortedPosts changes
-  useEffect(() => {
-    if (sortedPosts.length > 0) {
-      setPosts(sortedPosts);
-    }
-  }, [sortedPosts]);
+  // Use filteredPosts if filtering is active, otherwise use sortedPosts
+  const posts = filteredPosts.length > 0 || Object.keys(router.query).length > 0 
+    ? filteredPosts 
+    : sortedPosts;

   const onFilter = (data: IBlogPost[]) => {
-    setPosts(data);
+    setFilteredPosts(data);
     setCurrentPage(1);
   };

Also applies to: 31-51

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d3c31cc and 142fd33.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • markdown/docs/concepts/asyncapi-document/structure.md (1 hunks)
  • markdown/docs/reference/specification/v3.0.0.md (1 hunks)
  • next-env.d.ts (1 hunks)
  • pages/blog/index.tsx (4 hunks)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Lighthouse CI
🔇 Additional comments (7)
next-env.d.ts (1)

1-6: LGTM!

This is the standard Next.js ambient TypeScript declarations file. The structure and content are correct for Next.js projects.

markdown/docs/reference/specification/v3.0.0.md (1)

413-413: LGTM! Excellent clarification.

The expanded description of the protocolVersion field clearly distinguishes between the underlying protocol version, the AsyncAPI specification version, and the application API version. The concrete examples (AMQP 0.9.1, MQTT 3.1.1, HTTP 2.0, Kafka 1.0.0) make this distinction much clearer for users.

markdown/docs/concepts/asyncapi-document/structure.md (1)

72-72: LGTM! Consistent documentation improvement.

This clarification matches the changes in the specification document, maintaining consistency across the documentation. The examples effectively illustrate the distinction between protocol version, specification version, and application API version.

pages/blog/index.tsx (4)

2-2: LGTM! Proper imports and configuration.

The addition of useMemo and the POSTS_PER_PAGE constant (set to 15) align with the stated objectives for configurable pagination.

Also applies to: 17-18


53-56: LGTM! Proper pagination reset on filter changes.

Resetting currentPage to 1 when filters are applied or cleared is the correct behavior to prevent displaying empty results pages.

Also applies to: 69-74


77-95: LGTM! Correct pagination logic.

The pagination calculations and navigation handlers are implemented correctly with proper boundary checks.


169-205: Verify actual pagination requirements and consistency with existing codebase patterns.

The review raises valid architectural concerns about pagination, but some claims need clarification:

Verified:

  • The codebase establishes a pattern for UI state: the Filter component uses router.push() with query parameters and shallow: true routing (see components/navigation/Filter.tsx:76). Pagination should follow this same pattern for consistency.
  • Current pagination uses pure client-side state, making pages non-bookmarkable and non-crawlable—inconsistent with the Filter pattern.

Unverified:

  • The review claims "PR objectives explicitly require" query parameters, rel links, sitemap updates, and ISR support, but these objectives aren't documented in the codebase or SEO guide (markdown/docs/community/011-styleguide/seo-guide.md covers headings, URLs, internal links, and images, but not pagination-specific requirements).

Action needed:
Confirm the actual PR requirements. If query-parameter pagination is needed, align it with the Filter component's established pattern. However, verify whether rel links, sitemap updates, and ISR are actual hard requirements or architectural preferences.

Comment on lines +164 to +166
{currentPosts.map((post, index) => (
<BlogPostItem key={index} post={post} />
))}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Use stable identifiers for list keys instead of array index.

Using index as the key for BlogPostItem can cause issues with React's reconciliation when posts are filtered or reordered. Use a stable unique identifier from the post object instead (e.g., post.slug, post.id, or post.title).

-  {currentPosts.map((post, index) => (
-    <BlogPostItem key={index} post={post} />
+  {currentPosts.map((post) => (
+    <BlogPostItem key={post.slug || post.title} post={post} />
   ))}
📝 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.

Suggested change
{currentPosts.map((post, index) => (
<BlogPostItem key={index} post={post} />
))}
{currentPosts.map((post) => (
<BlogPostItem key={post.slug || post.title} post={post} />
))}
🤖 Prompt for AI Agents
In pages/blog/index.tsx around lines 164 to 166, the list items use the array
index as the React key which breaks reconciliation when posts are reordered or
filtered; change the key to a stable unique identifier from the post object
(e.g., post.slug or post.id) by passing that property as the key to BlogPostItem
instead of index so keys remain consistent across renders.

@AnvayKharb AnvayKharb changed the title Finding a Good Open Governance Model for AsyncAPI chore: finding a good open governance model for AsyncAPI Oct 25, 2025
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.

[FEATURE] Add pagination to blog page for improved performance and user experience

2 participants