Use team name and favicon (when public branding enabled) on shared links
This commit is contained in:
@@ -1,35 +1,34 @@
|
||||
import { observer } from "mobx-react";
|
||||
import * as React from "react";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { cdnPath } from "@shared/utils/urls";
|
||||
import env from "~/env";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import { useTeamContext } from "./TeamContext";
|
||||
|
||||
type Props = {
|
||||
title: React.ReactNode;
|
||||
favicon?: string;
|
||||
};
|
||||
|
||||
const originalShortcutHref = document
|
||||
.querySelector('link[rel="shortcut icon"]')
|
||||
?.getAttribute("href") as string;
|
||||
|
||||
const PageTitle = ({ title, favicon }: Props) => {
|
||||
const { auth } = useStores();
|
||||
const { team } = auth;
|
||||
const team = useTeamContext() ?? auth.team;
|
||||
|
||||
return (
|
||||
<Helmet>
|
||||
<title>
|
||||
{team?.name ? `${title} - ${team.name}` : `${title} - ${env.APP_NAME}`}
|
||||
</title>
|
||||
{favicon ? (
|
||||
<link rel="shortcut icon" href={favicon} key={favicon} />
|
||||
) : (
|
||||
<link
|
||||
rel="shortcut icon"
|
||||
type="image/png"
|
||||
key="favicon"
|
||||
href={cdnPath("/images/favicon-32.png")}
|
||||
sizes="32x32"
|
||||
/>
|
||||
)}
|
||||
<link
|
||||
rel="shortcut icon"
|
||||
type="image/png"
|
||||
href={favicon ?? originalShortcutHref}
|
||||
key={favicon ?? originalShortcutHref}
|
||||
/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
</Helmet>
|
||||
);
|
||||
|
||||
@@ -8,7 +8,7 @@ import SearchPopover from "~/components/SearchPopover";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import history from "~/utils/history";
|
||||
import { homePath, sharedDocumentPath } from "~/utils/routeHelpers";
|
||||
import { IAvatar } from "../Avatar/Avatar";
|
||||
import { useTeamContext } from "../TeamContext";
|
||||
import TeamLogo from "../TeamLogo";
|
||||
import Sidebar from "./Sidebar";
|
||||
import HeaderButton from "./components/HeaderButton";
|
||||
@@ -16,12 +16,12 @@ import Section from "./components/Section";
|
||||
import DocumentLink from "./components/SharedDocumentLink";
|
||||
|
||||
type Props = {
|
||||
team?: IAvatar & { name: string };
|
||||
rootNode: NavigationNode;
|
||||
shareId: string;
|
||||
};
|
||||
|
||||
function SharedSidebar({ rootNode, team, shareId }: Props) {
|
||||
function SharedSidebar({ rootNode, shareId }: Props) {
|
||||
const team = useTeamContext();
|
||||
const { ui, documents, auth } = useStores();
|
||||
const { t } = useTranslation();
|
||||
|
||||
|
||||
11
app/components/TeamContext.ts
Normal file
11
app/components/TeamContext.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import * as React from "react";
|
||||
import { PublicTeam } from "@shared/types";
|
||||
import Team from "~/models/Team";
|
||||
|
||||
export const TeamContext = React.createContext<Team | PublicTeam | undefined>(
|
||||
undefined
|
||||
);
|
||||
|
||||
export function useTeamContext() {
|
||||
return React.useContext(TeamContext);
|
||||
}
|
||||
Reference in New Issue
Block a user