feat: add per-suburb editorial narrative paragraph - #165
Conversation
Turn each suburb's "charts + numbers" page into one with human-readable prose, so the page reads as original content rather than templated filler (adsense-plan §8.5.1). A framework-free buildNarrative() assembles up to three paragraphs from the suburb's real ABS data: the rented-share trend plus the Residency Shift Index, the community mix (overseas-born share, top origin, top non-English languages), and the university-qualified share vs the city benchmark (with crime for Melbourne suburbs only, never fabricated where it 404s). Verbs and framing switch on numeric bands so suburbs read differently, not just with the place name swapped. SuburbNarrative reuses the five hooks SuburbCard already calls, so it shares the TanStack cache and fires no extra network requests.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughChangesSuburb narrative
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant SuburbCard
participant SuburbNarrative
participant buildNarrative
SuburbCard->>SuburbNarrative: pass salCode
SuburbNarrative->>buildNarrative: pass suburb data responses
buildNarrative-->>SuburbNarrative: return paragraphs and sources
SuburbNarrative-->>SuburbCard: render narrative section
Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 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.
Pull request overview
Adds a data-driven “In brief” editorial narrative to each suburb card by generating prose from existing suburb data queries, aiming to improve human-readable content density (AdSense hardening) without backend/schema changes.
Changes:
- Introduces a framework-free
buildNarrative()generator that assembles up to three narrative paragraphs plus a source line from ABS/crime datasets. - Adds a new
SuburbNarrativeReact component that renders the narrative card and progressively fills content as existing queries resolve. - Mounts the narrative card into
SuburbCardbetween the Shift Index and Nearby sections.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| frontend/src/lib/narrative.ts | Implements narrative text generation from tenure/language/birth/education/crime inputs and emits paragraphs + source attribution. |
| frontend/src/components/SuburbNarrative.tsx | New UI component that calls the existing suburb hooks and renders the “In brief” prose card. |
| frontend/src/components/SuburbCard.tsx | Inserts SuburbNarrative into the suburb card layout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const source = | ||
| `Source: ABS Census 2021 (TSP), SA2 “${tenure.sa2Name}”.` + | ||
| (crime?.periods?.length ? ' Crime: Victoria Crime Statistics Agency.' : '') |
What
A data-driven editorial paragraph on every suburb card (adsense-plan §8.5.1). Pure frontend — no backend, schema, or data change.
buildNarrative()(src/lib/narrative.ts) assembles up to three paragraphs from the suburb's own ABS data:SuburbNarrativecomponent renders it as an "In brief" card, mounted inSuburbCardbetween the Shift Index and Nearby sections.Why
The most important AdSense content-hardening step: turn each "charts + numbers" page into one with human-readable prose so it reads as genuine content, not scaled/templated filler — the strongest defence against a
Low value contentrejection. The text is rule-based, not LLM-generated (LLM bulk-generation would itself look like scaled-content abuse); each paragraph's value comes from that suburb's unique real data. Anti-template guard (§8.5.7): verbs and framing switch on numeric bands, so suburbs read differently rather than swapping only the place name.Two deliberate design points:
SuburbNarrativereuses the five hooksSuburbCardalready calls, sharing the TanStack cache; paragraphs fill in progressively as each query settles.buildNarrativeis kept React-free so the pending prerender-body tier (§8.5.6 step 7) can reuse the exact same logic.How to test
cd frontend && npx tsc --noEmit— passes clean.npm run dev, open a Melbourne suburb (e.g. via search) — the "In brief" card shows three paragraphs including a crime sentence, ending with aSource: ABS Census 2021 (TSP), SA2 "…". Crime: Victoria Crime Statistics Agency.line.Summary by CodeRabbit