Add Partials (#1824)
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { Partial } from "$fresh/runtime.ts";
|
||||
import CounterA from "../../islands/CounterA.tsx";
|
||||
import CounterB from "../../islands/CounterB.tsx";
|
||||
import PassThrough from "../../islands/PassThrough.tsx";
|
||||
|
||||
export default function SlotDemo() {
|
||||
return (
|
||||
<div>
|
||||
<Partial name="slot-1">
|
||||
<PassThrough>
|
||||
<div class="inner">
|
||||
<p>server content</p>
|
||||
<CounterA />
|
||||
</div>
|
||||
<hr />
|
||||
<PassThrough>
|
||||
<p>another pass through</p>
|
||||
<CounterB />
|
||||
</PassThrough>
|
||||
</PassThrough>
|
||||
</Partial>
|
||||
<hr />
|
||||
<p>
|
||||
<a
|
||||
class="update-link"
|
||||
href="/island_instance_nested/injected"
|
||||
fh-partial="/island_instance_nested/partial"
|
||||
>
|
||||
update
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<a
|
||||
class="replace-link"
|
||||
href="/island_instance_nested/injected"
|
||||
fh-partial="/island_instance_nested/replace"
|
||||
>
|
||||
replace
|
||||
</a>
|
||||
</p>
|
||||
<pre id="logs" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { defineRoute } from "$fresh/src/server/defines.ts";
|
||||
|
||||
export default defineRoute(() => {
|
||||
return new Response("", {
|
||||
status: 302,
|
||||
headers: {
|
||||
Location: "/island_instance_nested",
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
import { defineRoute } from "$fresh/src/server/defines.ts";
|
||||
import { RouteConfig } from "$fresh/server.ts";
|
||||
import { Partial } from "$fresh/runtime.ts";
|
||||
import CounterA from "../../islands/CounterA.tsx";
|
||||
import CounterB from "../../islands/CounterB.tsx";
|
||||
import PassThrough from "../../islands/PassThrough.tsx";
|
||||
|
||||
export const config: RouteConfig = {
|
||||
skipAppWrapper: true,
|
||||
skipInheritedLayouts: true,
|
||||
};
|
||||
|
||||
export default defineRoute((req, ctx) => {
|
||||
return (
|
||||
<Partial name="slot-1">
|
||||
<PassThrough>
|
||||
<div class="inner">
|
||||
<p class="status-a">updated server content</p>
|
||||
<CounterA />
|
||||
</div>
|
||||
<hr />
|
||||
<PassThrough>
|
||||
<p class="status-b">another pass through</p>
|
||||
<CounterB />
|
||||
</PassThrough>
|
||||
</PassThrough>
|
||||
</Partial>
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
import { defineRoute } from "$fresh/src/server/defines.ts";
|
||||
import { RouteConfig } from "$fresh/server.ts";
|
||||
import { Partial } from "$fresh/runtime.ts";
|
||||
import CounterA from "../../islands/CounterA.tsx";
|
||||
|
||||
export const config: RouteConfig = {
|
||||
skipAppWrapper: true,
|
||||
skipInheritedLayouts: true,
|
||||
};
|
||||
|
||||
export default defineRoute((req, ctx) => {
|
||||
return (
|
||||
<Partial name="slot-1">
|
||||
<CounterA />
|
||||
</Partial>
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user