AppNavigator can now navigate
This commit is contained in:
@@ -3,25 +3,14 @@ export interface AppProperties {
|
|||||||
icon: string;
|
icon: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type AppNavigatorProps = Record<string | number | symbol, never>;
|
type AppNavigatorProps = {
|
||||||
|
apps: Record<string, AppProperties>;
|
||||||
export default async function AppNavigator(_props: AppNavigatorProps) {
|
};
|
||||||
|
|
||||||
const apps: Record<string, AppProperties> = {};
|
|
||||||
|
|
||||||
for await (const appDir of Deno.readDir("../(apps)")) {
|
|
||||||
try {
|
|
||||||
const properties: AppProperties = await import(`../(apps)/${appDir.name}/(_props)/props.ts`);
|
|
||||||
apps[appDir.name] = properties;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
console.error(`Couldn't import app "${appDir.name}": ${error}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
export default function AppNavigator(props: AppNavigatorProps) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<p>{JSON.stringify(apps)}</p>
|
<p>{JSON.stringify(props.apps)}</p>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-6
@@ -1,13 +1,30 @@
|
|||||||
import { FreshContext } from "$fresh/server.ts";
|
import { FreshContext, Handlers } from "$fresh/server.ts";
|
||||||
import AppNavigator from "./(_islands)/AppNavigator.tsx";
|
import AppNavigator, { AppProperties } from "./(_islands)/AppNavigator.tsx";
|
||||||
|
|
||||||
|
export const handler: Handlers = {
|
||||||
|
async GET(_request, context) {
|
||||||
|
const apps: Record<string, AppProperties> = {};
|
||||||
|
|
||||||
|
for await (const appDir of Deno.readDir("routes/(apps)")) {
|
||||||
|
try {
|
||||||
|
const properties: AppProperties = (await import(
|
||||||
|
`./(apps)/${appDir.name}/(_props)/props.ts`
|
||||||
|
)).default;
|
||||||
|
apps[appDir.name] = properties;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Couldn't import app "${appDir.name}": ${error}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return context.render(apps);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
// deno-lint-ignore require-await
|
// deno-lint-ignore require-await
|
||||||
export default async function About(_request: Request, _context: FreshContext) {
|
export default async function About(_request: Request, context: FreshContext) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{
|
<AppNavigator apps={context.data} />
|
||||||
//<AppNavigator />
|
|
||||||
}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user