mirror of
https://github.com/lissy93/networking-toolbox.git
synced 2026-11-22 05:51:46 +03:00
Fix favicon updating on Chrome
This commit is contained in:
1 parent
7a7d36c8c0
commit
b09de201d6
4 files changed
+7
-18
No files matched your search
@@ -1,6 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { site } from '$lib/constants/site';
|
||||
import favicon from '$lib/assets/favicon.svg';
|
||||
import Icon from '$lib/components/global/Icon.svelte';
|
||||
import GlobalSearch from '$lib/components/global/GlobalSearch.svelte';
|
||||
import BurgerMenu from '$lib/components/furniture/BurgerMenu.svelte';
|
||||
@@ -11,10 +10,6 @@
|
||||
export let toggleTheme: () => void;
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<link rel="icon" href={favicon} />
|
||||
</svelte:head>
|
||||
|
||||
<header class="header">
|
||||
<div class="container">
|
||||
<div class="header-content">
|
||||
@@ -53,7 +48,8 @@
|
||||
/>
|
||||
</svg>
|
||||
{:else}
|
||||
<svg fill="currentColor" viewBox="0 0 20 20">
|
||||
<svg fill="currentColor" viewBox="0 0 640 640">
|
||||
<path d="M320 64C178.6 64 64 178.6 64 320C64 461.4 178.6 576 320 576C388.8 576 451.3 548.8 497.3 504.6C504.6 497.6 506.7 486.7 502.6 477.5C498.5 468.3 488.9 462.6 478.8 463.4C473.9 463.8 469 464 464 464C362.4 464 280 381.6 280 280C280 207.9 321.5 145.4 382.1 115.2C391.2 110.7 396.4 100.9 395.2 90.8C394 80.7 386.6 72.5 376.7 70.3C358.4 66.2 339.4 64 320 64z"/>
|
||||
<path d="M17.293 13.293A8 8 0 716.707 2.707a8.001 8.001 0 1010.586 10.586z" />
|
||||
</svg>
|
||||
{/if}
|
||||
|
||||
@@ -41,12 +41,11 @@ function processSvgForFavicon(svgContent: string, color: string): string {
|
||||
* @returns The CSS variable value or fallback color
|
||||
*/
|
||||
export function getPrimaryColor(): string {
|
||||
if (typeof window === 'undefined') return '#e3ed70';
|
||||
|
||||
const fallbackColor = '#e3ed70';
|
||||
if (typeof window === 'undefined') return fallbackColor;
|
||||
const computedStyle = getComputedStyle(document.documentElement);
|
||||
const colorValue = computedStyle.getPropertyValue('--color-primary').trim();
|
||||
|
||||
return colorValue || '#e3ed70';
|
||||
return colorValue || fallbackColor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,12 +59,8 @@ export function generateFaviconDataUri(iconName: string, color?: string): string
|
||||
if (!svgContent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const faviconColor = color || getPrimaryColor();
|
||||
const processedSvg = processSvgForFavicon(svgContent, faviconColor);
|
||||
|
||||
// URL encode the SVG for use in data URI
|
||||
const encodedSvg = encodeURIComponent(processedSvg);
|
||||
|
||||
return `data:image/svg+xml,${encodedSvg}`;
|
||||
}
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
// Dynamic favicon based on page icon
|
||||
const dynamicFavicon = $derived.by(() => {
|
||||
faviconTrigger; // Include faviconTrigger to force updates when theme changes
|
||||
faviconTrigger; // Include in order to force updates when theme changes
|
||||
const currentPath = $page.url.pathname;
|
||||
const pageDetailsWithIcon = getPageDetailsWithIcon(currentPath);
|
||||
if (pageDetailsWithIcon?.icon) {
|
||||
@@ -92,8 +92,8 @@
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<!-- Dynamic Favicon -->
|
||||
<link rel="icon" type="image/svg+xml" href={dynamicFavicon} />
|
||||
<link rel="shortcut icon" type="image/svg+xml" href={dynamicFavicon} />
|
||||
|
||||
<!-- SEO Meta Tags -->
|
||||
<title>{seoData.title}</title>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
<script lang="ts">
|
||||
export const prerender = true;
|
||||
|
||||
import '../../styles/pages.scss';
|
||||
import { site, pages } from '$lib/constants/site';
|
||||
import ToolsCarousel from '$lib/components/global/ToolsCarousel.svelte';
|
||||
|
||||
Reference in new issue
Block a user