fix: update lastUpdated date handling and replace buttons with links …#2796
fix: update lastUpdated date handling and replace buttons with links …#2796adityaoberai merged 7 commits intomainfrom
Conversation
…in blog navigation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis PR changes the blog listing UI to import Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/routes/blog/`[[page]]/+page.svelte:
- Around line 329-348: The selectedCategory value is stale after client-side
anchor navigation; change the class:is-selected bindings on the "Latest" anchor
and the category anchors to derive selection from the reactive page URL (e.g.
use page.url.searchParams.get('category') or its fallback 'Latest') instead of
the local selectedCategory variable so the highlight updates on navigation, and
keep selectedCategory writable only for the "Clear search" handler by leaving
its write logic in place but not relying on it for the class bindings (update
references in the anchors that use class:is-selected and any code that reads
category selection).
In `@src/routes/blog/post/managing-website-assets-repo-cold-start/`+page.markdoc:
- Around line 5-7: Update the frontmatter keys in the post: change the date
value in the `date` (and `lastUpdated`) field from "2025-03-11" to "2026-03-11",
and replace the `cover` value from
"/images/blog/announcing-cname-flattening/cover.png" to the correct image path
"/images/blog/managing-website-assets-repo-cold-start/cover.png" so the post
uses the correct date and its dedicated cover image.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6983b480-a325-4a57-b086-4b51a8a5257a
📒 Files selected for processing (3)
src/routes/blog/[[page]]/+page.sveltesrc/routes/blog/content.tssrc/routes/blog/post/managing-website-assets-repo-cold-start/+page.markdoc
| <li class="flex items-center"> | ||
| <button | ||
| <a | ||
| href={base + '/blog'} | ||
| class="web-interactive-tag web-caption-400 cursor-pointer" | ||
| class:is-selected={selectedCategory === 'Latest'} | ||
| onclick={() => { | ||
| selectedCategory = 'Latest'; | ||
| handleSearch(); | ||
| }} | ||
| > | ||
| Latest | ||
| </button> | ||
| </a> | ||
| </li> | ||
|
|
||
| {#each categories as category (category.name)} | ||
| <li class="flex items-center"> | ||
| <button | ||
| <a | ||
| href={base + '/blog?category=' + encodeURIComponent(category.name)} | ||
| class="web-interactive-tag web-caption-400 cursor-pointer" | ||
| class:is-selected={selectedCategory === category.name} | ||
| onclick={() => { | ||
| selectedCategory = category.name; | ||
| handleSearch(); | ||
| }} | ||
| > | ||
| {category.name} | ||
| </button> | ||
| </a> | ||
| </li> |
There was a problem hiding this comment.
selectedCategory won't update after anchor-based navigation, breaking the visual highlight.
The selectedCategory state (line 43) is initialized once from URL params via $state. When users click these new anchor links, SvelteKit performs client-side navigation without re-running the component script—so selectedCategory remains stale while the URL changes. The is-selected class bindings on lines 333 and 344 will show the wrong category as selected.
Consider deriving the selected state directly from the reactive page.url:
🐛 Proposed fix
-let selectedCategory = $state(page.url.searchParams.get('category') ?? 'Latest');
+let selectedCategory = $derived(page.url.searchParams.get('category') ?? 'Latest');If selectedCategory must remain writable for the "Clear search" handler (line 412), use page.url.searchParams directly in the class bindings instead:
<a
href={base + '/blog'}
class="web-interactive-tag web-caption-400 cursor-pointer"
- class:is-selected={selectedCategory === 'Latest'}
+ class:is-selected={!page.url.searchParams.get('category')}
> <a
href={base + '/blog?category=' + encodeURIComponent(category.name)}
class="web-interactive-tag web-caption-400 cursor-pointer"
- class:is-selected={selectedCategory === category.name}
+ class:is-selected={page.url.searchParams.get('category') === category.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.
| <li class="flex items-center"> | |
| <button | |
| <a | |
| href={base + '/blog'} | |
| class="web-interactive-tag web-caption-400 cursor-pointer" | |
| class:is-selected={selectedCategory === 'Latest'} | |
| onclick={() => { | |
| selectedCategory = 'Latest'; | |
| handleSearch(); | |
| }} | |
| > | |
| Latest | |
| </button> | |
| </a> | |
| </li> | |
| {#each categories as category (category.name)} | |
| <li class="flex items-center"> | |
| <button | |
| <a | |
| href={base + '/blog?category=' + encodeURIComponent(category.name)} | |
| class="web-interactive-tag web-caption-400 cursor-pointer" | |
| class:is-selected={selectedCategory === category.name} | |
| onclick={() => { | |
| selectedCategory = category.name; | |
| handleSearch(); | |
| }} | |
| > | |
| {category.name} | |
| </button> | |
| </a> | |
| </li> | |
| <li class="flex items-center"> | |
| <a | |
| href={base + '/blog'} | |
| class="web-interactive-tag web-caption-400 cursor-pointer" | |
| class:is-selected={!page.url.searchParams.get('category')} | |
| > | |
| Latest | |
| </a> | |
| </li> | |
| {`#each` categories as category (category.name)} | |
| <li class="flex items-center"> | |
| <a | |
| href={base + '/blog?category=' + encodeURIComponent(category.name)} | |
| class="web-interactive-tag web-caption-400 cursor-pointer" | |
| class:is-selected={page.url.searchParams.get('category') === category.name} | |
| > | |
| {category.name} | |
| </a> | |
| </li> |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/routes/blog/`[[page]]/+page.svelte around lines 329 - 348, The
selectedCategory value is stale after client-side anchor navigation; change the
class:is-selected bindings on the "Latest" anchor and the category anchors to
derive selection from the reactive page URL (e.g. use
page.url.searchParams.get('category') or its fallback 'Latest') instead of the
local selectedCategory variable so the highlight updates on navigation, and keep
selectedCategory writable only for the "Clear search" handler by leaving its
write logic in place but not relying on it for the class bindings (update
references in the anchors that use class:is-selected and any code that reads
category selection).
src/routes/blog/post/managing-website-assets-repo-cold-start/+page.markdoc
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/routes/blog/post/managing-website-assets-repo-cold-start/`+page.markdoc:
- Line 4: The description and body contain hyphenated fragments where em dashes
or rewording are intended (examples: "bite-and", "others-especially", "repo-a",
"regions-for example", "not-and"); open the "+page.markdoc" content and replace
those broken compounds with proper punctuation or phrasing (use — em dashes or
commas/parentheses as appropriate) across the noted ranges (lines around 15, 19,
27, 35–37, 49, 62–70) so that phrases read naturally (e.g., "bite — and",
"others — especially", "repo a" -> "a repo", "regions, for example", "not, and"
or restructure the sentence) while preserving intended meaning and tone.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 24940723-5e0b-408a-ae8c-32bc3aaa16f4
⛔ Files ignored due to path filters (1)
static/images/blog/managing-website-assets-repo-cold-start/cover.pngis excluded by!**/*.png
📒 Files selected for processing (1)
src/routes/blog/post/managing-website-assets-repo-cold-start/+page.markdoc
src/routes/blog/post/managing-website-assets-repo-cold-start/+page.markdoc
Outdated
Show resolved
Hide resolved
adityaoberai
left a comment
There was a problem hiding this comment.
@eldadfux mostly all minor edits, there's one important point that needs more attention (around the point of setting a base URL in the environment)
src/routes/blog/post/managing-website-assets-repo-cold-start/+page.markdoc
Outdated
Show resolved
Hide resolved
src/routes/blog/post/managing-website-assets-repo-cold-start/+page.markdoc
Outdated
Show resolved
Hide resolved
src/routes/blog/post/managing-website-assets-repo-cold-start/+page.markdoc
Outdated
Show resolved
Hide resolved
src/routes/blog/post/managing-website-assets-repo-cold-start/+page.markdoc
Outdated
Show resolved
Hide resolved
src/routes/blog/post/managing-website-assets-repo-cold-start/+page.markdoc
Outdated
Show resolved
Hide resolved
src/routes/blog/post/managing-website-assets-repo-cold-start/+page.markdoc
Outdated
Show resolved
Hide resolved
src/routes/blog/post/managing-website-assets-repo-cold-start/+page.markdoc
Outdated
Show resolved
Hide resolved
src/routes/blog/post/managing-website-assets-repo-cold-start/+page.markdoc
Outdated
Show resolved
Hide resolved
src/routes/blog/post/managing-website-assets-repo-cold-start/+page.markdoc
Outdated
Show resolved
Hide resolved
|
Also, @eldadfux, we need to run the optimize and format scripts. Those tests are failing. |
Co-authored-by: Aditya Oberai <adityaoberai1@gmail.com>
Co-authored-by: Aditya Oberai <adityaoberai1@gmail.com>
New blog post
Summary by CodeRabbit
New Features
Bug Fixes