feat: Configurable site content — hero, stats, about text editable from admin - #6
Open
jerry-shimizutech wants to merge 1 commit into
Open
feat: Configurable site content — hero, stats, about text editable from admin#6jerry-shimizutech wants to merge 1 commit into
jerry-shimizutech wants to merge 1 commit into
Conversation
…ge support - New SiteContent model with key-value pairs for flexible content management - Public API: GET /api/v1/site-contents returns all content as key→translations map - Admin API: CRUD endpoints at /api/v1/admin/site-contents (staff-only) - useSiteContent hook with module-level caching and language-aware t() helper - HomePage updated: hero badge, subtitle, title, stats, featured section all from API - Graceful fallback to i18n hardcoded values while API loads - Content Admin page: grouped by section, inline editing, 5 languages per entry - Seeded 29 content entries across hero, stats, featured, and about sections - npm run build passes with zero errors
Contributor
Author
|
@greptile review |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
| { value: t('stats.since'), label: t('stats.sinceLabel'), icon: Calendar }, | ||
| { value: sc('stat_competitors', t('stats.competitors')), label: sc('stat_competitors_label', t('stats.competitorsLabel')), icon: Users }, | ||
| { value: sc('stat_countries', t('stats.countries')), label: sc('stat_countries_label', t('stats.countriesLabel')), icon: Globe }, | ||
| { value: sc('stat_prize_pool', t('stats.prizePpool')), label: sc('stat_prize_pool_label', t('stats.prizePoolLabel')), icon: Trophy }, |
There was a problem hiding this comment.
typo: prizePpool should be prizePool (extra 'p')
Suggested change
| { value: sc('stat_prize_pool', t('stats.prizePpool')), label: sc('stat_prize_pool_label', t('stats.prizePoolLabel')), icon: Trophy }, | |
| { value: sc('stat_prize_pool', t('stats.prizePool')), label: sc('stat_prize_pool_label', t('stats.prizePoolLabel')), icon: Trophy }, |
Prompt To Fix With AI
This is a comment left during a code review.
Path: web/src/pages/HomePage.tsx
Line: 36:36
Comment:
typo: `prizePpool` should be `prizePool` (extra 'p')
```suggestion
{ value: sc('stat_prize_pool', t('stats.prizePool')), label: sc('stat_prize_pool_label', t('stats.prizePoolLabel')), icon: Trophy },
```
How can I resolve this? If you propose a fix, please make it concise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New SiteContent model with multi-language support. All homepage text now configurable from admin.
Backend
GET /api/v1/site-contentsreturns flat key→translations map (single request)/api/v1/admin/site-contentsbehindrequire_staff!Frontend
useSiteContenthook — module-level cache, language-awaret(key, fallback)helperArchitecture
npm run buildpasses with zero errorsGreptile Overview
Greptile Summary
Adds a flexible SiteContent model for managing multi-language page content across the site. The implementation cleanly separates page content (hero text, stats, about paragraphs) from UI chrome (buttons, nav labels), allowing non-technical staff to update homepage and about page text without code changes.
Key changes:
require_staff!, 29 seeded entriesuseSiteContenthook with module-level caching, graceful fallbacks to i18n hardcoded values during load, admin UI with section grouping and inline editingIssue found:
HomePage.tsx:36—prizePpoolshould beprizePool(causes fallback to hardcoded i18n value)Confidence Score: 4/5
web/src/pages/HomePage.tsx:36before mergingImportant Files Changed
Sequence Diagram
sequenceDiagram participant User participant Browser participant HomePage participant useSiteContent participant API participant Rails participant DB Note over User,DB: Public Content Fetch Flow User->>Browser: Visit homepage Browser->>HomePage: Render HomePage->>useSiteContent: useSiteContent() alt Cache exists useSiteContent-->>HomePage: Return cached content else No cache useSiteContent->>API: GET /api/v1/site-contents API->>Rails: SiteContentsController#index Rails->>DB: SiteContent.all.order() DB-->>Rails: Return all entries Rails->>Rails: Build flat key→translations map Rails-->>API: JSON {key: {en, ja, ko, tl, zh}} API-->>useSiteContent: SiteContentMap useSiteContent->>useSiteContent: Cache result useSiteContent-->>HomePage: Return content end HomePage->>HomePage: Render with t(key, fallback) HomePage-->>Browser: Display content Browser-->>User: Show page Note over User,DB: Admin Edit Flow User->>Browser: Navigate to /admin/content Browser->>ContentAdmin: Render (requires staff auth) ContentAdmin->>API: GET /api/v1/admin/site-contents API->>Rails: Admin::SiteContentsController#index Rails->>DB: SiteContent.all (grouped by section) DB-->>Rails: Return entries Rails-->>API: JSON {site_contents: {section: [entries]}} API-->>ContentAdmin: Grouped entries ContentAdmin-->>User: Show editable sections User->>ContentAdmin: Edit & save entry ContentAdmin->>API: PUT /api/v1/admin/site-contents/:id API->>Rails: Admin::SiteContentsController#update Rails->>DB: Update SiteContent DB-->>Rails: Success Rails-->>API: Updated entry API-->>ContentAdmin: Confirm save ContentAdmin->>useSiteContent: invalidateSiteContentCache() useSiteContent->>useSiteContent: Clear module cache ContentAdmin->>API: Refetch content ContentAdmin-->>User: Show updated dataLast reviewed commit: be39f75