feat: Allow to chose webroot

issue #180
This commit is contained in:
C4illin 2024-11-06 08:49:53 +01:00
parent f3a4aece46
commit 36cb6cc589
7 changed files with 114 additions and 86 deletions

View file

@ -3,34 +3,37 @@ import { Html } from "@elysiajs/html";
export const BaseHtml = ({
children,
title = "ConvertX",
webroot = "",
}: {
children: JSX.Element;
title?: string;
webroot?: string;
}) => (
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="webroot" content={webroot} />
<title safe>{title}</title>
<link rel="stylesheet" href="/generated.css" />
<link rel="stylesheet" href={`${webroot}/generated.css`} />
<link
rel="apple-touch-icon"
sizes="180x180"
href="/apple-touch-icon.png"
href={`${webroot}/apple-touch-icon.png`}
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/favicon-32x32.png"
href={`${webroot}/favicon-32x32.png`}
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="/favicon-16x16.png"
href={`${webroot}/favicon-16x16.png`}
/>
<link rel="manifest" href="/site.webmanifest" />
<link rel="manifest" href={`${webroot}/site.webmanifest`} />
</head>
<body class="w-full bg-neutral-900 text-neutral-200">{children}</body>
</html>

View file

@ -3,9 +3,11 @@ import { Html } from "@kitajs/html";
export const Header = ({
loggedIn,
accountRegistration,
webroot = "",
}: {
loggedIn?: boolean;
accountRegistration?: boolean;
webroot?: string;
}) => {
let rightNav: JSX.Element;
if (loggedIn) {
@ -17,7 +19,7 @@ export const Header = ({
text-accent-600 transition-all
hover:text-accent-500 hover:underline
`}
href="/history"
href={`${webroot}/history`}
>
History
</a>
@ -28,7 +30,7 @@ export const Header = ({
text-accent-600 transition-all
hover:text-accent-500 hover:underline
`}
href="/logoff"
href={`${webroot}/logoff`}
>
Logout
</a>
@ -44,7 +46,7 @@ export const Header = ({
text-accent-600 transition-all
hover:text-accent-500 hover:underline
`}
href="/login"
href={`${webroot}/login`}
>
Login
</a>
@ -56,7 +58,7 @@ export const Header = ({
text-accent-600 transition-all
hover:text-accent-500 hover:underline
`}
href="/register"
href={`${webroot}/register`}
>
Register
</a>
@ -72,7 +74,7 @@ export const Header = ({
<ul>
<li>
<strong>
<a href="/">ConvertX</a>
<a href={`${webroot}/`}>ConvertX</a>
</strong>
</li>
</ul>