Skip to content

feat: add tkdodo past query and router articles to blog feed#1000

Open
KevinVandy wants to merge 2 commits into
mainfrom
add-tk-dodo-tanstack-blogs
Open

feat: add tkdodo past query and router articles to blog feed#1000
KevinVandy wants to merge 2 commits into
mainfrom
add-tk-dodo-tanstack-blogs

Conversation

@KevinVandy

@KevinVandy KevinVandy commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features
    • Added support for external blog sources (e.g., TkDodo) in the blog index, recent posts widget, and library-specific blog pages, including “Read on {source}” external links.
    • Introduced a reusable blog search input and enhanced filtering with both author and q query terms.
    • Added automated external post header image scraping and generation for consistent local image assets.
  • Improvements
    • Updated blog list fetching and sorting, including normalized author display and improved empty-state messaging.
    • Enhanced page caching behavior for blog list and library blog views.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 110405ed-5d5f-4e1c-92f2-1c7c00f86d1a

📥 Commits

Reviewing files that changed from the base of the PR and between e54fcc0 and 303194c.

📒 Files selected for processing (4)
  • src/components/BlogSearchFilter.tsx
  • src/routes/_library/$libraryId/$version.docs.blog.tsx
  • src/routes/blog.index.tsx
  • src/utils/blog.ts
✅ Files skipped from review due to trivial changes (1)
  • src/components/BlogSearchFilter.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/routes/blog.index.tsx
  • src/routes/_library/$libraryId/$version.docs.blog.tsx
  • src/utils/blog.ts

📝 Walkthrough

Walkthrough

