fix: redirects with partials (#2053)

This commit is contained in:
Marvin Hagemeister
2023-11-21 11:35:08 +01:00
committed by GitHub
parent ba3fa2c895
commit 27adeb7b14
7 changed files with 79 additions and 1 deletions
@@ -0,0 +1,15 @@
import { RouteConfig } from "$fresh/server.ts";
import { Partial } from "$fresh/runtime.ts";
export const config: RouteConfig = {
skipAppWrapper: true,
skipInheritedLayouts: true,
};
export default function Home() {
return (
<Partial name="slot-1">
<p class="status-updated">Updated content</p>
</Partial>
);
}
@@ -0,0 +1,20 @@
import { Partial } from "$fresh/runtime.ts";
export default function SlotDemo() {
return (
<div>
<div class="output">
<Partial name="slot-1">
<p class="status-default">Default content</p>
</Partial>
</div>
<a
class="update-link"
href="/redirected/injected"
f-partial="/redirected/redirect"
>
update
</a>
</div>
);
}
@@ -0,0 +1,10 @@
import { defineRoute } from "$fresh/src/server/defines.ts";
export default defineRoute(() => {
return new Response("", {
status: 302,
headers: {
Location: "/redirected",
},
});
});
@@ -0,0 +1,11 @@
import { Handler } from "$fresh/server.ts";
export const handler: Handler = (req) => {
return new Response(null, {
headers: {
...req.headers,
Location: "/redirected/handler",
},
status: 307,
});
};