mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-24 07:37:10 +00:00
Make generator config more robust
This commit is contained in:
@@ -2,7 +2,7 @@ import { getCurrentUrl, Link } from 'preact-router'
|
||||
import { Btn, BtnMenu, Icons, Octicon } from '.'
|
||||
import config from '../../config.json'
|
||||
import { locale } from '../Locales'
|
||||
import { cleanUrl } from '../Utils'
|
||||
import { cleanUrl, getGenerator } from '../Utils'
|
||||
|
||||
const Themes: Record<string, keyof typeof Octicon> = {
|
||||
system: 'device_desktop',
|
||||
@@ -20,8 +20,7 @@ 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
|
||||
const category = getGenerator(getCurrentUrl())?.category
|
||||
|
||||
return <header>
|
||||
<div class="header-title">
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useModel } from '../hooks'
|
||||
import type { VersionId } from '../Schemas'
|
||||
import { BiomeSourcePreview, DecoratorPreview, NoiseSettingsPreview } from './previews'
|
||||
|
||||
export const HasPreview = ['dimension', 'worldgen/noise-settings', 'worldgen/feature']
|
||||
export const HasPreview = ['dimension', 'worldgen/noise_settings', 'worldgen/configured_feature']
|
||||
|
||||
export const Previews: {
|
||||
id: string,
|
||||
@@ -30,14 +30,14 @@ export const Previews: {
|
||||
},
|
||||
{
|
||||
id: 'noise-settings',
|
||||
generator: 'worldgen/noise-settings',
|
||||
generator: 'worldgen/noise_settings',
|
||||
path: new Path(['noise']),
|
||||
predicate: () => true,
|
||||
preview: NoiseSettingsPreview,
|
||||
},
|
||||
{
|
||||
id: 'decorator',
|
||||
generator: 'worldgen/feature',
|
||||
generator: 'worldgen/configured_feature',
|
||||
path: new Path([]),
|
||||
predicate: () => true,
|
||||
preview: DecoratorPreview,
|
||||
|
||||
Reference in New Issue
Block a user