feat: upgrade to app directory

This commit is contained in:
Bart Stefanski 2023-11-25 23:30:41 +01:00
parent fb4a7cda23
commit 38fc128d62
10 changed files with 61 additions and 68 deletions

View file

@ -1,29 +0,0 @@
import { render } from "@testing-library/react"
import { AppProps } from "next/app"
import MyApp from "./_app"
// Mock router object with required properties
const router = {
basePath: "",
pathname: "/",
query: {},
asPath: "/",
}
describe("MyApp", () => {
it("should render a component with page props", () => {
const props: AppProps = {
Component: ({ title }) => (
<>
<div>Test Component</div>
<div>{title}</div>
</>
),
pageProps: { title: "Test Page" },
router: router as never, // Include mocked router object in props
}
const { getByText } = render(<MyApp {...props} />)
expect(getByText("Test Component")).toBeInTheDocument()
expect(getByText("Test Page")).toBeInTheDocument()
})
})

View file

@ -1,9 +0,0 @@
import "../styles/tailwind.css"
import { AppProps } from "next/app"
function MyApp({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}
export default MyApp

View file

@ -1,5 +0,0 @@
import { NextApiRequest, NextApiResponse } from "next"
export default function handler(req: NextApiRequest, res: NextApiResponse) {
res.status(200).json({ status: "ok" })
}

View file

@ -1,75 +0,0 @@
import { GetServerSidePropsContext } from "next"
import Head from "next/head"
import { Button } from "components/Button/Button"
import { LP_GRID_ITEMS } from "../lp-items"
export default function Web() {
return (
<>
<Head>
<meta property="og:url" content="https://next-enterprise.vercel.app/" />
<meta
property="og:image"
content="https://raw.githubusercontent.com/Blazity/next-enterprise/main/project-logo.png"
/>
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta name="twitter:card" content="summary_large_image" />
<title>Next.js Enterprise Boilerplate</title>
</Head>
<section className="bg-white dark:bg-gray-900">
<div className="mx-auto grid max-w-screen-xl px-4 py-8 text-center lg:py-16">
<div className="mx-auto place-self-center">
<h1 className="mb-4 max-w-2xl text-4xl font-extrabold leading-none tracking-tight dark:text-white md:text-5xl xl:text-6xl">
Next.js Enterprise Boilerplate
</h1>
<p className="mb-6 max-w-2xl font-light text-gray-500 dark:text-gray-400 md:text-lg lg:mb-8 lg:text-xl">
Jumpstart your enterprise project with our feature-packed, high-performance Next.js boilerplate!
Experience rapid UI development, AI-powered code reviews, and an extensive suite of tools for a smooth and
enjoyable development process.
</p>
<Button href="https://github.com/Blazity/next-enterprise" className="mr-3">
Get started
</Button>
<Button
href="https://vercel.com/new/git/external?repository-url=https://github.com/Blazity/next-enterprise"
intent="secondary"
>
Deploy Now
</Button>
</div>
</div>
</section>
<section className="bg-white dark:bg-gray-900">
<div className="mx-auto max-w-screen-xl px-4 py-8 sm:py-16 lg:px-6">
<div className="justify-center space-y-8 md:grid md:grid-cols-2 md:gap-12 md:space-y-0 lg:grid-cols-3">
{LP_GRID_ITEMS.map((singleItem) => (
<div key={singleItem.title} className="flex flex-col items-center justify-center text-center">
<div className="mb-4 flex h-10 w-10 items-center justify-center rounded-full bg-primary-100 p-1.5 text-blue-700 dark:bg-primary-900 lg:h-12 lg:w-12">
{singleItem.icon}
</div>
<h3 className="mb-2 text-xl font-bold dark:text-white">{singleItem.title}</h3>
<p className="text-gray-500 dark:text-gray-400">{singleItem.description}</p>
</div>
))}
</div>
</div>
</section>
</>
)
}
export async function getServerSideProps({ req, res }: GetServerSidePropsContext) {
if (req.headers?.host?.includes("next-enterprise.vercel.app")) {
return {
redirect: {
destination: "https://blazity.com/open-source/nextjs-enterprise-boilerplate",
permanent: true,
},
}
}
return {
props: {},
}
}