diff --git a/js/app/hooks/useTitle.tsx b/js/app/hooks/useTitle.tsx index 351437ad..47cb83a2 100644 --- a/js/app/hooks/useTitle.tsx +++ b/js/app/hooks/useTitle.tsx @@ -1,11 +1,13 @@ import { useNavigation } from "@react-navigation/native"; +import { useBrandingAsset } from "@streamplace/components"; import { useEffect } from "react"; export default function useTitle(user: string) { const navigation = useNavigation(); + const title = useBrandingAsset("siteTitle")?.data || "Streamplace"; useEffect(() => { navigation.setOptions({ - title: `@${user} on Streamplace`, + title: `@${user} on ${title}`, }); }, [user, navigation]); } diff --git a/js/app/src/router.tsx b/js/app/src/router.tsx index fd69069b..886d767b 100644 --- a/js/app/src/router.tsx +++ b/js/app/src/router.tsx @@ -15,7 +15,12 @@ import { useRoute, } from "@react-navigation/native"; import { createNativeStackNavigator } from "@react-navigation/native-stack"; -import { Text, useTheme, useToast } from "@streamplace/components"; +import { + Text, + useSiteTitle, + useTheme, + useToast, +} from "@streamplace/components"; import { Provider, Settings } from "components"; import AQLink from "components/aqlink"; import Login from "components/login/login"; @@ -395,6 +400,7 @@ export function StreamplaceDrawer() { const showLoginModal = useStore((state) => state.showLoginModal); const closeLoginModal = useStore((state) => state.closeLoginModal); const [livePopup, setLivePopup] = useState(false); + const siteTitle = useSiteTitle(); const sidebar = useSidebarControl(); @@ -519,7 +525,7 @@ export function StreamplaceDrawer() { drawerLabel: () => Home, headerTitle: isWeb ? "Home" : "Streamplace", headerShown: isWeb, - title: "Streamplace", + title: siteTitle, }} listeners={{ drawerItemPress: (e) => { @@ -703,6 +709,7 @@ export const PopupChecker = ({ const MainTab = () => { const theme = useTheme(); const { isWeb } = usePlatform(); + const siteTitle = useSiteTitle(); return ( { { if (Platform.OS === "web" && typeof document !== "undefined") { + // set title document.title = siteTitle; + + // set or update meta description + let metaDescription = document.querySelector('meta[name="description"]'); + if (!metaDescription) { + metaDescription = document.createElement("meta"); + metaDescription.setAttribute("name", "description"); + document.head.appendChild(metaDescription); + } + metaDescription.setAttribute("content", siteDescription); + + // set or update favicon + if (favicon) { + let link: HTMLLinkElement | null = + document.querySelector('link[rel="icon"]'); + if (!link) { + link = document.createElement("link"); + link.rel = "icon"; + document.head.appendChild(link); + } + link.href = favicon; + } } - }, [siteTitle]); + }, [siteTitle, siteDescription, favicon]); }