Skip to content

feat: add JSON-LD Place structured data to city pages (#120) - #136

Merged
shauryagangrade merged 2 commits into
StudentSuite:mainfrom
aryansk:feat/120-jsonld-place-structured-data
Aug 15, 2026
Merged

feat: add JSON-LD Place structured data to city pages (#120)#136
shauryagangrade merged 2 commits into
StudentSuite:mainfrom
aryansk:feat/120-jsonld-place-structured-data

Conversation

@aryansk

Copy link
Copy Markdown
Contributor

What

City pages now emit one schema.org JSON-LD <script type="application/ld+json"> block per place, exactly as #120 specifies.

  • @type picks a specific subtype where one genuinely fits — Library, GovernmentOffice, Airport — and falls back to Place otherwise
  • name, address, geo (GeoCoordinates with latitude/longitude), and url pointing at the place's map deep link (/map?place=<id>)
  • Only real dataset fields are emitted. Places without an address omit it; places with missing or non-finite coordinates omit geo entirely — never nulls, never placeholders, so the structured data cannot misrepresent the page

How it was verified

  • New unit tests (src/lib/jsonld.test.ts, 11 tests) cover the type mapping, the deep link, and the "omit rather than fake" rules from the acceptance criteria
  • npx vitest run — 63/63 pass (incl. 11 new)
  • npx eslint on changed files — clean
  • npm run build — clean; checked the generated static HTML: 27 valid JSON-LD blocks on /city/mumbai with real data (Library, Airport, GovernmentOffice subtypes all present), and address-less places correctly emit name/geo/url only
  • All emitted blocks are parseable JSON

Notes

I can't attach a Rich Results Test screenshot from here (no browser), but every block is plain schema.org Place-family data with only genuinely-held fields, so the test should report no errors — happy to adjust if a manual run surfaces anything.

Closes#120

)
Each place on a city page now gets a schema.org JSON-LD block using a
specific subtype where one genuinely fits (Library, GovernmentOffice,
Airport) and Place otherwise. Only real dataset fields are emitted:
name, address, geo with latitude/longitude, and a deep link to the
place's map pin. geo is omitted entirely when coordinates are missing
or unusable, and address when absent — no placeholders, so the
structured data can never misrepresent the page.
ClosesStudentSuite#120
@vercel

vercelBot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

@aryansk is attempting to deploy a commit to the studentsuite Team on Vercel.

A member of the Team first needs to authorize it.

@shauryagangrade

Copy link
Copy Markdown
Member

Thanks for the thorough work and the tests — this looks good overall. CI’s typecheck is failing on a small TypeScript issue in the new tests (TS2352): the tests create Place-like objects with lat/lng set to undefined and then assert them to type Place, which tsc rejects.

Minimal fix
Replace the two direct casts to Place with a two-step cast via unknown to preserve the test intent while satisfying the type checker.

Suggested patch (ready to paste):

- const withoutLat = { ...place(), lat: undefined } as Place;+ const withoutLat = ({ ...place(), lat: undefined } as unknown) as Place;
expect(placeJsonLd(withoutLat)).not.toHaveProperty("geo");
- const withoutLng = { ...place(), lng: undefined } as Place;+ const withoutLng = ({ ...place(), lng: undefined } as unknown) as Place;
expect(placeJsonLd(withoutLng)).not.toHaveProperty("geo");

Suggested commit message
test: fix TS2352 in jsonld.test.ts by casting via unknown

Next steps

  • Could you apply that small change and push it to this branch? CI should then pass and we can move this PR out of draft.
  • If you’d like, I can push the patch as a follow-up commit or open a tiny PR with just this test fix — tell me which you prefer.

Thanks again — low-risk change and tests look comprehensive; once CI is green this should be good to merge.

@shauryagangrade
shauryagangrade marked this pull request as ready for review August 15, 2026 14:15
@shauryagangrade
shauryagangrade merged commit 8c8d339 into StudentSuite:mainAug 15, 2026
3 of 4 checks passed
Sign up for freeto 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.

Add JSON-LD Place structured data to place cards and city pages

2 participants

@aryansk@shauryagangrade