Skip to content

feat(content-index): client-side filtering + MusicLibrary songs - #55

Merged
Ardnived merged 17 commits into
mainfrom
feat/content-index-filtering
Jul 1, 2026
Merged

Ardnived merged 17 commits into
mainfrom
feat/content-index-filtering

Conversation

@Ardnived

@Ardnived Ardnived commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Makes the content-index rich-text block interactive across all four content types: the list is resolved once server-side (SEO-friendly, KV-cached) and filtered client-side with multi-select pills.

  • pages / lectures → new ContentIndex organism (masonry card grid + filter pills derived from each item's tags).
  • songs → the existing MusicLibrary (playback + tag filtering); tracks resolve with playable audio + album art.
  • meditations → the block resolves to user-choice categories (a duration/mood picker); their referenced meditations are flattened into a deduped grid with the categories as filter pills.
  • Imageless cards get a branded (teal + white logo) fallback; empty/unresolved lists render nothing.

Changes

  • server/content-index.ts — per-type select/populate/depth; strip any CMS-baked depth before appending ours (duplicate depth params 400 the backend); resolveContentIndex now takes a transform(docs) so meditations can expand 1-category→many-cards; type folded into the cache key.
  • lib/cms-blocks.ts — contentIndexCard/contentIndexTrack mappers, meditationCardsFromUserChoices flatten+dedupe, page/lecture facet tags, filename-aware song image resolution.
  • components/organisms/ContentIndex/ — new organism; pills built on the Button atom (square/ghost).
  • components/organisms/RichText/blockConverters.tsx — dispatch content-index by type (songs → MusicLibrary; everything else → ContentIndex).
  • components/molecules/ContentCard / ContentGrid — branded imageless fallback; keep column width independent of item count.
  • lib/cms-routes.ts — enable the lectures outbound route builder (/lectures/:id).

Test Results

  • Lint: ✓ No errors (pnpm lint)
  • Types: ✓ Clean (pnpm exec tsc --noEmit)
  • Tests: ✓ 338 passed (pnpm test:run)
  • Build: ✓ Success (pnpm build)

Manual verification

  1. /inspiration (pages) — toggle filter pills; single-item filter keeps card width consistent.
  2. /music-for-meditation (songs) — MusicLibrary renders all tracks with playable audio; tag filters work.
  3. /meditate-now (meditations) — grid of meditation cards with "5 min / 5-10 min / 10-15 min" category pills; play buttons link to /meditations/:id.
  4. Ladle → Organisms → Content Index — all / filtered / empty states.

Notes for reviewer

  • CMS data-quality: meditation cards show the internal label ("Feel harmony-10 min-Neelam") because the meditations' public title is null upstream. Not a code bug — clean titles appear once the CMS populates title.
  • Songs upload gotcha: a Song's url/thumbnailURL are Payload afterRead virtuals derived from filename, so the query must select[filename] (and populate[images][filename]) or they return null and every track is dropped.
  • Lectures feed returns no userChoices, so lecture pills are dormant until feat(lectures): include per-lecture userChoices in the /for-audience feed SahajCloud#526 lands; WmWebConfig.audiences is currently empty, so the lectures path is inactive.
  • The duplicate-depth 400 on /meditate-now was pre-existing on main; fixed here.

Closes #54

🤖 Generated with Claude Code

Ardnived and others added 9 commits July 1, 2026 15:05
Pulls the current SahajCloud schema, which adds WmWebConfig.audiences
(the fixed audience set the public site passes to the lectures
/for-audience feed) and the custom-block definitions (ContentIndexBlock
with pageFilters/userChoiceFilters/songFilters), both consumed by the
content-index filtering work. Also carries unrelated upstream drift
(atlas-manager role, Region.slug, Client field renames).

Refs #54

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Asserts all 10 pages.content block types resolve to a converter
function, and that no stale converter keys linger. A future CMS block
addition now fails a test instead of silently hitting RichText's
`unknown` fallback.

Refs #54

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The /lectures/:id route (pages/lectures/[id]/(full)/) already exists and
matchDocumentRoute already matches it — only the outbound cmsHref builder
was stubbed to null. Build /lectures/:id from a document id, mirroring
the meditations builder. Also lights up lecture cards in the showcase
block (intended).

Refs #54

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Extend the content-index data model for interactive filtering:

- ContentIndexBlockFields gains pageFilters/userChoiceFilters/songFilters
  (CMS schema mirror) and a resolvedTracks field for the songs type.
- ResolvedCardItem gains `tags` (facets: page-tag enum labels, or lecture
  user-choice titles) used by client-side filter pills.
- contentIndexCard now routes lectures to /lectures/:id and attaches
  page/lecture facets; PAGE_TAG_LABELS maps the page-tag enum to labels.
- New contentIndexTrack maps a Song doc to an AudioPlayer Track (album
  credit/artwork, songTag slugs; duration 0 — no CMS field).

Also updates the showcase test: lectures now resolve to cards.

Refs #54

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Server-side resolution for the interactive content-index:

- Widen per-type queries (QUERY_BY_TYPE): pages gain `tags`; songs gain
  url/tags + album (artist/artwork) and song-tag populate at depth 2;
  lectures pass the site's audiences to /for-audience.
- Branch the resolve: songs → resolvedTracks (MusicLibrary), all other
  types → resolvedItems (card grid). Shared fetchContentIndexDocs handles
  the query build + graceful degrade.
- ResolveOptions.audiences threads WmWebConfig.audiences from both +data
  sites; lectures with no audiences short-circuit to empty (the feed 400s
  on an empty param). Audience ids fold into the cache key.
- WEB_CONFIG_SELECT selects `audiences`.

Verified against the live CMS: pages/songs return the expected populated
shapes; the /for-audience feed returns a fixed player projection with a
`thumbnailUrl` string (no `thumbnail` relationship) — so contentIndexCard
falls back to `thumbnailUrl` for the lecture card image. That feed omits
per-lecture userChoices, so lecture filter pills are gated on an upstream
SahajCloud field (follow-up); cards + /lectures/:id links work today.

Refs #54

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
New organism for pages/lectures content-index blocks: a server-resolved
ContentGrid plus a multi-select filter pill row derived from the items'
own tags. SSR renders the full list (SEO-friendly); hydration wires the
pill toggles (pure useState, no ClientOnly).

- "All" pill clears the selection; facet pills toggle with OR semantics,
  aria-pressed, and >=44px touch targets (mobile-first).
- No pill row when no facets are present (degrades to a plain grid — the
  current lecture-feed state).
- tags are stripped before ContentGrid (ContentCard forwards unknown
  props to the DOM).
- deriveFacets / filterByFacets exported as pure helpers for node-only
  unit tests; Ladle story covers pills / no-facets / empty.

Refs #54

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Replace the single static grid in the content-index converter with a
type switch:
  songs         → MusicLibrary (playback + its own tag filtering); filters
                  derived from the tracks' song-tag slugs, each with a
                  music glyph (SongTag has no icon).
  pages/lectures → ContentIndex (filterable card grid with pills)
  meditations   → static card grid (client filtering deferred)
Empty / unresolved lists still render nothing.

Refs #54

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- content-index: fold the two near-identical resolvers into a generic
  resolveContentIndex(fields, options, mapper) helper.
- cms-blocks: extract the card href type-dispatch into a cardHref helper.
- ContentIndex: extract pillClassName; collapse the filter+strip into a
  single memo.

Refs #54

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Per code review: contentIndexTrack derived the track thumbnail only from
the album's artwork, so a song whose album has no artwork (or an
unpublished/bare-id album) lost its thumbnail even when the Song document
carries its own thumbnailURL. Select that field and fall back to it.

