github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/webapp/javascript/components/PageTitle.tsx (about)

     1  import React, { useContext } from 'react';
     2  import { Helmet } from 'react-helmet';
     3  
     4  const defaultAppName = 'Pyroscope';
     5  export const AppNameContext = React.createContext(defaultAppName);
     6  
     7  function getFullTitle(title: string, appName: string) {
     8    const finalAppName = appName || defaultAppName;
     9  
    10    return `${title} | ${finalAppName}`;
    11  }
    12  
    13  interface PageTitleProps {
    14    /** Title of the page */
    15    title: string;
    16  }
    17  
    18  /**
    19   * PageTitleWithAppName will add a page name suffix from the context
    20   */
    21  export default function PageTitleWithAppName({ title }: PageTitleProps) {
    22    const appName = useContext(AppNameContext);
    23    const fullTitle = getFullTitle(title, appName);
    24  
    25    return (
    26      <Helmet>
    27        <title>{fullTitle}</title>
    28      </Helmet>
    29    );
    30  }