-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: detailed test cases for server- and client navigation cases
- Loading branch information
Showing
7 changed files
with
195 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Link } from 'waku'; | ||
|
||
export default function NotFound() { | ||
return ( | ||
<div> | ||
<h1>Custom not found</h1> | ||
<p> | ||
<Link to="/">Back</Link> | ||
</p> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,12 @@ | ||
import { Link } from 'waku'; | ||
|
||
const Page = () => ( | ||
<div> | ||
<h1>Existing page</h1> | ||
<p> | ||
<Link to="/">Back</Link> | ||
</p> | ||
</div> | ||
); | ||
|
||
export const getConfig = async () => { | ||
return { | ||
render: 'dynamic', | ||
}; | ||
}; | ||
|
||
export default Page; | ||
export default function Exists() { | ||
return ( | ||
<div> | ||
<h1>Existing page</h1> | ||
<p> | ||
<Link to="/">Back</Link> | ||
</p> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
import { Link } from 'waku'; | ||
|
||
const Page = () => ( | ||
<div> | ||
<h1>Index</h1> | ||
<p> | ||
<Link to="/exists">Existing page</Link> | ||
</p> | ||
<p> | ||
<Link to="/broken">Broken link</Link> | ||
</p> | ||
</div> | ||
); | ||
|
||
export const getConfig = async () => { | ||
return { | ||
render: 'dynamic', | ||
}; | ||
}; | ||
|
||
export default Page; | ||
export default function Index() { | ||
return ( | ||
<div> | ||
<h1>Index</h1> | ||
<p> | ||
<Link to="/exists">Existing page</Link> | ||
</p> | ||
<p> | ||
<Link to="/broken">Broken link</Link> | ||
</p> | ||
<p> | ||
<Link to="/redirect">Redirect</Link> | ||
</p> | ||
<p> | ||
<Link to="/broken-redirect">Broken redirect</Link> | ||
</p> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { Middleware } from 'waku/config'; | ||
|
||
const redirectsMiddleware: Middleware = () => async (ctx, next) => { | ||
switch (ctx.req.url.pathname) { | ||
case '/redirect': | ||
ctx.res.status = 302; | ||
ctx.res.headers = { | ||
Location: '/exists', | ||
}; | ||
break; | ||
case '/broken-redirect': | ||
ctx.res.status = 302; | ||
ctx.res.headers = { | ||
Location: '/broken', | ||
}; | ||
break; | ||
default: | ||
return await next(); | ||
} | ||
}; | ||
|
||
export default redirectsMiddleware; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** @type {import('waku/config').Config} */ | ||
export default { | ||
middleware: () => [ | ||
import('./src/redirects.js'), | ||
import('waku/middleware/dev-server'), | ||
import('waku/middleware/headers'), | ||
import('waku/middleware/rsc'), | ||
import('waku/middleware/ssr'), | ||
], | ||
}; |