Close #236 add tag generators

This commit is contained in:
Misode
2022-05-25 03:57:55 +02:00
parent 781d545962
commit 32e6d5c167
6 changed files with 59 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ export function App() {
<Router onChange={changeRoute}>
<Home path="/" />
<Category path="/worldgen" category="worldgen" />
<Category path="/tags" category="tags" />
<Category path="/assets" category="assets" />
<Partners path="/partners" />
<Sounds path="/sounds" />

View File

@@ -129,7 +129,8 @@ export function getFilePath(file: ProjectFile) {
}
const gen = config.generators.find(g => g.id === file.type)
if (!gen) {
throw new Error(`Cannot find generator of type ${file.type}`)
console.error(`Cannot find generator of type ${file.type}`)
return undefined
}
return `data/${namespace}/${gen.path ?? gen.id}/${id}`
}

View File

@@ -15,6 +15,7 @@ export function Home({}: Props) {
{config.generators.filter(g => !g.category).map(g =>
<ToolCard title={locale(g.id)} link={cleanUrl(g.url)} />
)}
<ToolCard title={locale('tags')} link="/tags/" />
<ToolCard title={locale('worldgen')} link="/worldgen/" />
</ToolCard>
<ToolCard title="Resource packs">

View File

@@ -9,7 +9,10 @@ export function Project({}: Props) {
const { locale } = useLocale()
const { project, openFile } = useProject()
useTitle(locale('title.project', project.name))
const entries = useMemo(() => project.files.map(getFilePath), project.files)
const entries = useMemo(() => project.files.flatMap(f => {
const path = getFilePath(f)
return path ? [path] : []
}), project.files)
const selectFile = useCallback((entry: string) => {
const [, namespace, type, ...id] = entry.split('/')