Refs #54

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
wemeditate-web eda27af Commit Preview URL

Branch Preview URL
Jul 01 2026, 08:22 PM

Ardnived and others added 5 commits July 1, 2026 17:16
Replace ContentIndex's hand-rolled pill buttons with the shared Button
atom (shape="square", primary when active / ghost when inactive), via a
small internal Pill wrapper. Keeps the >=44px touch target with min-h-11
since Button's `sm` size alone doesn't guarantee it.

Refs #54

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
fadeInOnLoad held the whole card at opacity-0 until the thumbnail's
onLoad fired — but a card with an empty thumbnailSrc renders a
placeholder, not an <img>, so onLoad never fired and the card stayed
invisible forever. This surfaced in the content-index grids (ContentGrid
forces fadeInOnLoad), where pages/lectures often have no image.

Start imageLoaded=true when there's no image src to wait for, and also
reveal the card on img onError (broken URL). Adds ContentCard tests.

Refs #54

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Instead of a blank card when a CMS thumbnail is missing, render a
non-animated teal Placeholder with a centered white Logo in a fixed 16:9
box, so imageless cards read consistently in the grid. Complements the
fadeInOnLoad visibility fix.

Refs #54

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The Masonry container was a shrink-to-fit flex child (flex justify-center
wrapper + max-w-full), so react-masonry-css's 100%/columns widths
collapsed to the cards' min-content — filtering to one item (or a short
title) shrank the whole grid and its cards (measured: a card dropping
from 264px to 47px). Make the wrapper a plain block and the Masonry
w-full so columns stay a consistent fraction of the available width
regardless of how many items are shown.

