Initial commit.
This commit is contained in:
13
src/pages/_app.tsx
Normal file
13
src/pages/_app.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import React from 'react';
|
||||
import { AppProps } from 'next/app';
|
||||
import './globals.scss';
|
||||
|
||||
const RootLayout:React.FC<AppProps> = ({ Component, pageProps }) => {
|
||||
return (
|
||||
<>
|
||||
<Component {...pageProps} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default RootLayout;
|
||||
16
src/pages/_document.tsx
Normal file
16
src/pages/_document.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Html, Head, Main, NextScript, DocumentProps } from 'next/document';
|
||||
|
||||
const RootDocument:React.FC<DocumentProps> = props => {
|
||||
return (
|
||||
<Html lang="en">
|
||||
<Head />
|
||||
|
||||
<body>
|
||||
<Main />
|
||||
<NextScript />
|
||||
</body>
|
||||
</Html>
|
||||
);
|
||||
};
|
||||
|
||||
export default RootDocument;
|
||||
21
src/pages/api/v1/graphql.ts
Normal file
21
src/pages/api/v1/graphql.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { typeDefs, resolvers } from "@/graphql/schema";
|
||||
import { ApolloServer } from "apollo-server-micro";
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
const apolloServer = new ApolloServer({ typeDefs, resolvers });
|
||||
|
||||
export const config = {
|
||||
api: {
|
||||
bodyParser: false,
|
||||
},
|
||||
};
|
||||
|
||||
const startServer = apolloServer.start();
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
) {
|
||||
await startServer;
|
||||
await apolloServer.createHandler({ path: '/api/v1/graphql' })(req, res);
|
||||
}
|
||||
40
src/pages/games/[id]/index.tsx
Normal file
40
src/pages/games/[id]/index.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import { GetServerSideProps, GetStaticPaths, GetStaticProps } from 'next';
|
||||
import Link from 'next/link';
|
||||
|
||||
type PageParams = {
|
||||
id:string;
|
||||
}
|
||||
|
||||
type PageProps = {
|
||||
id:string;
|
||||
}
|
||||
|
||||
export const getServerSideProps:GetServerSideProps<> = async ({ params }) => {
|
||||
const { id } = params as PageParams;
|
||||
|
||||
// if(id !== '0') {
|
||||
// return {
|
||||
// notFound: true
|
||||
// };
|
||||
// }
|
||||
|
||||
return {
|
||||
props: {
|
||||
id
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const Page:React.FC<PageProps> = ({ id }) => {
|
||||
return (
|
||||
<div>
|
||||
<h1>Viewing Game ID: {id}</h1>
|
||||
|
||||
<Link href={`/games/${id}/play`}>
|
||||
Play Game
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
||||
6
src/pages/games/[id]/play.module.scss
Normal file
6
src/pages/games/[id]/play.module.scss
Normal file
@@ -0,0 +1,6 @@
|
||||
.play {
|
||||
&__emulator {
|
||||
max-width: 320px;
|
||||
margin: auto;
|
||||
}
|
||||
}
|
||||
35
src/pages/games/[id]/play.tsx
Normal file
35
src/pages/games/[id]/play.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import { GetServerSideProps } from 'next';
|
||||
import { Emulator } from '@/components/Emulator';
|
||||
import styles from './play.module.scss';
|
||||
|
||||
type PageParams = {
|
||||
id:string;
|
||||
}
|
||||
|
||||
type PageProps = {
|
||||
id:string;
|
||||
}
|
||||
|
||||
export const getServerSideProps:GetServerSideProps = async ({ params }) => {
|
||||
const { id } = params as PageParams;
|
||||
|
||||
return {
|
||||
props: {
|
||||
id
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const Page:React.FC<PageProps> = ({ id }) => {
|
||||
return (
|
||||
<div className={styles.play}>
|
||||
<h1>Playing Game ID: {id}</h1>
|
||||
|
||||
<div className={styles.play__emulator}>
|
||||
<Emulator system='gbc' />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
||||
27
src/pages/games/index.tsx
Normal file
27
src/pages/games/index.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { GetServerSideProps, GetStaticPaths, GetStaticProps } from 'next';
|
||||
import Link from 'next/link';
|
||||
|
||||
type PageProps = {
|
||||
}
|
||||
|
||||
export const getServerSideProps:GetServerSideProps = async ({ params }) => {
|
||||
return {
|
||||
props: {
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const Page:React.FC<PageProps> = ({ }) => {
|
||||
return (
|
||||
<div>
|
||||
<h1>Games</h1>
|
||||
<div>
|
||||
<Link href="/games/0">
|
||||
Test Game
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
||||
2
src/pages/globals.scss
Normal file
2
src/pages/globals.scss
Normal file
@@ -0,0 +1,2 @@
|
||||
@use 'src/styles/elements/all';
|
||||
@use 'src/styles/elements/html';
|
||||
46
src/pages/index.tsx
Normal file
46
src/pages/index.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
import Head from 'next/head';
|
||||
import React from 'react';
|
||||
import { GetServerSideProps } from 'next';
|
||||
import { apiClientGet } from '@/lib/apiClient';
|
||||
import { ApolloQueryResult, gql } from '@apollo/client';
|
||||
import Link from 'next/link';
|
||||
|
||||
type PageData = {
|
||||
hello:string;
|
||||
}
|
||||
|
||||
type PageProps = ApolloQueryResult<PageData>
|
||||
|
||||
export const getServerSideProps:GetServerSideProps<PageProps> = async () => {
|
||||
const client = await apiClientGet();
|
||||
|
||||
const res = await client.query<PageData>({
|
||||
query: gql`
|
||||
query {
|
||||
hello
|
||||
}
|
||||
`
|
||||
});
|
||||
|
||||
return {
|
||||
props: res
|
||||
};
|
||||
};
|
||||
|
||||
const HomePage: React.FC<PageProps> = props => {
|
||||
return (
|
||||
<div className="homepage">
|
||||
<Head>
|
||||
<title>HomePlay, your personal video game library</title>
|
||||
</Head>
|
||||
|
||||
<Link href="/game/1/play">
|
||||
Play Game
|
||||
</Link>
|
||||
|
||||
{ props.data?.hello }
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default HomePage;
|
||||
Reference in New Issue
Block a user