@backstage/plugin-techdocs
Version:
The Backstage plugin that renders technical documentation for your components
40 lines (37 loc) • 1.51 kB
JavaScript
import { jsxs, jsx } from 'react/jsx-runtime';
import { getCompoundEntityRef, parseEntityRef } from '@backstage/catalog-model';
import { TECHDOCS_EXTERNAL_ANNOTATION } from '@backstage/plugin-techdocs-common';
import { getEntityRootTechDocsPath } from '@backstage/plugin-techdocs-react';
import { TechDocsReaderPage } from './plugin.esm.js';
import { TechDocsReaderPageContent } from './reader/components/TechDocsReaderPageContent/TechDocsReaderPageContent.esm.js';
import { TechDocsReaderPageSubheader } from './reader/components/TechDocsReaderPageSubheader/TechDocsReaderPageSubheader.esm.js';
import { useEntityPageTechDocsRedirect } from './search/hooks/useTechDocsLocation.esm.js';
const EntityPageDocs = ({
entity,
withSearch = true
}) => {
let entityRef = getCompoundEntityRef(entity);
const searchResultUrlMapper = useEntityPageTechDocsRedirect(entityRef);
if (entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION]) {
try {
entityRef = parseEntityRef(
entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION]
);
} catch {
}
}
const defaultPath = getEntityRootTechDocsPath(entity);
return /* @__PURE__ */ jsxs(TechDocsReaderPage, { entityRef, children: [
/* @__PURE__ */ jsx(TechDocsReaderPageSubheader, {}),
/* @__PURE__ */ jsx(
TechDocsReaderPageContent,
{
withSearch,
searchResultUrlMapper,
defaultPath
}
)
] });
};
export { EntityPageDocs };
//# sourceMappingURL=EntityPageDocs.esm.js.map