Refs #54

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Render the pages/lectures content-index (ContentIndex) with the same
full-bleed + Container maxWidth="xl" (6xl) treatment as ContentTextBox,
so the filterable grid breaks out of the narrow prose column and has more
room (measured: grid 864px -> 1120px, cards 264px -> 349px). The
full-bleed wrapper owns the vertical spacing, so ContentIndex no longer
needs BLOCK_SPACING.

Refs #54

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Deploying wemeditate-design with  Cloudflare Pages  Cloudflare Pages

Latest commit: eda27af
Status: ✅  Deploy successful!
Preview URL: https://b7e5db33.wm-design.pages.dev
Branch Preview URL: https://feat-content-index-filtering.wm-design.pages.dev

View logs

Ardnived and others added 3 commits July 1, 2026 19:17
The songs content-index rendered an empty MusicLibrary: a Song is an
upload, and its `url`/`thumbnailURL` are virtual fields the upload
afterRead hook derives from `filename`. Without `select[filename]` the
CMS returns them null, so `contentIndexTrack` dropped every track
(url-less). Same for related image uploads — `populate[images][filename]`
lets the album artwork's url compute (a url-only populate returns null).

Verified against the live CMS: /music-for-meditation now resolves all 27
tracks with playable audio + album cover art.

Refs #54

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
A `type: meditations` block resolves to user-choice *categories* (a
duration/mood picker), not meditation docs — so it 400'd and rendered
nothing. Two fixes:

- Strip any `depth` the CMS bakes into the computed endpoint before
  appending ours. Duplicate `depth` params parse to an array and the
  backend 400s ("populate required when depth > 1"). Pre-existing on main.
- Widen the meditations query to select each category's four time-of-day
  meditation slots (depth 2, populating meditation title/thumbnail/
  duration + image filename), then flatten via meditationCardsFromUser
  Choices: merge the referenced meditations into a deduped card grid and
  tag each with the user-choice(s) that reference it.

The meditations branch now feeds the same ContentIndex organism as
pages/lectures, with the user-choices as filter pills. Verified against
the live CMS: /meditate-now renders 9 meditation cards with 5 min /
5-10 min / 10-15 min pills.

Refs #54

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
From the /finalize-pr code-review pass:
- Omit a meditation card's duration badge when it rounds to under a
  minute (sub-minute `duration`, or an explicit `durationMinutes` of 0) —
  a "0 min" badge is meaningless.
- Fold the block `type` into the content-index cache key so two blocks
  that share an endpoint+locale can't collide and return the wrong shape
  from cache (a songs Track[] vs a card list).

Refs #54

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@Ardnived
Ardnived merged commit 857bab2 into main Jul 1, 2026
5 checks passed
@Ardnived
Ardnived deleted the feat/content-index-filtering branch July 1, 2026 20:47
Sign up for free to 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.

feat(content-index): client-side filtering + MusicLibrary songs

1 participant