sentryDocumentTitle.tsx 740 B

12345678910111213141516171819202122232425262728293031323334
  1. import React from 'react';
  2. import DocumentTitle from 'react-document-title';
  3. type Props = {
  4. // Main page title
  5. title: string;
  6. orgSlug?: string;
  7. projectSlug?: string;
  8. children?: React.ReactNode;
  9. };
  10. function SentryDocumentTitle({title, orgSlug, projectSlug, children}: Props) {
  11. function getDocTitle() {
  12. if (!orgSlug && !projectSlug) {
  13. return title;
  14. }
  15. if (orgSlug && projectSlug) {
  16. return `${title} - ${orgSlug} - ${projectSlug}`;
  17. }
  18. if (orgSlug) {
  19. return `${title} - ${orgSlug}`;
  20. }
  21. return `${title} - ${projectSlug}`;
  22. }
  23. const docTitle = getDocTitle();
  24. return <DocumentTitle title={`${docTitle} - Sentry`}>{children}</DocumentTitle>;
  25. }
  26. export default SentryDocumentTitle;