Skip to content

Commit

Permalink
Migrate to react router
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdinandsalis committed Nov 25, 2024
1 parent 88e3e25 commit 5650a48
Show file tree
Hide file tree
Showing 46 changed files with 8,518 additions and 4,259 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules

/build
/server-build
.react-router/
.env
.cache
/test-results/
Expand Down
2 changes: 1 addition & 1 deletion app/components/back-to-top.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link } from '@remix-run/react'
import { Link } from 'react-router'
import { ChevronUpIcon } from 'lucide-react'

Check warning on line 2 in app/components/back-to-top.tsx

View workflow job for this annotation

GitHub Actions / ⬣ EsLint

`lucide-react` import should occur before import of `react-router`

export function BackToTop({ className }: { className?: string }) {
Expand Down
2 changes: 1 addition & 1 deletion app/components/error-boundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
isRouteErrorResponse,
useParams,
useRouteError,
} from '@remix-run/react'
} from 'react-router'
import { captureRemixErrorBoundaryError } from '@sentry/remix'

Check warning on line 7 in app/components/error-boundary.tsx

View workflow job for this annotation

GitHub Actions / ⬣ EsLint

`@sentry/remix` import should occur before import of `react-router`
import { getErrorMessage } from '#app/utils/misc.tsx'

Expand Down
2 changes: 1 addition & 1 deletion app/components/hydrated.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type PropsWithChildren , useEffect, useState } from 'react'
import { type PropsWithChildren, useEffect, useState } from 'react'

let isHydrating = true

Expand Down
4 changes: 2 additions & 2 deletions app/components/newsletter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useFetcher } from '@remix-run/react'
import { useFetcher } from 'react-router'
import { LoaderIcon } from 'lucide-react'

Check warning on line 2 in app/components/newsletter.tsx

View workflow job for this annotation

GitHub Actions / ⬣ EsLint

`lucide-react` import should occur before import of `react-router`
import { HoneypotInputs } from 'remix-utils/honeypot/react'
import { useSpinDelay } from 'spin-delay'
Expand All @@ -16,7 +16,7 @@ export function NewsletterForm() {
name="newsletter"
method="POST"
action="/resources/newsletter"
className="xl:p-8 grid max-w-xl rounded-md bg-card p-6 shadow-md"
className="grid max-w-xl rounded-md bg-card p-6 shadow-md xl:p-8"
key={JSON.stringify(fetcher.data)}
>
<HoneypotInputs />
Expand Down
2 changes: 1 addition & 1 deletion app/components/section-heading.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link } from '@remix-run/react'
import { Link } from 'react-router'

