Remaped imports to prepare for new content handling

This commit is contained in:
Kevin FEDYNA
2025-01-15 11:20:48 +01:00
parent 55cf175181
commit ed2997d51f
16 changed files with 74 additions and 17 deletions
+2 -1
View File
@@ -28,7 +28,8 @@
"preact/": "https://esm.sh/preact@10.22.0/", "preact/": "https://esm.sh/preact@10.22.0/",
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.2", "@preact/signals": "https://esm.sh/*@preact/signals@1.2.2",
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.1", "@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.1",
"$std/": "https://deno.land/std@0.216.0/" "$std/": "https://deno.land/std@0.216.0/",
"$root/": "./"
}, },
"compilerOptions": { "compilerOptions": {
"jsx": "react-jsx", "jsx": "react-jsx",
+14
View File
@@ -2,7 +2,12 @@
// This file SHOULD be checked into source version control. // This file SHOULD be checked into source version control.
// This file is automatically updated during development when running `dev.ts`. // This file is automatically updated during development when running `dev.ts`.
import * as $_apps_layout from "./routes/(apps)/_layout.tsx";
import * as $_apps_notes_index from "./routes/(apps)/notes/index.tsx"; import * as $_apps_notes_index from "./routes/(apps)/notes/index.tsx";
import * as $_apps_notes_partials_admin_courses from "./routes/(apps)/notes/partials/(admin)/courses.tsx";
import * as $_apps_notes_partials_admin_students from "./routes/(apps)/notes/partials/(admin)/students.tsx";
import * as $_apps_notes_partials_index from "./routes/(apps)/notes/partials/index.tsx";
import * as $_apps_notes_partials_notes from "./routes/(apps)/notes/partials/notes.tsx";
import * as $_404 from "./routes/_404.tsx"; import * as $_404 from "./routes/_404.tsx";
import * as $_app from "./routes/_app.tsx"; import * as $_app from "./routes/_app.tsx";
import * as $_middleware from "./routes/_middleware.ts"; import * as $_middleware from "./routes/_middleware.ts";
@@ -13,11 +18,19 @@ import * as $login from "./routes/login.tsx";
import * as $logout from "./routes/logout.tsx"; import * as $logout from "./routes/logout.tsx";
import * as $Counter from "./islands/Counter.tsx"; import * as $Counter from "./islands/Counter.tsx";
import * as $_islands_AppNavigator from "./routes/(_islands)/AppNavigator.tsx"; import * as $_islands_AppNavigator from "./routes/(_islands)/AppNavigator.tsx";
import * as $_islands_Navbar from "./routes/(_islands)/Navbar.tsx";
import type { Manifest } from "$fresh/server.ts"; import type { Manifest } from "$fresh/server.ts";
const manifest = { const manifest = {
routes: { routes: {
"./routes/(apps)/_layout.tsx": $_apps_layout,
"./routes/(apps)/notes/index.tsx": $_apps_notes_index, "./routes/(apps)/notes/index.tsx": $_apps_notes_index,
"./routes/(apps)/notes/partials/(admin)/courses.tsx":
$_apps_notes_partials_admin_courses,
"./routes/(apps)/notes/partials/(admin)/students.tsx":
$_apps_notes_partials_admin_students,
"./routes/(apps)/notes/partials/index.tsx": $_apps_notes_partials_index,
"./routes/(apps)/notes/partials/notes.tsx": $_apps_notes_partials_notes,
"./routes/_404.tsx": $_404, "./routes/_404.tsx": $_404,
"./routes/_app.tsx": $_app, "./routes/_app.tsx": $_app,
"./routes/_middleware.ts": $_middleware, "./routes/_middleware.ts": $_middleware,
@@ -30,6 +43,7 @@ const manifest = {
islands: { islands: {
"./islands/Counter.tsx": $Counter, "./islands/Counter.tsx": $Counter,
"./routes/(_islands)/AppNavigator.tsx": $_islands_AppNavigator, "./routes/(_islands)/AppNavigator.tsx": $_islands_AppNavigator,
"./routes/(_islands)/Navbar.tsx": $_islands_Navbar,
}, },
baseUrl: import.meta.url, baseUrl: import.meta.url,
} satisfies Manifest; } satisfies Manifest;
+2
View File
@@ -1,6 +1,8 @@
export interface AppProperties { export interface AppProperties {
name: string; name: string;
icon: string; icon: string;
pages: Record<string, string>;
adminOnly: string[];
} }
type AppNavigatorProps = { type AppNavigatorProps = {
+11
View File
@@ -0,0 +1,11 @@
type NavbarProps = {
pages: Record<string, string>;
};
export default function Navbar(props: NavbarProps) {
return (
<>
<p>{JSON.stringify(props.pages)}</p>
</>
);
}
+24
View File
@@ -0,0 +1,24 @@
import { FreshContext } from "$fresh/server.ts";
import { Partial } from "$fresh/runtime.ts";
import { State } from "$root/routes/_middleware.ts";
import Navbar from "$root/routes/(_islands)/Navbar.tsx";
import { AppProperties } from "$root/routes/(_islands)/AppNavigator.tsx";
export default async function AppLayout(
request: Request,
context: FreshContext<State>,
) {
const currentApp = new URL(request.url).pathname;
const properties: AppProperties = (await import(
`./${currentApp}/(_props)/props.ts`
)).default;
return (
<>
<Navbar pages={properties.pages} />
<Partial name="body">
<context.Component />
</Partial>
</>
);
}
+9 -2
View File
@@ -1,8 +1,15 @@
import { AppProperties } from "../../../(_islands)/AppNavigator.tsx"; import { AppProperties } from "$root/routes/(_islands)/AppNavigator.tsx";
const properties: AppProperties = { const properties: AppProperties = {
name: "PolyNotes", name: "PolyNotes",
icon: "school" icon: "school",
pages: {
index: "Homepage",
notes: "Notes",
courses: "Courses management",
students: "Students management"
},
adminOnly: [ "courses", "students" ]
}; };
export default properties; export default properties;
+1 -4
View File
@@ -3,10 +3,7 @@ type ModulesProps = Record<string | number | symbol, never>;
export default function Modules(_props: ModulesProps) { export default function Modules(_props: ModulesProps) {
return ( return (
<> <>
<h2>All PolyMPR modules</h2> <a href="notes/test" f-partial={"notes/partial/test"}>click</a>
<nav>
</nav>
</> </>
); );
} }
+4 -7
View File
@@ -1,8 +1,7 @@
import { FreshContext } from "$fresh/server.ts"; import { FreshContext } from "$fresh/server.ts";
import { Partial } from "$fresh/runtime.ts"; import { State } from "$root/routes/_middleware.ts";
import { State } from "./_middleware.ts"; import Header from "$root/routes/(_components)/Header.tsx";
import Header from "./(_components)/Header.tsx"; import Footer from "$root/routes/(_components)/Footer.tsx";
import Footer from "./(_components)/Footer.tsx";
// deno-lint-ignore require-await // deno-lint-ignore require-await
export default async function App( export default async function App(
@@ -24,9 +23,7 @@ export default async function App(
<body f-client-nav> <body f-client-nav>
<Header link={link} /> <Header link={link} />
<section> <section>
<Partial name="body"> <context.Component />
<context.Component />
</Partial>
</section> </section>
<Footer /> <Footer />
</body> </body>
+5 -1
View File
@@ -1,11 +1,15 @@
import { FreshContext, Handlers } from "$fresh/server.ts"; import { FreshContext, Handlers } from "$fresh/server.ts";
import AppNavigator, { AppProperties } from "./(_islands)/AppNavigator.tsx"; import AppNavigator, { AppProperties } from "$root/routes/(_islands)/AppNavigator.tsx";
export const handler: Handlers = { export const handler: Handlers = {
async GET(_request, context) { async GET(_request, context) {
const apps: Record<string, AppProperties> = {}; const apps: Record<string, AppProperties> = {};
for await (const appDir of Deno.readDir("routes/(apps)")) { for await (const appDir of Deno.readDir("routes/(apps)")) {
if (appDir.isFile) {
continue;
}
try { try {
const properties: AppProperties = (await import( const properties: AppProperties = (await import(
`./(apps)/${appDir.name}/(_props)/props.ts` `./(apps)/${appDir.name}/(_props)/props.ts`
+1 -1
View File
@@ -1,5 +1,5 @@
import { Handlers } from "$fresh/server.ts"; import { Handlers } from "$fresh/server.ts";
import { State } from "./_middleware.ts"; import { State } from "$root/routes/_middleware.ts";
import { import {
parse, parse,
type RegularTagNode, type RegularTagNode,
+1 -1
View File
@@ -1,5 +1,5 @@
import { Handlers } from "$fresh/server.ts"; import { Handlers } from "$fresh/server.ts";
import { State } from "./_middleware.ts"; import { State } from "$root/routes/_middleware.ts";
import { deleteCookie } from "$std/http/cookie.ts"; import { deleteCookie } from "$std/http/cookie.ts";
const SERVICE = "https://localhost/"; const SERVICE = "https://localhost/";