Update home page and logo in header

This commit is contained in:
Misode
2021-06-30 05:36:26 +02:00
parent 2fb4848425
commit cabd97cb39
10 changed files with 140 additions and 79 deletions

View File

@@ -1,7 +1,8 @@
import { getCurrentUrl, Link } from 'preact-router'
import { Btn, BtnMenu, Octicon } from '.'
import { Btn, BtnMenu, Icons, Octicon } from '.'
import config from '../../config.json'
import { locale } from '../Locales'
import { cleanUrl } from '../Utils'
const Themes: Record<string, keyof typeof Octicon> = {
system: 'device_desktop',
@@ -19,10 +20,13 @@ type HeaderProps = {
}
export function Header({ lang, title, theme, changeTheme, language, changeLanguage }: HeaderProps) {
const loc = locale.bind(null, lang)
const id = getCurrentUrl().replace(/^\//, '').replace(/\/$/, '')
const category = config.models.find(m => m.id === id)?.category
return <header>
<div class="header-title">
<Link class="home-link" href={getCurrentUrl().match(/^\/worldgen\/.+/) ? '/worldgen/' : '/'}>
{Octicon.three_bars}
<Link class="home-link" href={typeof category === 'string' ? cleanUrl(category) : '/'}>
{Icons.home}
</Link>
<h2>{title}</h2>
</div>