Skip to content

Conversation

@2u841r
Copy link

@2u841r 2u841r commented Nov 12, 2025

otherwise, can be confusion.
and in most case- tags and categories for personal, even business blog exceed 10 but not 100.

request: update README

Summary by CodeRabbit

  • Bug Fixes
    • Improved data retrieval for categories, tags, pages, and authors to fetch complete result sets.

@vercel
Copy link

vercel bot commented Nov 12, 2025

@2u841r is attempting to deploy a commit to the 9d8 Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Nov 12, 2025

Walkthrough

Four API fetching functions in the WordPress library (getAllCategories, getAllTags, getAllPages, getAllAuthors) now append ?per_page=100 to their endpoints to request 100 items per page instead of the default pagination limit.

Changes

Cohort / File(s) Summary
WordPress API pagination updates
lib/wordpress.ts
Modified getAllCategories, getAllTags, getAllPages, and getAllAuthors to fetch with explicit per_page=100 query parameter appended to endpoints

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5–10 minutes

  • Homogeneous, repetitive pattern applied consistently across four functions
  • Single file modified with straightforward query parameter additions
  • No structural or logic complexity changes
  • Verify that the query parameter syntax is correct and doesn't break existing functionality

Suggested reviewers

  • youngbloodcyb

Poem

🐰 Four functions march in perfect stride,
Each one asks for more items to collide,
From 100 to 100, the pattern so neat,
Pagination's rhythm now sounds more sweet!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically describes the main change: adding ?per_page=100 query parameter to four API endpoints (tags, categories, pages, authors).
✨ 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.

Copy link

@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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3abffe5 and 124632e.

📒 Files selected for processing (1)
  • lib/wordpress.ts (4 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
Repo: 9d8dev/next-wp PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-06-26T17:28:47.375Z
Learning: Paginate content with a sensible default (e.g., 9 posts per page) to balance performance and usability.
📚 Learning: 2025-06-26T17:28:47.375Z
Learnt from: CR
Repo: 9d8dev/next-wp PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-06-26T17:28:47.375Z
Learning: Define all TypeScript interfaces for WordPress entities (Post, Page, Category, Tag, Author, Media) in a dedicated type definition file (e.g., lib/wordpress.d.ts) to ensure strict typing and maintainability.

Applied to files:

  • lib/wordpress.ts
🧬 Code graph analysis (1)
lib/wordpress.ts (5)
lib/wordpress.d.ts (4)
  • Category (106-109)
  • Tag (111-113)
  • Page (81-93)
  • Author (115-124)
app/posts/page.tsx (1)
  • Page (35-164)
app/posts/categories/page.tsx (1)
  • Page (15-37)
app/posts/authors/page.tsx (1)
  • Page (15-35)
app/posts/tags/page.tsx (1)
  • Page (15-35)


export async function getAllCategories(): Promise<Category[]> {
return wordpressFetch<Category[]>("/wp-json/wp/v2/categories");
return wordpressFetch<Category[]>("/wp-json/wp/v2/categories?per_page=100");
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Refactor to use query parameter objects for consistency and address silent truncation.

The implementation hardcodes ?per_page=100 directly in the URL path, which is inconsistent with the rest of the codebase. Other functions like searchCategories (line 330), searchTags (line 337), searchAuthors (line 344), and getAllPosts (line 191) properly use the query parameter object.

More critically, the hardcoded limit of 100 creates a silent truncation issue: if a WordPress site has more than 100 categories/tags/pages/authors, the functions will return incomplete data without any indication, despite their names suggesting they return "all" items. This contradicts the function semantics and could break UI components that expect complete data (e.g., app/posts/categories/page.tsx displays "All Categories").

Apply this diff to use query objects consistently:

 export async function getAllCategories(): Promise<Category[]> {
-  return wordpressFetch<Category[]>("/wp-json/wp/v2/categories?per_page=100");
+  return wordpressFetch<Category[]>("/wp-json/wp/v2/categories", { per_page: 100 });
 }
 export async function getAllTags(): Promise<Tag[]> {
-  return wordpressFetch<Tag[]>("/wp-json/wp/v2/tags?per_page=100");
+  return wordpressFetch<Tag[]>("/wp-json/wp/v2/tags", { per_page: 100 });
 }
 export async function getAllPages(): Promise<Page[]> {
-  return wordpressFetch<Page[]>("/wp-json/wp/v2/pages?per_page=100");
+  return wordpressFetch<Page[]>("/wp-json/wp/v2/pages", { per_page: 100 });
 }
 export async function getAllAuthors(): Promise<Author[]> {
-  return wordpressFetch<Author[]>("/wp-json/wp/v2/users?per_page=100");
+  return wordpressFetch<Author[]>("/wp-json/wp/v2/users", { per_page: 100 });
 }

Consider implementing proper pagination:

For sites with >100 items, implement pagination loops similar to getAllPostSlugs (lines 352-375) to fetch all pages of results, or rename these functions to indicate the limitation (e.g., getCategories with a limit parameter).

Also applies to: 260-260, 274-274, 288-288

🤖 Prompt for AI Agents
In lib/wordpress.ts around line 232 (and likewise at 260, 274, 288), the
function currently hardcodes "?per_page=100" in the URL which is inconsistent
with the rest of the module and silently truncates results; change the call to
pass a query object (e.g., { per_page: 100 }) to wordpressFetch for consistency,
and implement proper pagination to fetch subsequent pages (loop over page=1..n
using response headers or incrementing page until empty, like getAllPostSlugs)
so the function truly returns all categories (or else rename to a limited
getCategories/withLimit API and surface the limit).

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.

1 participant