mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 07:10:41 +00:00
Switch to vite and preact
This commit is contained in:
38
src/app/pages/Home.tsx
Normal file
38
src/app/pages/Home.tsx
Normal file
@@ -0,0 +1,38 @@
|
||||
import { Link } from 'preact-router'
|
||||
import config from '../../config.json'
|
||||
import { Octicon } from '../components/Octicon'
|
||||
import { locale } from '../Locales'
|
||||
import { cleanUrl } from '../Utils'
|
||||
|
||||
type HomeProps = {
|
||||
lang: string,
|
||||
changeTitle: (title: string) => unknown,
|
||||
path?: string,
|
||||
category?: string,
|
||||
}
|
||||
export function Home({ lang, changeTitle, category }: HomeProps) {
|
||||
const loc = locale.bind(null, lang)
|
||||
changeTitle(category ? loc('title.generator_category', loc(category)) : loc('title.home'))
|
||||
return <main>
|
||||
<div class="home">
|
||||
<div class="generator-picker">
|
||||
<ul class="generators-list">
|
||||
{config.models.filter(m => typeof m.category !== 'string').map(m => <li>
|
||||
<Link class={`generators-card${m.category === true && m.id === category ? ' selected' : ''}`} href={cleanUrl(m.id)}>
|
||||
{loc(m.id)}
|
||||
{m.category && Octicon.chevron_right}
|
||||
</Link>
|
||||
</li>)}
|
||||
</ul>
|
||||
{(category && config.models.some(m => m.category === category)) &&
|
||||
<ul class="generators-list">
|
||||
{config.models.filter(m => m.category === category).map(m => <li>
|
||||
<Link class="generators-card" href={cleanUrl(m.id)}>
|
||||
{loc(m.id)}
|
||||
</Link>
|
||||
</li>)}
|
||||
</ul>}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
}
|
||||
Reference in New Issue
Block a user