Adds support for surfacing external blog posts (TkDodo's RSS feed) alongside internal posts. New server utilities parse RSS feeds and classify posts by library. A scraper script downloads hero images and generates a slug-to-image mapping. Blog server functions are extended with merged internal/external post endpoints and author normalization. UI components and route loaders are updated to handle externalUrl posts with external link rendering and new search filtering.

Changes

External Blog Posts Integration

Layer / File(s) Summary
BlogCardPost type, author normalization, and sorting utilities
src/utils/blog.ts
Adds BlogCardPost type, author alias normalization (normalizeBlogAuthor, normalizeBlogAuthors, updated formatAuthors), postToBlogCardPost, sortBlogCardPosts, isBlogCardPostForLibrary, and updates getDistinctAuthors to normalize before deduplication.
External RSS feed parsing and BlogCardPost mapping
src/utils/external-blog-posts.server.ts, src/utils/external-blog-post-images.generated.ts
Adds keyword-based library inference, RSS fetching with AbortController timeout, Cheerio XML parsing of items into BlogCardPost objects (slug, headerImage, externalUrl, source), per-source fetchCached wrapping, and a getExternalBlogPosts concurrent aggregator. The generated file exports externalBlogPostHeaderImages mapping tkdodo slugs to local image paths.
TkDodo blog image scraper script
scripts/scrape-tkdodo-blog-images.ts
Scrapes TkDodo's RSS feed, filters qualifying items by keyword, downloads hero images from post HTML (with Cheerio-based selection, OG/Twitter fallback, referral-image exclusion), sanitizes filenames, writes images to public/blog-assets/tkdodosblog, and emits the generated image mapping file.
Blog server functions: new endpoints and merged post lists
src/utils/blog.functions.ts
Adds setBlogListCacheHeaders, getBlogCardPosts (merging internal and external posts), two new server endpoints (fetchBlogIndexPosts, fetchBlogPostsForLibrary), rewrites fetchRecentPosts to use merged data, and normalizes authors in fetchBlogPost via normalizeBlogAuthors. RecentPost is re-derived as a Pick<BlogCardPost, ...>.
Route loaders switched to new endpoints with author normalization
src/routes/blog.index.tsx, src/routes/_library/$libraryId/$version.docs.blog.tsx
blog.index.tsx switches its loader to fetchBlogIndexPosts and introduces selectedAuthor via normalizeBlogAuthor for filtering and display. The library blog route adds fetchBlogPostsForLibrary loader with cache-control headers, uses Route.useLoaderData(), normalizes the author param, adds BlogSearchFilter for q search param, and passes full post objects to BlogCard.
UI components updated for externalUrl branching and search filtering
src/components/BlogCard.tsx, src/components/RecentPostsWidget.tsx, src/components/home/HomeSocialProofSection.tsx, src/components/BlogSearchFilter.tsx
BlogCard re-exports BlogCardPost from blog.ts, destructures externalUrl/source, and branches between external anchor and internal Link with a "Read on …" CTA. RecentPostsWidget and HomeSocialProofSection apply the same conditional rendering for external vs. internal posts. New BlogSearchFilter component provides a controlled search input for library and blog routes.

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant RouteLoader
  participant fetchBlogIndexPosts
  participant getBlogCardPosts
  participant getPublishedPosts
  participant getExternalBlogPosts
  participant ExternalRSSFeed

  Browser->>RouteLoader: navigate to /blog/
  RouteLoader->>fetchBlogIndexPosts: call server fn
  fetchBlogIndexPosts->>getBlogCardPosts: assemble merged list
  getBlogCardPosts->>getPublishedPosts: fetch internal posts
  getBlogCardPosts->>getExternalBlogPosts: fetch external posts (cached)
  getExternalBlogPosts->>ExternalRSSFeed: HTTP GET RSS (with timeout)
  ExternalRSSFeed-->>getExternalBlogPosts: RSS XML
  getExternalBlogPosts-->>getBlogCardPosts: BlogCardPost[] (external)
  getPublishedPosts-->>getBlogCardPosts: BlogCardPost[] (internal)
  getBlogCardPosts-->>fetchBlogIndexPosts: sorted merged BlogCardPost[]
  fetchBlogIndexPosts-->>RouteLoader: BlogCardPost[] + cache-control headers
  RouteLoader-->>Browser: render BlogCard (internal Link or external anchor)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • TanStack/tanstack.com#911: Modifies the same blog author filtering pages, BlogCard/BlogCardPost rendering, and blog route structure that this PR extends with external URL support and author normalization.

Suggested reviewers

  • LadyBluenotes
  • schiller-manuel

🐇 A bunny hops through RSS land,
Fetching posts with a cheerful hand.
TkDodo's words, now sorted and neat,
External links make the blog complete!
With hero images cached away,
The TanStack blog blooms every day. 🌸

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective: adding past TkDodo Query and Router articles to the blog feed via RSS integration.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-tk-dodo-tanstack-blogs

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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)
scripts/scrape-tkdodo-blog-images.ts (1)

277-283: ⚡ Quick win

Keep the batch running when one post fetch fails.

A single network/parser error currently aborts the whole run. Wrap each iteration in try/catch so remaining posts still produce mappings.

