Skip to content

Commit

Permalink
♻️ Full front+backend migration from page router to app router.
Browse files Browse the repository at this point in the history
Followed nextjs official docs and best practices, backed by Playwright behavior regression test passing. Upated unit tests to reflect the new framework.
  • Loading branch information
KemingHe committed Dec 16, 2024
1 parent 5970ad6 commit 5b60e5b
Show file tree
Hide file tree
Showing 20 changed files with 494 additions and 316 deletions.
9 changes: 9 additions & 0 deletions app/[_owner]/[_name]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use client'

import { JSX } from 'react'

import MainRenderer from '@/src/components/mainRenderer'

export default function PreviewConfigPage(): JSX.Element {
return <MainRenderer />
}
File renamed without changes.
64 changes: 64 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { GoogleTagManager } from '@next/third-parties/google'
import type { Metadata, Viewport } from 'next'
import { Inter } from 'next/font/google'
import { JSX, type ReactNode } from 'react'
import { Toaster } from 'react-hot-toast'

import './globals.css'
import { version } from '@/common/helpers'
import Footer from '@/src/components/footer/footer'
import Header from '@/src/components/header/header'

const inter = Inter({
subsets: ['latin'],
})

export const metadata: Metadata = {
title: 'GitHub Socialify',
description: '💞 Socialify your project. 🌐 Share with the world!',
manifest: '/manifest.json',
openGraph: {
images: [
{
url: 'https://socialify.git.ci/wei/socialify/png?description=1&font=Raleway&issues=1&language=1&pattern=Charlie%20Brown&pulls=1&stargazers=1&theme=Light',
width: 1280,
height: 640,
type: 'image/png',
},
],
},
}

export const viewport: Viewport = {
themeColor: '#000000',
width: 'device-width',
// The following settings breaks mobile view, use with caution.
// initialScale: 1,
// maximumScale: 1,
// userScalable: false,
}

export default function RootLayout({
children,
}: Readonly<{ children: ReactNode }>): JSX.Element {
return (
<html lang="en">
<head>
<meta name="viewport" content="minimal-ui" />
<meta property="x-socialify-version" content={version} />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="apple-touch-icon" href="/assets/logo192.png" />
</head>
<body
className={`${inter.className} flex flex-col min-h-screen socialify-bg`}
>
<Header />
<main className="flex-1 flex">{children}</main>
<Footer />
<Toaster />
</body>
{/* Google Tag Manager, env only relevant/accessible to owner, use '' for dev. */}
<GoogleTagManager gtmId={process.env.GTM_ID || ''} />
</html>
)
}
6 changes: 3 additions & 3 deletions pages/404.tsx → app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { JSX } from 'react'

import ErrorContent from '@/src/components/error/error'

const HomePage = () => {
export default function NotFoundPage(): JSX.Element {
return (
<ErrorContent
code="404"
Expand All @@ -9,5 +11,3 @@ const HomePage = () => {
/>
)
}

export default HomePage
9 changes: 9 additions & 0 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use client'

import { JSX } from 'react'

import Repo from '@/src/components/repo/repo'

export default function HomePage(): JSX.Element {
return <Repo />
}
1 change: 0 additions & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
7 changes: 0 additions & 7 deletions pages/[_owner]/[_name].tsx

This file was deleted.

59 changes: 0 additions & 59 deletions pages/_app.tsx

This file was deleted.

7 changes: 0 additions & 7 deletions pages/index.tsx

This file was deleted.

Loading

0 comments on commit 5b60e5b

Please sign in to comment.