a3638fe954
Test and Lint / backend-test (push) Successful in 1m11s
continuous-integration/drone/push Build is passing
Test and Lint / frontend-test (push) Successful in 2m17s
Version and Release / version-bump (push) Successful in 43s
Version and Release / trigger-drone (push) Successful in 3s
- Add URL utility functions for building resource URLs - Update all components to use relative URLs in production - Add production deployment documentation - Update nginx config to proxy all required endpoints - Add .env.production.example with proper configuration
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { useEffect } from 'react';
|
|
import { useQuery } from '@tanstack/react-query';
|
|
import { getApiBaseUrl, buildResourceUrl } from '../../utils/url';
|
|
|
|
export const DynamicFavicon: React.FC = () => {
|
|
const { data: settings } = useQuery({
|
|
queryKey: ['public-settings'],
|
|
queryFn: async () => {
|
|
try {
|
|
const response = await fetch(`${getApiBaseUrl()}/public/settings`);
|
|
if (response.ok) {
|
|
return response.json();
|
|
}
|
|
return null;
|
|
} catch {
|
|
return null;
|
|
}
|
|
},
|
|
staleTime: 5 * 60 * 1000, // 5 minutes
|
|
});
|
|
|
|
useEffect(() => {
|
|
if (settings?.branding_favicon_url) {
|
|
// Remove existing favicon links
|
|
const existingFavicons = document.querySelectorAll("link[rel*='icon']");
|
|
existingFavicons.forEach(favicon => favicon.remove());
|
|
|
|
// Create new favicon link
|
|
const link = document.createElement('link');
|
|
link.rel = 'icon';
|
|
link.type = 'image/png';
|
|
link.href = settings.branding_favicon_url.startsWith('http')
|
|
? settings.branding_favicon_url
|
|
: buildResourceUrl(settings.branding_favicon_url);
|
|
|
|
document.head.appendChild(link);
|
|
}
|
|
}, [settings?.branding_favicon_url]);
|
|
|
|
return null;
|
|
}; |