Suggested fix
   for (const item of items) {
-    const entry = await scrapePostImage(item)
-
-    if (entry) {
-      entries.push(entry)
-    }
+    try {
+      const entry = await scrapePostImage(item)
+      if (entry) {
+        entries.push(entry)
+      }
+    } catch (error) {
+      console.warn(`[skip] ${getExternalPostSlug(item)}: failed to scrape`, error)
+    }
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/scrape-tkdodo-blog-images.ts` around lines 277 - 283, The loop
iterating over items does not handle errors from the scrapePostImage function
call, causing any network or parser error to abort the entire batch. Wrap the
scrapePostImage function call and the entry push logic inside a try/catch block
within the for loop. In the catch block, log the error with context (such as the
current item being processed) but allow the loop to continue processing the
remaining items instead of crashing.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/utils/external-blog-posts.server.ts`:
- Around line 191-214: The externalUrl assignment uses feedItem.link directly
without validating the URL scheme, which is a security risk. Before the return
statement that creates the post object (after the getExternalPostSlug call), add
validation to ensure feedItem.link uses a safe scheme (http: or https:). If the
URL does not match these schemes, return an empty array to drop the invalid
item. This validation should be done by checking the URL scheme before passing
feedItem.link to addSearchParams.

---

Nitpick comments:
In `@scripts/scrape-tkdodo-blog-images.ts`:
- Around line 277-283: The loop iterating over items does not handle errors from
the scrapePostImage function call, causing any network or parser error to abort
the entire batch. Wrap the scrapePostImage function call and the entry push
logic inside a try/catch block within the for loop. In the catch block, log the
error with context (such as the current item being processed) but allow the loop
to continue processing the remaining items instead of crashing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 281cd017-bfee-4b7e-9642-eea304dee620

📥 Commits

Reviewing files that changed from the base of the PR and between e4cc876 and e54fcc0.

⛔ Files ignored due to path filters (36)
  • public/blog-assets/tkdodosblog/automatic-query-invalidation-after-mutations.jpg is excluded by !**/*.jpg
  • public/blog-assets/tkdodosblog/breaking-react-querys-api-on-purpose.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/concurrent-optimistic-updates-in-react-query.jpg is excluded by !**/*.jpg
  • public/blog-assets/tkdodosblog/context-inheritance-in-tan-stack-router.jpg is excluded by !**/*.jpg
  • public/blog-assets/tkdodosblog/creating-query-abstractions.jpg is excluded by !**/*.jpg
  • public/blog-assets/tkdodosblog/effective-react-query-keys.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/how-infinite-queries-work.jpg is excluded by !**/*.jpg
  • public/blog-assets/tkdodosblog/inside-react-query.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/leveraging-the-query-function-context.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/mastering-mutations-in-react-query.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/offline-react-query.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/placeholder-and-initial-data-in-react-query.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/practical-react-query.jpg is excluded by !**/*.jpg
  • public/blog-assets/tkdodosblog/react-query-and-forms.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/react-query-and-react-context.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/react-query-and-type-script.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/react-query-api-design-lessons-learned.jpg is excluded by !**/*.jpg
  • public/blog-assets/tkdodosblog/react-query-as-a-state-manager.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/react-query-data-transformations.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/react-query-error-handling.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/react-query-fa-qs.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/react-query-meets-react-router.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/react-query-render-optimizations.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/react-query-selectors-supercharged.jpg is excluded by !**/*.jpg
  • public/blog-assets/tkdodosblog/react-query-the-bad-parts.jpg is excluded by !**/*.jpg
  • public/blog-assets/tkdodosblog/seeding-the-query-cache.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/status-checks-in-react-query.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/tan-stack-router-and-query.jpg is excluded by !**/*.jpg
  • public/blog-assets/tkdodosblog/testing-react-query.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/the-beauty-of-tan-stack-router.jpg is excluded by !**/*.jpg
  • public/blog-assets/tkdodosblog/the-query-options-api.jpg is excluded by !**/*.jpg
  • public/blog-assets/tkdodosblog/thinking-in-react-query.png is excluded by !**/*.png
  • public/blog-assets/tkdodosblog/type-safe-react-query.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/using-web-sockets-with-react-query.jpeg is excluded by !**/*.jpeg
  • public/blog-assets/tkdodosblog/why-you-want-react-query.jpg is excluded by !**/*.jpg
  • public/blog-assets/tkdodosblog/you-might-not-need-react-query.jpeg is excluded by !**/*.jpeg
📒 Files selected for processing (11)
  • public/blog-assets/tkdodosblog/tkdodosblog.webp
  • scripts/scrape-tkdodo-blog-images.ts
  • src/components/BlogCard.tsx
  • src/components/RecentPostsWidget.tsx
  • src/components/home/HomeSocialProofSection.tsx
  • src/routes/_library/$libraryId/$version.docs.blog.tsx
  • src/routes/blog.index.tsx
  • src/utils/blog.functions.ts
  • src/utils/blog.ts
  • src/utils/external-blog-post-images.generated.ts
  • src/utils/external-blog-posts.server.ts

Comment on lines +191 to +214
if (
!feedItem.title ||
!feedItem.link ||
!feedItem.published ||
!libraries.length
) {
return []
}

const slug = getExternalPostSlug(source, feedItem)

return [
{
slug,
title: feedItem.title,
published: feedItem.published,
excerpt: feedItem.excerpt,
headerImage: source.headerImages?.[slug] ?? source.defaultHeaderImage,
authors: normalizeBlogAuthors(source.authors),
library: libraries.join(','),
externalUrl: addSearchParams(
feedItem.link,
source.externalUrlSearchParams,
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Validate external feed URLs before assigning externalUrl.

Line 211 forwards feed-controlled links to UI href without scheme validation. Restrict to http:/https: (and optionally expected hosts) before returning a post; otherwise drop the item.

Suggested fix
+function toSafeExternalUrl(
+  url: string,
+  searchParams: Record<string, string> | undefined,
+) {
+  try {
+    const nextUrl = new URL(url)
+    if (nextUrl.protocol !== 'https:' && nextUrl.protocol !== 'http:') {
+      return undefined
+    }
+
+    for (const [key, value] of Object.entries(searchParams ?? {})) {
+      nextUrl.searchParams.set(key, value)
+    }
+
+    return nextUrl.toString()
+  } catch {
+    return undefined
+  }
+}
+
 function parseRssFeed(
   source: ExternalBlogSource,
   feed: string,
 ): Array<BlogCardPost> {
@@
-      return [
+      const externalUrl = toSafeExternalUrl(
+        feedItem.link,
+        source.externalUrlSearchParams,
+      )
+
+      if (!externalUrl) {
+        return []
+      }
+
+      return [
         {
@@
-          externalUrl: addSearchParams(
-            feedItem.link,
-            source.externalUrlSearchParams,
-          ),
+          externalUrl,
           source: source.name,
         },
       ]
📝 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
if (
!feedItem.title ||
!feedItem.link ||
!feedItem.published ||
!libraries.length
) {
return []
}
const slug = getExternalPostSlug(source, feedItem)
return [
{
slug,
title: feedItem.title,
published: feedItem.published,
excerpt: feedItem.excerpt,
headerImage: source.headerImages?.[slug] ?? source.defaultHeaderImage,
authors: normalizeBlogAuthors(source.authors),
library: libraries.join(','),
externalUrl: addSearchParams(
feedItem.link,
source.externalUrlSearchParams,
),
function toSafeExternalUrl(
url: string,
searchParams: Record<string, string> | undefined,
) {
try {
const nextUrl = new URL(url)
if (nextUrl.protocol !== 'https:' && nextUrl.protocol !== 'http:') {
return undefined
}
for (const [key, value] of Object.entries(searchParams ?? {})) {
nextUrl.searchParams.set(key, value)
}
return nextUrl.toString()
} catch {
return undefined
}
}
if (
!feedItem.title ||
!feedItem.link ||
!feedItem.published ||
!libraries.length
) {
return []
}
const slug = getExternalPostSlug(source, feedItem)
const externalUrl = toSafeExternalUrl(
feedItem.link,
source.externalUrlSearchParams,
)
if (!externalUrl) {
return []
}
return [
{
slug,
title: feedItem.title,
published: feedItem.published,
excerpt: feedItem.excerpt,
headerImage: source.headerImages?.[slug] ?? source.defaultHeaderImage,
authors: normalizeBlogAuthors(source.authors),
library: libraries.join(','),
externalUrl,
source: source.name,
},
]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/utils/external-blog-posts.server.ts` around lines 191 - 214, The
externalUrl assignment uses feedItem.link directly without validating the URL
scheme, which is a security risk. Before the return statement that creates the
post object (after the getExternalPostSlug call), add validation to ensure
feedItem.link uses a safe scheme (http: or https:). If the URL does not match
these schemes, return an empty array to drop the invalid item. This validation
should be done by checking the URL scheme before passing feedItem.link to
addSearchParams.

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