export function SectionHeading({
children,
Expand Down
16 changes: 8 additions & 8 deletions app/components/shell.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link, NavLink } from '@remix-run/react'
import { Link, NavLink } from 'react-router'
import {

Check warning on line 2 in app/components/shell.tsx

View workflow job for this annotation

GitHub Actions / ⬣ EsLint

`lucide-react` import should occur before import of `react-router`
ExternalLinkIcon,
Home,
Expand Down Expand Up @@ -28,28 +28,28 @@ export function Navigation() {
return (
<nav
aria-label="Global"
className="xl:flex-col xl:items-start xl:gap-0 flex flex-col divide-y divide-stone-100 overflow-hidden rounded-lg bg-card shadow-lg shadow-stone-200 md:flex-row md:items-center md:gap-2 md:divide-none md:bg-transparent md:shadow-none lg:gap-3"
className="flex flex-col divide-y divide-stone-100 overflow-hidden rounded-lg bg-card shadow-lg shadow-stone-200 md:flex-row md:items-center md:gap-2 md:divide-none md:bg-transparent md:shadow-none lg:gap-3 xl:flex-col xl:items-start xl:gap-0"
>
<NavLink
to="/"
prefetch="intent"
className={({ isActive }) =>
cn(
'xl:p-1 xl:aspect-auto xl:rounded-none group flex-none items-center px-3 py-2 font-condensed text-lg font-bold outline-none transition-colors hover:text-gray-900 focus:ring-2 focus:ring-inset focus:ring-primary/20 md:mr-1 md:aspect-square md:rounded-full md:p-3 lg:text-xl',
'group flex-none items-center px-3 py-2 font-condensed text-lg font-bold outline-none transition-colors hover:text-gray-900 focus:ring-2 focus:ring-inset focus:ring-primary/20 md:mr-1 md:aspect-square md:rounded-full md:p-3 lg:text-xl xl:aspect-auto xl:rounded-none xl:p-1',
'hover:text-primary',
{
'text-stone-900 ring-0': isActive,
'xl:after:content-none relative after:absolute after:bottom-[5px] after:left-1/2 after:-ml-5 after:h-[2px] after:w-10 after:bg-primary after:content-none md:after:content-[""]':
'relative after:absolute after:bottom-[5px] after:left-1/2 after:-ml-5 after:h-[2px] after:w-10 after:bg-primary after:content-none md:after:content-[""] xl:after:content-none':
isActive,
},
)
}
>
<Home
size={24}
className="xl:hidden order-1 hidden stroke-secondary md:block md:group-hover:scale-105"
className="order-1 hidden stroke-secondary md:block md:group-hover:scale-105 xl:hidden"
/>
<span className="xl:not-sr-only md:sr-only">Startseite</span>
<span className="md:sr-only xl:not-sr-only">Startseite</span>
</NavLink>
{navigation.main.map(item => (
<NavLink
Expand All @@ -58,11 +58,11 @@ export function Navigation() {
prefetch="intent"
className={({ isActive }) =>
cn(
'xl:p-1 px-3 py-2 font-condensed text-lg font-bold text-stone-800 outline-none ring-inset ring-card transition-colors focus:ring-2 focus:ring-primary/20 md:rounded-md md:px-1 md:py-2 lg:text-xl',
'px-3 py-2 font-condensed text-lg font-bold text-stone-800 outline-none ring-inset ring-card transition-colors focus:ring-2 focus:ring-primary/20 md:rounded-md md:px-1 md:py-2 lg:text-xl xl:p-1',
'hover:text-primary',
{
'text-stone-900 ring-0': isActive,
'xl:after:content-none relative after:absolute after:bottom-[5px] after:left-1/2 after:-ml-5 after:h-[2px] after:w-10 after:bg-primary after:content-none md:after:content-[""]':
'relative after:absolute after:bottom-[5px] after:left-1/2 after:-ml-5 after:h-[2px] after:w-10 after:bg-primary after:content-none md:after:content-[""] xl:after:content-none':
isActive,
},
)
Expand Down
2 changes: 1 addition & 1 deletion app/components/toc.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link } from '@remix-run/react'
import { Link } from 'react-router'
import { BookOpen } from 'lucide-react'

Check warning on line 2 in app/components/toc.tsx

View workflow job for this annotation

GitHub Actions / ⬣ EsLint

`lucide-react` import should occur before import of `react-router`
import { cn } from '#app/utils/misc.js'

Expand Down
2 changes: 1 addition & 1 deletion app/components/ui/divider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link } from '@remix-run/react'
import { Link } from 'react-router'
import { ChevronUpIcon } from 'lucide-react'

Check warning on line 2 in app/components/ui/divider.tsx

View workflow job for this annotation

GitHub Actions / ⬣ EsLint

`lucide-react` import should occur before import of `react-router`
import { cn } from '#app/utils/misc.js'

Expand Down
4 changes: 2 additions & 2 deletions app/entry.client.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RemixBrowser } from '@remix-run/react'
import { HydratedRouter } from 'react-router/dom'

Check warning on line 1 in app/entry.client.tsx

View workflow job for this annotation

GitHub Actions / ⬣ EsLint

`react-router/dom` import should occur after import of `react-dom/client`
import { startTransition } from 'react'
import { hydrateRoot } from 'react-dom/client'

Expand All @@ -11,5 +11,5 @@ if (ENV.MODE === 'production' && ENV.SENTRY_DSN) {
}

startTransition(() => {
hydrateRoot(document, <RemixBrowser />)
hydrateRoot(document, <HydratedRouter />)
})
15 changes: 9 additions & 6 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { PassThrough } from 'stream'

import {

Check warning on line 3 in app/entry.server.tsx

View workflow job for this annotation

GitHub Actions / ⬣ EsLint

`react-router` import should occur after import of `react-dom/server`
type ActionFunctionArgs,
type LoaderFunctionArgs,
createReadableStreamFromReadable,
type HandleDocumentRequestFunction,
} from '@remix-run/node'
import { RemixServer } from '@remix-run/react'
} from 'react-router'

Check warning on line 7 in app/entry.server.tsx

View workflow job for this annotation

GitHub Actions / ⬣ EsLint

'/home/runner/work/walz/walz/node_modules/react-router/dist/production/index.mjs' imported multiple times

import { createReadableStreamFromReadable } from '@react-router/node'
import { ServerRouter } from 'react-router'

Check warning on line 10 in app/entry.server.tsx

View workflow job for this annotation

GitHub Actions / ⬣ EsLint

`react-router` import should occur after import of `react-dom/server`
import * as Sentry from '@sentry/remix'
import chalk from 'chalk'
import { isbot } from 'isbot'
Expand All @@ -29,7 +31,8 @@ if (ENV.MODE === 'production' && ENV.SENTRY_DSN) {
type DocRequestArgs = Parameters<HandleDocumentRequestFunction>

export default async function handleRequest(...args: DocRequestArgs) {
const [request, responseStatusCode, responseHeaders, remixContext] = args
const [request, responseStatusCode, responseHeaders, reactRouterContext] =
args
const callbackName = isbot(request.headers.get('user-agent'))
? 'onAllReady'
: 'onShellReady'
Expand All @@ -39,9 +42,9 @@ export default async function handleRequest(...args: DocRequestArgs) {
const timings = makeTimings('render', 'renderToPipeableStream')

const { pipe, abort } = renderToPipeableStream(
<RemixServer
<ServerRouter
abortDelay={ABORT_DELAY}
context={remixContext}
context={reactRouterContext}
url={request.url}
/>,
{
Expand Down
6 changes: 3 additions & 3 deletions app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { type LoaderFunctionArgs } from '@remix-run/node'
import {
Link,
Links,
Expand All @@ -8,7 +7,7 @@ import {
ScrollRestoration,
useLoaderData,
useLocation,
} from '@remix-run/react'
} from 'react-router'
import { withSentry } from '@sentry/remix'
import { MenuIcon } from 'lucide-react'
import { HoneypotProvider } from 'remix-utils/honeypot/react'
Expand All @@ -25,6 +24,7 @@ import fontStyleSheetUrl from './styles/font.css?url'
import { getEnv } from './utils/env.server.ts'
import { honeypot } from './utils/honeypot.server.ts'
import { cn, getDomainUrl } from './utils/misc.tsx'
import { type Route } from '../.react-router/types/app/+types/root.ts'

export function links() {
return [
Expand All @@ -39,7 +39,7 @@ export function meta() {
return [{ title: 'Walz' }]
}

export async function loader({ request }: LoaderFunctionArgs) {
export async function loader({ request }: Route.LoaderArgs) {
return {
requestInfo: {
origin: getDomainUrl(request),
Expand Down
15 changes: 15 additions & 0 deletions app/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { type RouteConfig } from '@react-router/dev/routes'
import { remixRoutesOptionAdapter } from '@react-router/remix-routes-option-adapter'
import { flatRoutes } from 'remix-flat-routes'

export default remixRoutesOptionAdapter(defineRoutes =>
flatRoutes('routes', defineRoutes, {
ignoredRouteFiles: [
'.*',
'**/*.css',
'**/*.query.ts',
'**/*.test.{js,jsx,ts,tsx}',
'**/__*.*',
],
}),
) satisfies RouteConfig
2 changes: 1 addition & 1 deletion app/routes/$.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link, useLocation } from '@remix-run/react'
import { Link, useLocation } from 'react-router'
import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx'

export async function loader() {
Expand Down
10 changes: 2 additions & 8 deletions app/routes/_index/route.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link, useLoaderData } from '@remix-run/react'
import { Link, useLoaderData } from 'react-router'
import { getImageDimensions } from '@sanity/asset-utils'
import {
ArrowRight,
Expand Down Expand Up @@ -140,7 +140,6 @@ export default function Home() {
</article>
)}
</div>

<div className="grid grid-cols-subgrid gap-8 lg:col-span-2">
<section className="col-span-1 space-y-4">
<div>
Expand Down Expand Up @@ -193,7 +192,6 @@ export default function Home() {
</div>
</section>
</div>

<section className="grid gap-4 lg:col-span-2">
<h1 className="text-body-xs font-bold uppercase tracking-widest text-muted-foreground">
Beiträge
Expand Down Expand Up @@ -284,7 +282,6 @@ export default function Home() {
</div>
</div>
</section>

<section className="grid gap-8 lg:col-span-2">
<header className="py-4 md:py-8 lg:py-12">
<SectionHeading id="philosophie">Unsere Philosophie</SectionHeading>
Expand All @@ -304,7 +301,6 @@ export default function Home() {
})}
</div>
</section>

<section className="grid gap-8 lg:col-span-2">
<header className="py-4 md:py-8">
<SectionHeading id="testimonials">
Expand Down Expand Up @@ -333,7 +329,6 @@ export default function Home() {
</div>
</Carousel>
</section>

<section className="grid gap-8 lg:col-span-2">
<header className="py-4 md:py-8">
<SectionHeading id="faq">Häufige Fragen</SectionHeading>
Expand Down Expand Up @@ -396,7 +391,6 @@ export default function Home() {
</Link>
</div>
</section>

<section className="grid gap-8 lg:col-span-2">
<header className="py-4 md:py-8">
<SectionHeading id="kontakt">Anfahrt & Kontakt</SectionHeading>
Expand Down Expand Up @@ -492,7 +486,7 @@ function TestimonialCard({ idx, ...entry }: TestimonialCardProps) {
<p className="font-bold text-primary md:text-body-md">
{entry.name}
{' '}
<span className="font-greek align-super font-bold text-secondary">
<span className="align-super font-greek font-bold text-secondary">
{alphabetMap[entry.year?.letter ?? '']}
</span>{' '}
</p>
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_seo+/robots[.]txt.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { generateRobotsTxt } from '@nasa-gcn/remix-seo'
import { type LoaderFunctionArgs } from '@remix-run/node'
import { type LoaderFunctionArgs } from 'react-router'
import { getDomainUrl } from '#app/utils/misc.tsx'

export function loader({ request }: LoaderFunctionArgs) {
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_seo+/sitemap[.].xml.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { generateSitemap } from '@nasa-gcn/remix-seo'
import { type LoaderFunctionArgs, type ServerBuild } from '@remix-run/node'
import { type LoaderFunctionArgs, type ServerBuild } from 'react-router'
import { getDomainUrl } from '#app/utils/misc.tsx'

export async function loader({ request, context }: LoaderFunctionArgs) {
Expand Down
4 changes: 2 additions & 2 deletions app/routes/aktuelles/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
AccordionItem,
AccordionTrigger,
} from '@radix-ui/react-accordion'
import { type LoaderFunctionArgs } from '@remix-run/node'
import { Link, useLoaderData, useLocation } from '@remix-run/react'
import { type LoaderFunctionArgs } from 'react-router'
import { Link, useLoaderData, useLocation } from 'react-router'
import { loadQuery } from '@sanity/react-loader'
import {
ArrowRight,
Expand Down
4 changes: 2 additions & 2 deletions app/routes/aktuelles_.beitraege+/$slug.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PortableText } from '@portabletext/react'
import { type LoaderFunctionArgs } from '@remix-run/node'
import { type MetaArgs, useLoaderData } from '@remix-run/react'
import { type LoaderFunctionArgs } from 'react-router'
import { type MetaArgs, useLoaderData } from 'react-router'
import { getImageDimensions } from '@sanity/asset-utils'
import { loadQuery } from '@sanity/react-loader'
import { urlFor } from '#app/sanity/instance.ts'
Expand Down
2 changes: 1 addition & 1 deletion app/routes/aktuelles_.beitraege+/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useLoaderData } from '@remix-run/react'
import { useLoaderData } from 'react-router'
import { loadQuery } from '@sanity/react-loader'
import { PostItem } from '../aktuelles/route.tsx'
import { type QueryResult, beitraegeIndexQuery } from './_index.query.tsx'
Expand Down
2 changes: 1 addition & 1 deletion app/routes/aktuelles_.beitraege+/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link, Outlet } from '@remix-run/react'
import { Link, Outlet } from 'react-router'
import { ArrowLeft } from 'lucide-react'

export default function PostLayout() {
Expand Down
2 changes: 1 addition & 1 deletion app/routes/aufnahme+/__formular.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Form } from '@remix-run/react'
import { Form } from 'react-router'
import { Button } from '#app/components/ui/button.tsx'
import { Input } from '#app/components/ui/input.tsx'
import { Label } from '#app/components/ui/label.tsx'
Expand Down
2 changes: 1 addition & 1 deletion app/routes/aufnahme+/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useLoaderData } from '@remix-run/react'
import { useLoaderData } from 'react-router'
import { loadQuery } from '@sanity/react-loader'
import { DownloadIcon, ExternalLinkIcon, InfoIcon } from 'lucide-react'
import { Toc } from '#app/components/toc.tsx'
Expand Down
2 changes: 1 addition & 1 deletion app/routes/curriculum/route.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useLoaderData } from '@remix-run/react'
import { useLoaderData } from 'react-router'
import React from 'react'
import {
Carousel,
Expand Down
4 changes: 2 additions & 2 deletions app/routes/die-walz-kennenlernen.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type ActionFunctionArgs } from '@remix-run/node'
import { useFetcher } from '@remix-run/react'
import { type ActionFunctionArgs } from 'react-router'
import { useFetcher } from 'react-router'
import { getImage } from '@sanity/asset-utils'
import { HoneypotInputs } from 'remix-utils/honeypot/react'
import { Button } from '#app/components/ui/button.tsx'
Expand Down
2 changes: 1 addition & 1 deletion app/routes/haeufige-fragen.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link } from '@remix-run/react'
import { Link } from 'react-router'
import { BackToTop } from '#app/components/back-to-top.tsx'
import { Divider } from '#app/components/ui/divider.js'

Expand Down
4 changes: 2 additions & 2 deletions app/routes/jahrgaenge+/$year.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type LoaderFunctionArgs } from '@remix-run/node'
import { Link, type MetaArgs, useLoaderData } from '@remix-run/react'
import { type LoaderFunctionArgs } from 'react-router'
import { Link, type MetaArgs, useLoaderData } from 'react-router'
import { getImageDimensions } from '@sanity/asset-utils'
import { loadQuery } from '@sanity/react-loader'
import { BabyIcon, DownloadIcon } from 'lucide-react'
Expand Down
2 changes: 1 addition & 1 deletion app/routes/resources+/healthcheck.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// learn more: https://fly.io/docs/reference/configuration/#services-http_checks
import { type LoaderFunctionArgs } from '@remix-run/node'
import { type LoaderFunctionArgs } from 'react-router'

export async function loader({ request }: LoaderFunctionArgs) {
const host =
Expand Down
2 changes: 1 addition & 1 deletion app/routes/resources+/newsletter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ActionFunctionArgs } from '@remix-run/node'
import { type ActionFunctionArgs } from 'react-router'
import z from 'zod'
import * as Buttondown from '#app/utils/buttondown.ts'
import { checkHoneypot } from '#app/utils/honeypot.server.ts'
Expand Down
2 changes: 1 addition & 1 deletion app/routes/studio.$.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type LinksFunction } from '@remix-run/node'
import { type LinksFunction } from 'react-router'
import { Studio } from 'sanity'
import { Hydrated } from '#app/components/hydrated.tsx'
import studioCssUrl from '#app/styles/studio.css?url'
Expand Down
2 changes: 1 addition & 1 deletion app/routes/ueber-uns+/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ScrollArea from '@radix-ui/react-scroll-area'
import { Link, useLoaderData } from '@remix-run/react'
import { Link, useLoaderData } from 'react-router'
import { type SanityImageSource } from '@sanity/image-url/lib/types/types.js'
import { loadQuery } from '@sanity/react-loader'
import { ExternalLinkIcon, SmileIcon } from 'lucide-react'
Expand Down
Loading

0 comments on commit 5650a48

Please sign in to comment.