Skip to content

Commit d90de5b

Browse files
committed
chore: mv fathom to after body
1 parent 27d884a commit d90de5b

1 file changed

Lines changed: 14 additions & 19 deletions

File tree

src/routes/__root.tsx

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ export const Route = createRootRoute({
1717
rel: 'preload',
1818
type: 'font/woff2',
1919
},
20-
{ href: '/sheep/static/thunder.png', rel: 'icon', type: 'image/png' },
20+
{ href: 'https://cdn.usefathom.com', rel: 'preconnect' },
21+
{ href: '/sheep/static/cloud.png', rel: 'icon', type: 'image/png' },
22+
{
23+
href: '/sheep/static/thunder.png',
24+
media: '(prefers-color-scheme: dark)',
25+
rel: 'icon',
26+
type: 'image/png',
27+
},
2128
],
2229
meta: [
2330
{ charSet: 'utf-8' },
@@ -26,13 +33,6 @@ export const Route = createRootRoute({
2633
content: 'width=device-width, initial-scale=1, maximum-scale=1',
2734
},
2835
],
29-
scripts: [
30-
{
31-
src: 'https://cdn.usefathom.com/script.js',
32-
'data-site': 'GPMOZIWR',
33-
defer: true,
34-
},
35-
],
3636
}
3737
},
3838
component: RootComponent,
@@ -80,15 +80,16 @@ function RootDocument(props: React.PropsWithChildren) {
8080
suppressHydrationWarning
8181
/>
8282
<HeadContent />
83+
</head>
84+
<body>
85+
{children}
86+
<Scripts />
87+
<script data-site="GPMOZIWR" defer src="https://cdn.usefathom.com/script.js" />
8388
<script
8489
// oxlint-disable-next-line react/no-danger: favicon script is static
8590
dangerouslySetInnerHTML={{ __html: faviconScript }}
8691
suppressHydrationWarning
8792
/>
88-
</head>
89-
<body>
90-
{children}
91-
<Scripts />
9293
</body>
9394
</html>
9495
)
@@ -99,15 +100,9 @@ const faviconScript = `
99100
var query = window.matchMedia('(prefers-color-scheme: dark)');
100101
function apply() {
101102
document.querySelectorAll('link[rel="icon"]').forEach(function(link) {
102-
link.remove();
103+
link.href = query.matches ? '/sheep/static/thunder.png' : '/sheep/static/cloud.png';
103104
});
104-
var link = document.createElement('link');
105-
link.rel = 'icon';
106-
link.type = 'image/png';
107-
link.href = (query.matches ? '/sheep/static/thunder.png' : '/sheep/static/cloud.png') + '?theme=' + (query.matches ? 'dark' : 'light') + '&t=' + Date.now();
108-
document.head.appendChild(link);
109105
}
110-
apply();
111106
query.addEventListener('change', apply);
112107
})();
113108
`

0 commit comments

Comments
 (0)