feat: set browser tab title and favicon from customer branding
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,29 @@
|
|||||||
import { createRootRoute, Outlet } from '@tanstack/react-router'
|
import { createRootRoute, Outlet } from '@tanstack/react-router'
|
||||||
import { Toaster } from 'sonner'
|
import { Toaster } from 'sonner'
|
||||||
|
import { useEffect } from 'react'
|
||||||
|
|
||||||
export const Route = createRootRoute({
|
export const Route = createRootRoute({
|
||||||
component: RootLayout,
|
component: RootLayout,
|
||||||
})
|
})
|
||||||
|
|
||||||
function RootLayout() {
|
function RootLayout() {
|
||||||
|
useEffect(() => {
|
||||||
|
fetch('/v1/store/branding')
|
||||||
|
.then((r) => r.ok ? r.json() : null)
|
||||||
|
.then((data: { name: string | null; hasLogo: boolean } | null) => {
|
||||||
|
if (!data) return
|
||||||
|
if (data.name) document.title = data.name
|
||||||
|
if (data.hasLogo) {
|
||||||
|
const link = document.querySelector<HTMLLinkElement>('link[rel="icon"]')
|
||||||
|
?? document.createElement('link')
|
||||||
|
link.rel = 'icon'
|
||||||
|
link.href = '/v1/store/logo'
|
||||||
|
document.head.appendChild(link)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
|
|||||||
Reference in New Issue
Block a user