mirror of
https://git.meshkee.com/Meshkee/dashboards.git
synced 2026-08-11 22:30:58 +04:30
Initial commit: Meshkee dashboards monorepo.
Includes business, customer, and super-admin apps with shared packages and production deploy scripts. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
const FAVICON_ATTR = 'data-business-favicon'
|
||||
|
||||
function removeIconLinks(root: ParentNode = document.head) {
|
||||
root
|
||||
.querySelectorAll(
|
||||
'link[rel="icon"], link[rel="shortcut icon"], link[rel="apple-touch-icon"]',
|
||||
)
|
||||
.forEach((node) => node.remove())
|
||||
}
|
||||
|
||||
/** Sets browser tab favicon links for the current tenant. Pass null to clear. */
|
||||
export function applyDocumentFavicon(url: string | null | undefined) {
|
||||
if (typeof document === 'undefined') return
|
||||
|
||||
removeIconLinks()
|
||||
|
||||
const href = url?.trim()
|
||||
if (!href) return
|
||||
|
||||
// Bust browser favicon cache when the logo/favicon media URL changes.
|
||||
const cacheBusted =
|
||||
href.includes('?') ? `${href}&v=${Date.now()}` : `${href}?v=${Date.now()}`
|
||||
|
||||
for (const rel of ['icon', 'apple-touch-icon'] as const) {
|
||||
const link = document.createElement('link')
|
||||
link.setAttribute(FAVICON_ATTR, 'true')
|
||||
link.rel = rel
|
||||
link.href = cacheBusted
|
||||
if (rel === 'icon') {
|
||||
link.type = 'image/png'
|
||||
link.sizes = '48x48'
|
||||
}
|
||||
document.head.appendChild(link)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user