diff --git a/fresh.gen.ts b/fresh.gen.ts index 7eb9815..1bcdb76 100644 --- a/fresh.gen.ts +++ b/fresh.gen.ts @@ -2,6 +2,7 @@ // This file SHOULD be checked into source version control. // This file is automatically updated during development when running `dev.ts`. +import * as $_apps_mobility_index from "./routes/(apps)/mobility/index.tsx"; import * as $_apps_notes_index from "./routes/(apps)/notes/index.tsx"; import * as $_404 from "./routes/_404.tsx"; import * as $_app from "./routes/_app.tsx"; @@ -17,6 +18,7 @@ import type { Manifest } from "$fresh/server.ts"; const manifest = { routes: { + "./routes/(apps)/mobility/index.tsx": $_apps_mobility_index, "./routes/(apps)/notes/index.tsx": $_apps_notes_index, "./routes/_404.tsx": $_404, "./routes/_app.tsx": $_app, diff --git a/routes/(_components)/ModuleCard.tsx b/routes/(_components)/ModuleCard.tsx new file mode 100644 index 0000000..8e77f1e --- /dev/null +++ b/routes/(_components)/ModuleCard.tsx @@ -0,0 +1,16 @@ +import { AppProperties } from "../(_islands)/AppNavigator.tsx"; + +type ModuleCardProps = { + module: AppProperties; +}; + +export default function ModuleCard({ module }: ModuleCardProps) { + return ( +
+ + {module.icon} +

{module.name}

+
+
+ ); +} diff --git a/routes/(_islands)/AppNavigator.tsx b/routes/(_islands)/AppNavigator.tsx index 24d7dc5..7f23cb2 100644 --- a/routes/(_islands)/AppNavigator.tsx +++ b/routes/(_islands)/AppNavigator.tsx @@ -1,6 +1,7 @@ export interface AppProperties { name: string; icon: string; + hint: string; } type AppNavigatorProps = { diff --git a/routes/(apps)/mobility/(_props)/props.ts b/routes/(apps)/mobility/(_props)/props.ts new file mode 100644 index 0000000..db5371b --- /dev/null +++ b/routes/(apps)/mobility/(_props)/props.ts @@ -0,0 +1,9 @@ +import { AppProperties } from "../../../(_islands)/AppNavigator.tsx"; + +const properties: AppProperties = { + name: "PolyMobility", + icon: "flight_takeoff", + hint: "Gestionnaire de mobilité" +}; + +export default properties; \ No newline at end of file diff --git a/routes/(apps)/mobility/index.tsx b/routes/(apps)/mobility/index.tsx new file mode 100644 index 0000000..ddfcc34 --- /dev/null +++ b/routes/(apps)/mobility/index.tsx @@ -0,0 +1,12 @@ +type ModulesProps = Record; + +export default function Modules(_props: ModulesProps) { + return ( + <> +

All PolyMPR modules

+ + + ); +} \ No newline at end of file diff --git a/routes/(apps)/notes/(_props)/props.ts b/routes/(apps)/notes/(_props)/props.ts index 6350ddd..7c203a6 100644 --- a/routes/(apps)/notes/(_props)/props.ts +++ b/routes/(apps)/notes/(_props)/props.ts @@ -2,7 +2,8 @@ import { AppProperties } from "../../../(_islands)/AppNavigator.tsx"; const properties: AppProperties = { name: "PolyNotes", - icon: "school" + icon: "school", + hint: "Gestionnaire de note" }; export default properties; \ No newline at end of file diff --git a/routes/_app.tsx b/routes/_app.tsx index de447b0..31218a7 100644 --- a/routes/_app.tsx +++ b/routes/_app.tsx @@ -18,7 +18,7 @@ export default async function App( PolyMPR - + diff --git a/routes/index.tsx b/routes/index.tsx index a210e9a..997573a 100644 --- a/routes/index.tsx +++ b/routes/index.tsx @@ -1,10 +1,49 @@ -import { FreshContext } from "$fresh/server.ts"; +import { FreshContext, Handlers } from "$fresh/server.ts"; +import ModuleCard from "./(_components)/ModuleCard.tsx"; +import { AppProperties } from "./(_islands)/AppNavigator.tsx"; + +export const handler: Handlers = { + async GET(_request, context) { + const apps: Record = {}; + + 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 -export default async function Home(_request: Request, _context: FreshContext) { +export default async function Home(_request: Request, context: FreshContext) { + const apps: Record = context.data; + console.log("Context data:", context.data); + + if (!apps) { + return ( + <> +

Welcome to PolyMPR!

+

No modules available.

+ + ); + } + return ( <>

Welcome to PolyMPR!

+

Module list

+
+ {Object.entries(apps).map(([key, module]) => ( + + ))} +
); }