-
Notifications
You must be signed in to change notification settings - Fork 4
fix(footer): sync catalog stats with templates.json #47
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ interface Stat { | |
| suffix?: string; | ||
| } | ||
|
|
||
| const STATS: Stat[] = [ | ||
| const DEFAULT_STATS: Stat[] = [ | ||
| { value: 5, label: 'Templates' }, | ||
| { value: 12, label: 'Extensions' }, | ||
| { value: 9, label: 'Categories' }, | ||
|
|
@@ -47,11 +47,26 @@ function Counter({ target, duration = 1200 }: { target: number; duration?: numbe | |
| return <span ref={ref}>{count}</span>; | ||
| } | ||
|
|
||
| export function StatsBar() { | ||
| export function StatsBar({ | ||
| templates, | ||
| extensions, | ||
| categories, | ||
| }: { | ||
| templates?: number; | ||
| extensions?: number; | ||
| categories?: number; | ||
| } = {}) { | ||
| const stats: Stat[] = [ | ||
| { value: templates ?? (DEFAULT_STATS[0].value as number), label: 'Templates' }, | ||
| { value: extensions ?? (DEFAULT_STATS[1].value as number), label: 'Extensions' }, | ||
| { value: categories ?? (DEFAULT_STATS[2].value as number), label: 'Categories' }, | ||
| { value: 'MIT', label: 'Licensed' }, | ||
| ]; | ||
|
Comment on lines
+50
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- repository conventions ---'
find /tmp/coderabbit-repo-knowledge/create-python-app-website-e4a52af8 -maxdepth 2 -type f -name '*.md' -print
printf '%s\n' '--- stats-bar.tsx ---'
cat -n src/components/stats-bar.tsx
printf '%s\n' '--- Counter definitions and usages ---'
rg -n -S 'function Counter|const Counter|<Counter|Counter\(' srcRepository: Create-Python-App/website Length of output: 3665 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- repository-wide review convention ---'
cat /tmp/coderabbit-repo-knowledge/create-python-app-website-e4a52af8/conventions/repo-wide.md
printf '%s\n' '--- StatsBar callers and refresh-related paths ---'
rg -n -S 'StatsBar|router\.refresh|refresh\(|revalidate|templates=|extensions=|categories=' --glob '!node_modules' --glob '!dist' --glob '!build' .Repository: Create-Python-App/website Length of output: 1224 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- page.tsx structure and relevant data flow ---'
ast-grep outline src/app/page.tsx
sed -n '1,105p' src/app/page.tsx
printf '%s\n' '--- data.ts ---'
cat -n src/lib/data.tsRepository: Create-Python-App/website Length of output: 6920 🌐 Web query:
💡 Result: According to official Next.js documentation, the router.refresh function is designed to refresh the current route by making a new request to the server, re-fetching data, and re-rendering React Server Components [1][2]. Crucially, the official behavior is that the client will merge the updated React Server Component (RSC) payload without losing unaffected client-side React state (such as useState) or browser state (such as scroll position) [1][2]. When router.refresh is called, the Router Cache is cleared, and the updated rendered result is reconciled on the client while preserving existing UI state [3]. However, developers have historically reported scenarios where client-side state appeared to be lost or components seemed to remount during this process [4][5]. The framework maintains that, by default, it should not remount components or reset state [1][3]. If you encounter unexpected state loss or remounting: 1. Reconciliation Details: Next.js uses React's reconciliation process to merge new RSC payloads with the existing component tree [3]. If the structure of the returned RSC payload changes significantly (e.g., changes to component keys or hierarchy), it can trigger a remount of child Client Components. 2. Component Keys: If your Client Components rely on props that are refreshed, ensuring they have stable, consistent keys is essential to prevent unnecessary unmounting/remounting. 3. Troubleshooting: If you are using router.refresh after a Server Action, ensure you are following the recommended patterns, as Server Actions themselves often automatically handle data updates and UI synchronization without needing an explicit refresh [6]. In summary, while the official documentation states that router.refresh preserves client-side state [1][2], it relies on React's reconciliation process to do so; deviations in expected behavior are typically tied to how the new server payload reconciles with the existing client-side component tree. Citations:
Reset When 🤖 Prompt for AI Agents |
||
|
|
||
| return ( | ||
| <div className="w-full border-y border-border/50 bg-muted/20"> | ||
| <div className="container flex flex-wrap items-center justify-center gap-x-10 gap-y-4 py-6 md:gap-x-16"> | ||
| {STATS.map((stat) => ( | ||
| {stats.map((stat) => ( | ||
| <div key={stat.label} className="flex flex-col items-center gap-0.5"> | ||
| <span className="font-display text-2xl font-bold text-foreground md:text-3xl"> | ||
| {typeof stat.value === 'number' ? <Counter target={stat.value} /> : stat.value} | ||
|
|
||
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.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: Create-Python-App/website
Length of output: 27966
🏁 Script executed:
Repository: Create-Python-App/website
Length of output: 8561
Bound the catalog fetch before awaiting it in the root layout.
RootLayoutawaitsgetTemplatesData()for every route.getTemplatesData()has no timeout, so a stalledtemplates.jsonrequest can keep the shared layout pending. Add a bounded timeout and preserve the fallback path.🤖 Prompt for AI Agents