Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/app-astro/src/components/SpaDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export default function SpaDetail() {
const id = new URLSearchParams(window.location.search).get('id')
export default function SpaDetail({ id }: { id?: string }) {
return <p id="detail-id">{id}</p>
}
2 changes: 1 addition & 1 deletion packages/app-astro/src/components/SpaPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function SpaPage() {
<td>{entry.id}</td>
<td>{entry.name}</td>
<td>
<a href={`/spa/detail?id=${entry.id}`}>View →</a>
<a href={`/spa/${entry.id}`}>View →</a>
</td>
</tr>
))}
Expand Down
2 changes: 1 addition & 1 deletion packages/app-astro/src/pages/mpa.astro
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const entries = await testData()
<td>{entry.id}</td>
<td>{entry.name}</td>
<td>
<a href={`/mpa/detail?id=${entry.id}`}>View →</a>
<a href={`/mpa/${entry.id}`}>View →</a>
</td>
</tr>
))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
const id = Astro.url.searchParams.get('id')
const { id } = Astro.params
---

<html lang="en">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
import SpaDetail from '../../components/SpaDetail'

const { id } = Astro.params
---

<html lang="en">
Expand All @@ -9,6 +11,6 @@ import SpaDetail from '../../components/SpaDetail'
<title>Astro SPA Detail</title>
</head>
<body>
<SpaDetail client:only="react" />
<SpaDetail client:only="react" id={id} />
</body>
</html>
9 changes: 9 additions & 0 deletions packages/app-next-js/app/mpa/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
interface Props {
params: Promise<{ id: string }>
}

export default async function MpaDetailPage({ params }: Props) {
const { id } = await params

return <p id="detail-id">{id}</p>
}
9 changes: 0 additions & 9 deletions packages/app-next-js/app/mpa/detail/page.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/app-next-js/app/mpa/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default async function MpaPage() {
<td>{entry.id}</td>
<td>{entry.name}</td>
<td>
<a href={`/mpa/detail?id=${entry.id}`}>View →</a>
<a href={`/mpa/${entry.id}`}>View →</a>
</td>
</tr>
))}
Expand Down
2 changes: 1 addition & 1 deletion packages/app-next-js/app/spa/SpaTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function SpaTable() {
<td>{entry.id}</td>
<td>{entry.name}</td>
<td>
<Link href={`/spa/detail?id=${entry.id}`}>View →</Link>
<Link href={`/spa/${entry.id}`}>View →</Link>
</td>
</tr>
))}
Expand Down
9 changes: 9 additions & 0 deletions packages/app-next-js/app/spa/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use client'

import { useParams } from 'next/navigation'

export default function SpaDetailPage() {
const params = useParams<{ id: string }>()

return <p id="detail-id">{params.id}</p>
}
19 changes: 0 additions & 19 deletions packages/app-next-js/app/spa/detail/page.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
const route = useRoute()
const id = Array.isArray(route.query.id) ? route.query.id[0] : route.query.id
const id = Array.isArray(route.params.id) ? route.params.id[0] : route.params.id
</script>

<template>
Expand Down
2 changes: 1 addition & 1 deletion packages/app-nuxt/app/pages/mpa/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const { data } = await useAsyncData(() => testData(), { deep: false })
<td>{{ entry.id }}</td>
<td>{{ entry.name }}</td>
<td>
<a :href="`/mpa/detail?id=${entry.id}`">View →</a>
<a :href="`/mpa/${entry.id}`">View →</a>
</td>
</tr>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
definePageMeta({ ssr: false })

const route = useRoute()
const id = Array.isArray(route.query.id) ? route.query.id[0] : route.query.id
const id = Array.isArray(route.params.id) ? route.params.id[0] : route.params.id
</script>

