Skip to content

Commit

Permalink
Update remix to 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lpsinger committed Sep 18, 2023
1 parent d446360 commit 3b53bd3
Show file tree
Hide file tree
Showing 9 changed files with 1,522 additions and 2,987 deletions.
8 changes: 5 additions & 3 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* For more information, see https://remix.run/file-conventions/entry.server
*/
import type { AppLoadContext, EntryContext } from '@remix-run/node'
import { Response } from '@remix-run/node'
import { createReadableStreamFromReadable } from '@remix-run/node'
import { RemixServer } from '@remix-run/react'
import isbot from 'isbot'
import { PassThrough } from 'node:stream'
Expand Down Expand Up @@ -59,11 +59,12 @@ function handleBotRequest(
onAllReady() {
shellRendered = true
const body = new PassThrough()
const stream = createReadableStreamFromReadable(body)

responseHeaders.set('Content-Type', 'text/html')

resolve(
new Response(body, {
new Response(stream, {
headers: responseHeaders,
status: responseStatusCode,
})
Expand Down Expand Up @@ -108,11 +109,12 @@ function handleBrowserRequest(
onShellReady() {
shellRendered = true
const body = new PassThrough()
const stream = createReadableStreamFromReadable(body)

responseHeaders.set('Content-Type', 'text/html')

resolve(
new Response(body, {
new Response(stream, {
headers: responseHeaders,
status: responseStatusCode,
})
Expand Down
2 changes: 1 addition & 1 deletion app/lib/schema-data.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function resolveRelativePath(

export type ExampleFile = {
name: string
content: object
content: any
}
export type GitContentDataResponse = {
name: string
Expand Down
4 changes: 2 additions & 2 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { cssBundleHref } from '@remix-run/css-bundle'
import type {
DataFunctionArgs,
LinksFunction,
V2_MetaFunction,
MetaFunction,
} from '@remix-run/node'
import {
Link,
Expand Down Expand Up @@ -98,7 +98,7 @@ export const handle: BreadcrumbHandle = {
breadcrumb: 'GCN',
}

export const meta: V2_MetaFunction<typeof loader> = ({ data }) => {
export const meta: MetaFunction<typeof loader> = ({ data }) => {
const result = [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width,initial-scale=1' },
Expand Down
22 changes: 8 additions & 14 deletions app/root/Title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,20 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
import type { AppData, SerializeFrom } from '@remix-run/node'
import {
type RouteMatch as RemixRouteMatch,
useMatches,
} from '@remix-run/react'
import type { SerializeFrom } from '@remix-run/node'
import { useMatches } from '@remix-run/react'
import type { UIMatch as UIMatchRR } from 'react-router'

// FIXME: https://github.com/remix-run/remix/pull/7333
type RouteMatch<T = AppData> = Omit<RemixRouteMatch, 'data'> & {
data: SerializeFrom<T>
}
type UIMatch<D = unknown> = UIMatchRR<SerializeFrom<D>, BreadcrumbHandle<D>>

export type BreadcrumbHandle<T = AppData> = {
breadcrumb?: string | ((match: RouteMatch<T>) => string | undefined)
export type BreadcrumbHandle<D = unknown> = {
breadcrumb?: string | ((match: UIMatch<D>) => string | undefined)
}

export function Title() {
const title = useMatches()
const title = (useMatches() as UIMatch[])
.map((match) => {
let breadcrumb = (match.handle as BreadcrumbHandle | undefined)
?.breadcrumb
let breadcrumb = match.handle?.breadcrumb
if (typeof breadcrumb === 'function') breadcrumb = breadcrumb(match)
return breadcrumb
})
Expand Down
5 changes: 2 additions & 3 deletions app/routes/_auth.post_logout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { SEOHandle } from '@balavishnuvj/remix-seo'
import type { LoaderArgs } from '@remix-run/node'
import { redirect } from '@remix-run/node'
import { type LoaderFunctionArgs, redirect } from '@remix-run/node'
import { Form, Link, useLoaderData } from '@remix-run/react'
import {
Button,
Expand All @@ -22,7 +21,7 @@ export const handle: SEOHandle = {
getSitemapEntries: () => null,
}

export async function loader({ request: { headers } }: LoaderArgs) {
export async function loader({ request: { headers } }: LoaderFunctionArgs) {
const session = await storage.getSession(headers.get('Cookie'))
const existingIdp = session.get('existingIdp')
if (session.id) await storage.destroySession(session)
Expand Down
Loading

0 comments on commit 3b53bd3

Please sign in to comment.