forked from benvinegar/counterscale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroot.tsx
140 lines (133 loc) · 5.42 KB
/
root.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import styles from "./globals.css";
import {
json,
LoaderFunctionArgs,
type LinksFunction,
} from "@remix-run/cloudflare";
import { cssBundleHref } from "@remix-run/css-bundle";
import {
Links,
LiveReload,
Meta,
Outlet,
Scripts,
ScrollRestoration,
useLoaderData,
} from "@remix-run/react";
export const links: LinksFunction = () => [
{ rel: "stylesheet", href: styles },
...(cssBundleHref ? [{ rel: "stylesheet", href: cssBundleHref }] : []),
];
export const loader = ({ context, request }: LoaderFunctionArgs) => {
const url = new URL(request.url);
return json({
version: context.env.VERSION,
origin: url.origin,
url: request.url,
});
};
export default function App() {
const data = useLoaderData<typeof loader>();
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1"
/>
<link rel="icon" type="image/x-icon" href="/favicon.png" />
<meta property="og:url" content={data.url} />
<meta property="og:type" content="website" />
<meta property="og:title" content="Counterscale" />
<meta
property="og:description"
content="Scalable web analytics you run yourself on Cloudflare"
/>
<meta
property="og:image"
content={data.origin + "/counterscale-og-large.webp"}
/>
<meta name="twitter:card" content="summary_large_image" />
<meta property="twitter:domain" content="counterscale.dev" />
<meta property="twitter:url" content={data.url} />
<meta name="twitter:title" content="Counterscale" />
<meta
name="twitter:description"
content="Scalable web analytics you run yourself on Cloudflare"
/>
<meta
name="twitter:image"
content={data.origin + "/counterscale-og-large.webp"}
/>
<Meta />
<Links />
</head>
<body>
<div className="container mx-auto mt-4">
<header className="border-b-2 mb-12 py-4">
<nav className="flex justify-between items-center">
<div className="flex items-center">
<a
href="/"
className="text-xl sm:text-2xl font-bold"
>
Counterscale
</a>
<img
className="w-6 sm:w-8 ml-1"
src="/favicon.png"
alt="Counterscale Icon"
/>
</div>
<div className="flex items-center font-small font-medium text-md sm:text-lg">
<a href="/dashboard">Dashboard</a>
<a
href="/admin-redirect"
target="_blank"
className="hidden sm:inline-block ml-2 sm:ml-4"
>
Admin
</a>
<a
href="https://github.com/benvinegar/counterscale"
className="w-8 ml-2 sm:ml-4"
>
<img
src="/github-mark.svg"
alt="GitHub Logo"
style={{
filter: "invert(21%) sepia(27%) saturate(271%) hue-rotate(113deg) brightness(97%) contrast(97%)",
}}
/>
</a>
</div>
</nav>
</header>
<main role="main" className="w-full">
<Outlet />
</main>
<footer className="py-4 flex justify-end text-s">
<div>
Version{" "}
<a
href={`https://github.com/benvinegar/counterscale/commit/${data.version}`}
>
{data.version?.slice(0, 7)}
</a>
</div>
</footer>
</div>
<ScrollRestoration />
<Scripts />
<LiveReload />
<script
dangerouslySetInnerHTML={{
__html: "window.counterscale = {'q': [['set', 'siteId', 'counterscale-dev'], ['trackPageview']] };",
}}
></script>
<script id="counterscale-script" src="/tracker.js"></script>
</body>
</html>
);
}