<template>
Expand Down
2 changes: 1 addition & 1 deletion packages/app-nuxt/app/pages/spa/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const entries: Entry[] = Array.from({ length: 1000 }, () => ({
<td>{{ entry.id }}</td>
<td>{{ entry.name }}</td>
<td>
<NuxtLink :to="`/spa/detail?id=${entry.id}`">View →</NuxtLink>
<NuxtLink :to="`/spa/${entry.id}`">View →</NuxtLink>
</td>
</tr>
</tbody>
Expand Down
4 changes: 2 additions & 2 deletions packages/app-react-router/app/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const isSpa = process.env.BUILD_MODE === 'spa'
export default [
...(isSpa ? [] : [index('routes/home.tsx')]),
route('/spa', 'routes/spa.tsx'),
route('/spa/detail', 'routes/spa.detail.tsx'),
route('/spa/:id', 'routes/spa.detail.tsx'),
...(isSpa
? []
: [
route('/mpa', 'routes/mpa.tsx'),
route('/mpa/detail', 'routes/mpa.detail.tsx'),
route('/mpa/:id', 'routes/mpa.detail.tsx'),
]),
] satisfies RouteConfig
5 changes: 2 additions & 3 deletions packages/app-react-router/app/routes/mpa.detail.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { Route } from './+types/mpa.detail'

export async function loader({ request }: Route.LoaderArgs) {
const url = new URL(request.url)
const id = url.searchParams.get('id')
export async function loader({ params }: Route.LoaderArgs) {
const id = params.id
return { id }
}

Expand Down
2 changes: 1 addition & 1 deletion packages/app-react-router/app/routes/mpa.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function MpaPage({ loaderData }: Route.ComponentProps) {
<td>{entry.id}</td>
<td>{entry.name}</td>
<td>
<a href={`/mpa/detail?id=${entry.id}`}>View →</a>
<a href={`/mpa/${entry.id}`}>View →</a>
</td>
</tr>
))}
Expand Down
5 changes: 2 additions & 3 deletions packages/app-react-router/app/routes/spa.detail.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useSearchParams } from 'react-router'
import { useParams } from 'react-router'

export default function SpaDetailPage() {
const [searchParams] = useSearchParams()
const id = searchParams.get('id')
const { id } = useParams()

return <p id="detail-id">{id}</p>
}
2 changes: 1 addition & 1 deletion packages/app-react-router/app/routes/spa.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function SpaPage() {
<td>{entry.id}</td>
<td>{entry.name}</td>
<td>
<Link to={`/spa/detail?id=${entry.id}`}>View →</Link>
<Link to={`/spa/${entry.id}`}>View →</Link>
</td>
</tr>
))}
Expand Down
7 changes: 7 additions & 0 deletions packages/app-solid-start/src/routes/mpa/[id].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { useParams } from '@solidjs/router'

export default function MpaDetailPage() {
const params = useParams()

return <p id="detail-id">{params.id}</p>
}
7 changes: 0 additions & 7 deletions packages/app-solid-start/src/routes/mpa/detail.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/app-solid-start/src/routes/mpa/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function MpaPage() {
<td>{entry.id}</td>
<td>{entry.name}</td>
<td>
<a href={`/mpa/detail?id=${entry.id}`}>View →</a>
<a href={`/mpa/${entry.id}`}>View →</a>
</td>
</tr>
)}
Expand Down
9 changes: 9 additions & 0 deletions packages/app-solid-start/src/routes/spa/[id].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { useParams } from '@solidjs/router'

export const ssr = false

export default function SpaDetailPage() {
const params = useParams()

return <p id="detail-id">{params.id}</p>
}
9 changes: 0 additions & 9 deletions packages/app-solid-start/src/routes/spa/detail.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/app-solid-start/src/routes/spa/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function SpaPage() {
<td>{entry.id}</td>
<td>{entry.name}</td>
<td>
<A href={`/spa/detail?id=${entry.id}`}>View →</A>
<A href={`/spa/${entry.id}`}>View →</A>
</td>
</tr>
)}
Expand Down
2 changes: 1 addition & 1 deletion packages/app-sveltekit/src/routes/mpa/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<td>{entry.id}</td>
<td>{entry.name}</td>
<td>
<a href="/mpa/detail?id={entry.id}" data-sveltekit-reload>View →</a>
<a href="/mpa/{entry.id}" data-sveltekit-reload>View →</a>
</td>
</tr>
{/each}
Expand Down
5 changes: 5 additions & 0 deletions packages/app-sveltekit/src/routes/mpa/[id]/+page.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { PageServerLoad } from './$types'

export const load: PageServerLoad = ({ params }) => {
return { id: params.id }
}

This file was deleted.

2 changes: 1 addition & 1 deletion packages/app-sveltekit/src/routes/spa/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<tr>
<td>{entry.id}</td>
<td>{entry.name}</td>
<td><a href="/spa/detail?id={entry.id}">View →</a></td>
<td><a href="/spa/{entry.id}">View →</a></td>
</tr>
{/each}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { page } from '$app/state'

const id = page.url.searchParams.get('id')
const id = page.params.id
</script>

<p id="detail-id">{id}</p>
Loading
Loading