Shared Content: reusable blocks centers can place on their own pages

Aperta
#1,350 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
next.js, typescript

Direzione di ricerca

Read ADR 022, docs/shared-content.md, docs/coding-guide.md, docs/revalidation.md, and ADR 005 first; also review src/utilities/clearLayoutRelationships.ts and the linked design issues #1152, #1344, and #1352. Resolve the listed design decisions before implementation, then follow the shared-content checklist and add the specified access and revalidation fan-out tests. Done means the acceptance criteria pass, including safe rendering for missing or unpublished references and preserved references when duplicating pages.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement ready-for-human

Part of #564 — Shared Content (Pages, Media, etc.). ADR 022 is the design; this is its second shared collection, after Shared Media.

What

A shared collection of reusable blocks, written by Shared Content Editors and readable by every center, plus a layout block that lets a center place one on its own Page or Home Page by reference. When an editor changes a reusable block, every center page using it updates.

We chose reusable blocks over whole shared pages. A center can take one section of shared content without taking the rest of the page, and a page built from reusable blocks already gives us what a shared page would.

This also covers page templates. Template pages on the template tenant (#1152 — Create a new template tenant) can be built from reusable blocks. "Duplicate Page For…" already keeps references to Shared Content when it copies a page (pointsOnlyAtSharedContent in src/utilities/clearLayoutRelationships.ts), so a new center's copied pages keep pointing at the shared sections and stay current.

First content: the national pages Andy listed in #564 (How to Use the Forecast, Avalanche Problems, Danger Scale, Basic Avalanche Safety, Seguridad de Avalanchas Básica, Grief and Loss).

Decisions to make before building

  • What one document holds. Either a single layout block, or a small blocks array that forms a section. A section makes templates easier to build, because a template is then a few reusable blocks rather than many.
  • Which blocks are allowed inside. ADR 022 decision 4 says a shared document never contains a part one center owns. So blocks that point at tenant-scoped collections (Team, Sponsors, Document, Gallery, event and blog lists, forms, and center Media) can't be used inside a reusable block. Image slots must use the Shared library, so this depends on #1344 (Shared Content: offer the Shared library on ImageText, LinkPreview, ImageLinkGrid and other image slots) for any image block other than Media.
  • Nesting. A reusable block inside a reusable block hits the known gap in findDocumentsWithReferences: a referencing document with no tenant stops the revalidation walk (see docs/revalidation.md). Either disallow nesting, or fix the gap first.
  • Layout only, or also inside rich text. A layout block covers pages. A Lexical variant would let one appear inside a Post, but it would be stored as JSON, where ON DELETE set null doesn't reach (see #1249).
  • Drafts. Whether the collection has drafts, and that center pages render only the published version.
  • A Center / Shared choice from day one. If centers get reusable blocks of their own (#1352 — Center reusable blocks: a center's own blocks, reusable across its pages), ADR 022 decision 5 puts both behind one block with a "Center library / Shared library" choice, as Media does. Settle this before building. Adding the choice later means a missing source value would have to mean shared for this block, the opposite of image slots, or else existing blocks need a backfill.

Acceptance criteria

  • The collection follows every applicable step of docs/shared-content.md: no tenant field, accessBySharedContent, the Shared Content admin group and admin.hidden, a revalidation hook, SHARED_CONTENT_COLLECTIONS, seed data, Suggest an Edit, the reference count, and the "Where this is used" panel.
  • A layout block (named per docs/coding-guide.md) references one document and is available on Pages and Home Pages, following ADR 005.
  • The block renders nothing, rather than crashing, when the referenced document is missing or unpublished.
  • Publishing a change to a reusable block revalidates every center page that uses it.
  • Duplicating a page that uses a reusable block to another center keeps the reference.
  • Server tests cover access (the ADR 022 matrix), and a test proves the revalidation fan-out.

Out of scope

  • Whole shared pages, and a "replace page with…" action.
  • Center-specific sections inside a shared document (ADR 022 decision 4). A center adds its own content around the reusable block on its own page.
Lingua principale
TypeScript
Stelle
6
Fork
2
Merge medio
1g 11h
PR unite (30g)
35

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NWACus/web

Tutte le issue di NWACus/web

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.