feat: support route layouts via _layout.tsx (#1506)
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
This commit is contained in:
co-authored by
Marvin Hagemeister
parent
18857ea052
commit
1ed93cec88
@@ -0,0 +1,9 @@
|
||||
import { AppProps } from "$fresh/server.ts";
|
||||
|
||||
export default function App({ Component }: AppProps) {
|
||||
return (
|
||||
<div class="app">
|
||||
<Component />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { LayoutProps } from "$fresh/server.ts";
|
||||
|
||||
export default function RootLayout({ Component }: LayoutProps) {
|
||||
return (
|
||||
<div class="root-layout">
|
||||
<Component />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { h } from "preact";
|
||||
|
||||
export default function JsLayout({ Component }) {
|
||||
return h("div", { class: "js-layout" }, h(Component, null));
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { h } from "preact";
|
||||
|
||||
export default function JsPage() {
|
||||
return h("div", { class: "js-page" }, "/files/js");
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { h } from "preact";
|
||||
|
||||
export default function JsxLayout({ Component }) {
|
||||
return (
|
||||
<div class="jsx-layout">
|
||||
<Component />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function JsxPage() {
|
||||
return <div class="jsx-page">/files/jsx page</div>;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { h } from "preact";
|
||||
import { LayoutProps } from "$fresh/server.ts";
|
||||
|
||||
export default function TsLayout({ Component }: LayoutProps) {
|
||||
return h("div", { class: "ts-layout" }, h(Component, null));
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { h } from "preact";
|
||||
|
||||
export default function TsPage() {
|
||||
return h("div", { class: "ts-page" }, "/files/ts");
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { h } from "preact";
|
||||
import { LayoutProps } from "$fresh/server.ts";
|
||||
|
||||
export default function TsxLayout({ Component }: LayoutProps) {
|
||||
return (
|
||||
<div class="tsx-layout">
|
||||
<Component />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function TsxPage() {
|
||||
return <div class="tsx-page">/files/tsx page</div>;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { LayoutProps } from "$fresh/server.ts";
|
||||
|
||||
export default function FooLayout({ Component }: LayoutProps) {
|
||||
return (
|
||||
<div class="foo-layout">
|
||||
<Component />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export default function BarPage() {
|
||||
return (
|
||||
<div class="bar-page">
|
||||
/foo/bar page
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export default function FooPage() {
|
||||
return (
|
||||
<div class="foo-page">
|
||||
/foo index page
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export default function Home() {
|
||||
return (
|
||||
<div class="home-page">
|
||||
Home
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export default function OtherPage() {
|
||||
return (
|
||||
<div class="other-page">
|
||||
/other
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { LayoutProps } from "$fresh/server.ts";
|
||||
|
||||
export default function SubLayout({ Component }: LayoutProps) {
|
||||
return (
|
||||
<div class="sub-layout">
|
||||
<Component />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export default function SubPage() {
|
||||
return (
|
||||
<div class="sub-page">
|
||||
/skip/sub page
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user