UNPKG

@backstage/plugin-techdocs

Version:

The Backstage plugin that renders technical documentation for your components

38 lines (35 loc) 1.39 kB
import { jsx } from 'react/jsx-runtime'; import { useEffect } from 'react'; import { useApi, configApiRef, useAnalytics } from '@backstage/core-plugin-api'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; import { ErrorPage } from '@backstage/core-components'; import { useTechDocsReaderPage } from '@backstage/plugin-techdocs-react'; import { useLocation } from 'react-router-dom'; import { techdocsTranslationRef } from '../../translation.esm.js'; const TechDocsNotFound = ({ errorMessage }) => { const techdocsBuilder = useApi(configApiRef).getOptionalString("techdocs.builder"); const analyticsApi = useAnalytics(); const { entityRef } = useTechDocsReaderPage(); const location = useLocation(); const { t } = useTranslationRef(techdocsTranslationRef); useEffect(() => { const { pathname, search, hash } = location; analyticsApi.captureEvent("not-found", `${pathname}${search}${hash}`, { attributes: entityRef }); }, [analyticsApi, entityRef, location]); let additionalInfo = ""; if (![void 0, "local"].includes(techdocsBuilder)) { additionalInfo = t("notFound.builderNote"); } return /* @__PURE__ */ jsx( ErrorPage, { status: "404", statusMessage: errorMessage || t("notFound.title"), additionalInfo } ); }; export { TechDocsNotFound }; //# sourceMappingURL=TechDocsNotFound.esm.js.map