Remaped imports to prepare for new content handling
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
export interface AppProperties {
|
||||
name: string;
|
||||
icon: string;
|
||||
pages: Record<string, string>;
|
||||
adminOnly: string[];
|
||||
}
|
||||
|
||||
type AppNavigatorProps = {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
type NavbarProps = {
|
||||
pages: Record<string, string>;
|
||||
};
|
||||
|
||||
export default function Navbar(props: NavbarProps) {
|
||||
return (
|
||||
<>
|
||||
<p>{JSON.stringify(props.pages)}</p>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,15 @@
|
||||
import { AppProperties } from "../../../(_islands)/AppNavigator.tsx";
|
||||
import { AppProperties } from "$root/routes/(_islands)/AppNavigator.tsx";
|
||||
|
||||
const properties: AppProperties = {
|
||||
name: "PolyNotes",
|
||||
icon: "school"
|
||||
icon: "school",
|
||||
pages: {
|
||||
index: "Homepage",
|
||||
notes: "Notes",
|
||||
courses: "Courses management",
|
||||
students: "Students management"
|
||||
},
|
||||
adminOnly: [ "courses", "students" ]
|
||||
};
|
||||
|
||||
export default properties;
|
||||
@@ -3,10 +3,7 @@ type ModulesProps = Record<string | number | symbol, never>;
|
||||
export default function Modules(_props: ModulesProps) {
|
||||
return (
|
||||
<>
|
||||
<h2>All PolyMPR modules</h2>
|
||||
<nav>
|
||||
|
||||
</nav>
|
||||
<a href="notes/test" f-partial={"notes/partial/test"}>click</a>
|
||||
</>
|
||||
);
|
||||
}
|
||||
+4
-7
@@ -1,8 +1,7 @@
|
||||
import { FreshContext } from "$fresh/server.ts";
|
||||
import { Partial } from "$fresh/runtime.ts";
|
||||
import { State } from "./_middleware.ts";
|
||||
import Header from "./(_components)/Header.tsx";
|
||||
import Footer from "./(_components)/Footer.tsx";
|
||||
import { State } from "$root/routes/_middleware.ts";
|
||||
import Header from "$root/routes/(_components)/Header.tsx";
|
||||
import Footer from "$root/routes/(_components)/Footer.tsx";
|
||||
|
||||
// deno-lint-ignore require-await
|
||||
export default async function App(
|
||||
@@ -24,9 +23,7 @@ export default async function App(
|
||||
<body f-client-nav>
|
||||
<Header link={link} />
|
||||
<section>
|
||||
<Partial name="body">
|
||||
<context.Component />
|
||||
</Partial>
|
||||
<context.Component />
|
||||
</section>
|
||||
<Footer />
|
||||
</body>
|
||||
|
||||
+5
-1
@@ -1,11 +1,15 @@
|
||||
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 = {
|
||||
async GET(_request, context) {
|
||||
const apps: Record<string, AppProperties> = {};
|
||||
|
||||
for await (const appDir of Deno.readDir("routes/(apps)")) {
|
||||
if (appDir.isFile) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
const properties: AppProperties = (await import(
|
||||
`./(apps)/${appDir.name}/(_props)/props.ts`
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
import { State } from "./_middleware.ts";
|
||||
import { State } from "$root/routes/_middleware.ts";
|
||||
import {
|
||||
parse,
|
||||
type RegularTagNode,
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
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";
|
||||
|
||||
const SERVICE = "https://localhost/";
|
||||
|
||||
Reference in New Issue
Block a user