diff --git a/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.tsx b/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.tsx index e307564f9c..0e9b244d74 100644 --- a/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.tsx @@ -35,6 +35,82 @@ import { useRouteRefParams, } from '@backstage/core-plugin-api'; +/* An explanation for the multiple ways of customizing the TechDocs reader page + +Please refer to this page on the microsite for the latest recommended approach: +https://backstage.io/docs/features/techdocs/how-to-guides#how-to-customize-the-techdocs-reader-page + +The component is responsible for rendering the and +its contained version of a , which in turn renders the . + +Historically, there have been different approaches on how this can be customized, and how the + inside could be exchanged for a custom implementation (which was not +possible before). Also, the current implementation supports every scenario to avoid breaking default +configurations of TechDocs. + +In particular, there are 4 different TechDocs page configurations: + +CONFIGURATION 1: only, no children + +} > + +This is the simplest way to use TechDocs. Only a full page is passed, assuming that it comes with +its content inside. Since we allowed customizing it, we started providing as +a default implementation (which contains ). + +CONFIGURATION 2 (not advised): with element children + + + {techdocsPage} + + } +/> + +Previously, there were two ways of passing children to : either as elements (as +shown above), or as a render function (described below in CONFIGURATION 3). The "techdocsPage" is +located in packages/app/src/components/techdocs and is the default implementation of the content +inside. + +CONFIGURATION 3 (not advised): with render function as child + + + {({ metadata, entityMetadata, onReady }) => ( + techdocsPage + )} + + } +/> + +Similar to CONFIGURATION 2, the direct children will be passed to the but in +this case interpreted as render prop. + +CONFIGURATION 4: and provided content in + +} +> + {techDocsPage} + + + + + + + +This is the current state in packages/app/src/App.tsx and moved the location of children from inside +the element prop in the to the children of the . Then, in they +are retrieved using the useOutlet hook from React Router. + +NOTE: Render functions are no longer supported in this approach. +*/ + /** * Props for {@link TechDocsReaderLayout} * @public @@ -96,6 +172,7 @@ export const TechDocsReaderPage = (props: TechDocsReaderPageProps) => { grandChild => !getComponentData(grandChild, TECHDOCS_ADDONS_WRAPPER_KEY), ); + // As explained above, "page" is configuration 4 and is 1 return ( {(page as JSX.Element) || } @@ -103,6 +180,7 @@ export const TechDocsReaderPage = (props: TechDocsReaderPageProps) => { ); } + // As explained above, a render function is configuration 3 and React element is 2 return ( {({ metadata, entityMetadata, onReady }) => (