sentryDocumentTitle.tsx 782 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 (
  25. <DocumentTitle title={`${docTitle} - Sentry`}>
  26. {children as React.ReactChild}
  27. </DocumentTitle>
  28. );
  29. }
  30. export default SentryDocumentTitle;