From f5790837cf4c75c344c1e7dee49b84531ec0b481 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 6 Feb 2025 14:22:09 +0100 Subject: [PATCH] docs/frontend-system: add docs for multiple parents Signed-off-by: Patrik Oldsberg --- .../architecture/20-extensions.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/frontend-system/architecture/20-extensions.md b/docs/frontend-system/architecture/20-extensions.md index 02f4ba9d05..eae0405bda 100644 --- a/docs/frontend-system/architecture/20-extensions.md +++ b/docs/frontend-system/architecture/20-extensions.md @@ -337,3 +337,21 @@ const routableExtension = createExtension({ }, }); ``` + +## Multiple attachment points + +For some cases it can be useful to attach extensions to multiple parents. An example of this are Scaffolder field extensions or TechDocs addons that are consumed by multiple extensions. Specifying multiple attachments is done by providing an array of attachment points to the `attachTo` property of the extension. Keep in mind that this increases the complexity of your extension tree and should only be done when necessary. The following example shows how to attach our example extension to multiple parents: + +```tsx +const extension = createExtension({ + name: 'my-extension', + attachTo: [ + { id: 'my-first-parent', input: 'content' }, + { id: 'my-second-parent', input: 'children' }, // The input names do not need to match + ], + output: [coreExtensionData.reactElement], + factory() { + return [coreExtensionData.reactElement(
Hello World
)]; + }, +}); +```