Skip to content

Commit

Permalink
feat: restructure pages to Sanity folder
Browse files Browse the repository at this point in the history
  • Loading branch information
martapanc-resourcify committed Jul 8, 2023
1 parent 27188a5 commit 069d56d
Show file tree
Hide file tree
Showing 14 changed files with 110 additions and 178 deletions.
8 changes: 4 additions & 4 deletions sanity/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ export const apiVersion =
process.env.NEXT_PUBLIC_SANITY_API_VERSION || '2023-07-06';

export const dataset = assertValue(
process.env.SANITY_STUDIO_DATASET,
'Missing environment variable: SANITY_STUDIO_DATASET'
process.env.NEXT_PUBLIC_SANITY_DATASET,
'Missing environment variable: NEXT_PUBLIC_SANITY_DATASET'
);

export const projectId = assertValue(
process.env.SANITY_STUDIO_PROJECT_ID,
'Missing environment variable: SANITY_STUDIO_PROJECT_ID'
process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,
'Missing environment variable: NEXT_PUBLIC_SANITY_PROJECT_ID'
);

export const useCdn = false;
Expand Down
14 changes: 14 additions & 0 deletions src/app/(admin)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ReactNode } from 'react';

export const metadata = {
title: 'Next.js',
description: 'Generated by Next.js',
};

export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang='en'>
<body>{children}</body>
</html>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import { NextStudio } from 'next-sanity/studio';

import config from '../../../../sanity.config';
import config from '../../../../../sanity.config';

export default function StudioPage() {
return <NextStudio config={config} />;
Expand Down
19 changes: 19 additions & 0 deletions src/app/(public)/layout-client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use client';

import { ThemeProvider } from 'next-themes';
import type { PropsWithChildren } from 'react';

import Footer from '@/components/layout/Footer';
import Header from '@/components/layout/Header';

export default function LayoutClient({ children }: PropsWithChildren) {
return (
<ThemeProvider attribute='class' defaultTheme='light' enableSystem={false}>
<Header />

<main id='content'>{children}</main>

<Footer />
</ThemeProvider>
);
}
29 changes: 29 additions & 0 deletions src/app/(public)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ReactNode } from 'react';

import '@/styles/globals.css';

import LayoutClient from '@/app/(public)/layout-client';

export const metadata = {
title: 'Next.js',
description: 'Generated by Next.js',
};

export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang='en'>
<head>
<title>MartaCodes.it</title>
<link
rel='icon'
type='image/png'
sizes='32x32'
href='/favicon/favicon.ico'
/>
</head>
<body>
<LayoutClient>{children}</LayoutClient>
</body>
</html>
);
}
19 changes: 19 additions & 0 deletions src/app/(public)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as React from 'react';

import Seo from '@/components/Seo';

const HomePage = async () => {
return (
<main>
<Seo templateTitle='Home' />

<section className='dark:bg-dark min-h-main bg-white'>
<div className='layout relative flex flex-col items-center justify-center py-12 text-center'>
Homepage :)
</div>
</section>
</main>
);
};

export default HomePage;
10 changes: 6 additions & 4 deletions src/components/Seo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use client';

import Head from 'next/head';
import { useRouter } from 'next/router';
// import { useRouter } from 'next/navigation';

const defaultMeta = {
title: 'Marta codes it!',
Expand All @@ -21,7 +23,7 @@ type SeoProps = {
} & Partial<typeof defaultMeta>;

export default function Seo(props: SeoProps) {
const router = useRouter();
// const navigation = useRouter();
const meta = {
...defaultMeta,
...props,
Expand All @@ -45,8 +47,8 @@ export default function Seo(props: SeoProps) {
<title>{meta.title}</title>
<meta name='robots' content={meta.robots} />
<meta content={meta.description} name='description' />
<meta property='og:url' content={`${meta.url}${router.asPath}`} />
<link rel='canonical' href={`${meta.url}${router.asPath}`} />
{/*<meta property='og:url' content={`${meta.url}${navigation.asPath}`} />*/}
{/*<link rel='canonical' href={`${meta.url}${navigation.asPath}`} />*/}
{/* Open Graph */}
<meta property='og:type' content={meta.type} />
<meta property='og:site_name' content={meta.siteName} />
Expand Down
2 changes: 0 additions & 2 deletions src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ export const links = [
{ href: '/contact', label: 'Contact' },
];

//TODO: Menu style

export default function Header() {
const { theme } = useTheme();
const [isOpen, setIsOpen] = useState(false);
Expand Down
16 changes: 0 additions & 16 deletions src/components/layout/Layout.tsx

This file was deleted.

36 changes: 14 additions & 22 deletions src/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
import * as React from 'react';
import { RiAlarmWarningFill } from 'react-icons/ri';

import Layout from '@/components/layout/Layout';
import ArrowLink from '@/components/links/ArrowLink';
import Seo from '@/components/Seo';
import '@/styles/globals.css';

import UnstyledLink from '@/components/links/UnstyledLink';

export default function NotFoundPage() {
return (
<Layout>
<Seo templateTitle='Not Found' />

<main>
<section className='bg-white'>
<div className='layout flex min-h-screen flex-col items-center justify-center text-center text-black'>
<RiAlarmWarningFill
size={60}
className='drop-shadow-glow animate-flicker text-red-500'
/>
<h1 className='mt-8 text-4xl md:text-6xl'>Page Not Found</h1>
<ArrowLink className='mt-4 md:text-lg' href='/'>
Back to Home
</ArrowLink>
</div>
</section>
</main>
</Layout>
<>
<div className='layout min-h-no-header flex flex-col items-center justify-center text-center dark:text-white'>
<h1 className='mt-8'>Page Not Found</h1>
<UnstyledLink
href='/'
className='animated-underline dark:animated-underline mt-4 rounded-sm font-medium text-slate-950 dark:text-blue-50'
>
Back to Home
</UnstyledLink>
</div>
</>
);
}
19 changes: 0 additions & 19 deletions src/pages/_app.tsx

This file was deleted.

21 changes: 0 additions & 21 deletions src/pages/_document.tsx

This file was deleted.

89 changes: 0 additions & 89 deletions src/pages/index.tsx

This file was deleted.

4 changes: 4 additions & 0 deletions src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@
.min-h-main {
@apply min-h-[calc(100vh-56px)];
}

.min-h-no-header {
@apply min-h-[calc(100vh-120px)];
}
}

@layer utilities {
Expand Down

0 comments on commit 069d56d

Please sign in to comment.