Partials OK, auto navbar and content

This commit is contained in:
Kevin FEDYNA
2025-01-15 15:43:52 +01:00
parent ed2997d51f
commit 9db588ff02
24 changed files with 510 additions and 321 deletions
+7 -6
View File
@@ -1,24 +1,25 @@
import { FreshContext } from "$fresh/server.ts";
import { Partial } from "$fresh/runtime.ts";
import { State } from "$root/routes/_middleware.ts";
import { AppProperties } from "$root/defaults/interfaces.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 pathname = new URL(request.url).pathname;
const currentApp = pathname.split("/")[1];
const properties: AppProperties = (await import(
`./${currentApp}/(_props)/props.ts`
)).default;
)).default;
return (
<>
<Navbar pages={properties.pages} />
<section id="app">
<Navbar currentApp={currentApp} pages={properties.pages} />
<Partial name="body">
<context.Component />
</Partial>
</>
</section>
);
}
+4 -4
View File
@@ -1,4 +1,4 @@
import { AppProperties } from "$root/routes/(_islands)/AppNavigator.tsx";
import { AppProperties } from "$root/defaults/interfaces.ts";
const properties: AppProperties = {
name: "PolyNotes",
@@ -7,9 +7,9 @@ const properties: AppProperties = {
index: "Homepage",
notes: "Notes",
courses: "Courses management",
students: "Students management"
students: "Students management",
},
adminOnly: [ "courses", "students" ]
adminOnly: ["courses", "students"],
};
export default properties;
export default properties;
+2 -9
View File
@@ -1,9 +1,2 @@
type ModulesProps = Record<string | number | symbol, never>;
export default function Modules(_props: ModulesProps) {
return (
<>
<a href="notes/test" f-partial={"notes/partial/test"}>click</a>
</>
);
}
import makeIndex from "$root/defaults/makeIndex.ts";
export default makeIndex(import.meta.dirname!);
@@ -0,0 +1,17 @@
import { Partial } from "$fresh/runtime.ts";
import { RouteConfig } from "$fresh/server.ts";
type ModulesProps = Record<string | number | symbol, never>;
export const config: RouteConfig = {
skipAppWrapper: true,
skipInheritedLayouts: true,
};
export default function Modules(_props: ModulesProps) {
return (
<Partial name="body">
<a href="notes" f-partial={"notes/partials"}>notes</a>
</Partial>
);
}
@@ -0,0 +1,17 @@
import { Partial } from "$fresh/runtime.ts";
import { RouteConfig } from "$fresh/server.ts";
type ModulesProps = Record<string | number | symbol, never>;
export const config: RouteConfig = {
skipAppWrapper: true,
skipInheritedLayouts: true,
};
export default function Modules(_props: ModulesProps) {
return (
<Partial name="body">
<a href="notes" f-partial={"notes/partials"}>notes</a>
</Partial>
);
}
+10
View File
@@ -0,0 +1,10 @@
import { getConfig, makePartials } from "$root/defaults/makePartials.tsx";
type NotesIndexProps = Record<string | number | symbol, never>;
export function Index(_props: NotesIndexProps) {
return <a href="notes" f-partial={"notes/partials"}>bip boup</a>;
}
export const config = getConfig();
export default makePartials(Index);
+17
View File
@@ -0,0 +1,17 @@
import { Partial } from "$fresh/runtime.ts";
import { RouteConfig } from "$fresh/server.ts";
type ModulesProps = Record<string | number | symbol, never>;
export const config: RouteConfig = {
skipAppWrapper: true,
skipInheritedLayouts: true,
};
export default function Modules(_props: ModulesProps) {
return (
<Partial name="body">
<a href="notes" f-partial={"notes/partials"}>notes</a>
</Partial>
);
}