@backstage/plugin-techdocs
Version:
The Backstage plugin that renders technical documentation for your components
35 lines (32 loc) • 1.51 kB
JavaScript
import { jsx } from 'react/jsx-runtime';
import { useEffect } from 'react';
import { useApi, configApiRef, useAnalytics } from '@backstage/core-plugin-api';
import { ErrorPage } from '@backstage/core-components';
import { useTechDocsReaderPage } from '@backstage/plugin-techdocs-react';
import { useLocation } from 'react-router-dom';
const TechDocsNotFound = ({ errorMessage }) => {
const techdocsBuilder = useApi(configApiRef).getOptionalString("techdocs.builder");
const analyticsApi = useAnalytics();
const { entityRef } = useTechDocsReaderPage();
const location = useLocation();
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 = "Note that techdocs.builder is not set to 'local' in your config, which means this Backstage app will not generate docs if they are not found. Make sure the project's docs are generated and published by some external process (e.g. CI/CD pipeline). Or change techdocs.builder to 'local' to generate docs from this Backstage instance.";
}
return /* @__PURE__ */ jsx(
ErrorPage,
{
status: "404",
statusMessage: errorMessage || "Documentation not found",
additionalInfo
}
);
};
export { TechDocsNotFound };
//# sourceMappingURL=TechDocsNotFound.esm.js.map