Generic `/tools/widgets/{name}` namespace for link-driven blocks
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
- Da chiarire
- Stato di attività
- Tranquilla
- Stack tecnologico
- javascript
Direzione di ricerca
Inizia leggendo linkBlocks e decorateLinks in scripts.js, quindi esamina come il blocco dell’intestazione trova /tools/widgets/scheme, /language e /toggle. Risolvi la collisione dello namespace, il contratto dei parametri del widget e se sia necessario un dispatcher prima di definire l’ambito dell’implementazione. Il lavoro è completato quando lo namespace e il comportamento della migrazione sono stati decisi e documentati nel codice o nella documentazione del progetto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
linkBlocks in scripts.js is a registry, and registries in config files grow:
const linkBlocks = [
{ fragment: '/fragments/' },
{ schedule: '/schedules/' },
{ youtube: 'https://www.youtube' },
];
Every new link-driven experience means another bespoke top-level path and another entry. The
naming is ad hoc (/schedules/ vs /fragments/), and nothing signals to an author that these
are the same kind of thing.
Proposal
A generic /tools/widgets/{name} namespace, with query params for configuration:
/tools/widgets/mortgage-calculator
/tools/widgets/article-list?filter=category|tech&limit=6&sort=publishDate
Authors get one predictable prefix; the config stops growing per widget.
Namespace vs. dispatcher
These are separable decisions, and the second may not be worth it.
If the block name is simply the last path segment, /tools/widgets/mortgage-calculator resolves
to blocks/mortgage-calculator/mortgage-calculator.js with no central module involved. One
config entry, no growth, no indirection. Params come free — the widget already receives the
anchor as el, so new URL(el.href).searchParams is available.
A blocks/widgets/widgets.js traffic cop that maps names to modules is the same registry
relocated: still a file to edit per widget, plus an extra module on the load path. It earns its
place only if widgets share real behavior (param coercion, a common failure mode, loading
states) — and that is a util each widget imports, not a wrapper each widget hides behind.
Two wrinkles
The header already occupies this namespace. /tools/widgets/scheme, /language and
/toggle are sentinels the header block finds via href*= after its fragment loads — they are
not widgets and are not auto-blocks today. Making the prefix a catch-all means decorateLinks
claims them first and tries to load blocks/toggle/toggle.js inside the header fragment. Either
they move to their own namespace, or they become genuine widgets and the header just styles
wherever they land. The latter is probably the better end state.
Not everything collapses into it. /fragments/ and /schedules/ are content-addressed —
the path says which content. Widgets are behavior-addressed. Folding schedules in costs
authors ?path=/schedules/foo, which is worse than what they have. YouTube can't be a path at
all. Realistically the list lands at three-ish entries, one of them elastic.
Open questions
- Is
linkBlocksstill the right name? It describes the mechanism (a block made from a link)
rather than the intent.widgetsfits the new namespace but not/fragments/or YouTube, so
the rename may belong to the namespace rather than the config key. - Do header actions migrate into the widget namespace, or move out of it?
- Are widget params a documented contract (coercion, defaults, validation), or left to each
widget?
- Lingua principale
- JavaScript
- Stelle
- 12
- Fork
- 19
- Merge medio
- 7m
- PR unite (30g)
- 2
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di aemsites/author-kit
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
aemsites/author-kit#19 ·
Tutte le issue di aemsites/author-kit
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
tshemsedinov/reslop#158 ·
I maintainer di solito rispondono entro 1 giorno
-
level/task type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
wazuh/wazuh-documentation#10398 ·
I maintainer di solito rispondono entro 1 giorno
-
app_installations reports an error on every repo or suborg change when the plugin is not configuredAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
github-community-projects/safe-settings#1111 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno