From 4d7d7e629d4134b807bdf2803e03362c4d7c2b28 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sun, 4 Feb 2024 00:04:01 +0000 Subject: [PATCH] header refactor --- src/app/[slug]/page.tsx | 2 + src/app/__tests__/layout.test.tsx | 2 +- src/app/actions.ts | 4 +- src/app/layout.tsx | 2 - src/app/page.tsx | 4 ++ src/components/Availability/index.tsx | 17 +----- src/components/Header/index.module.css | 1 + src/components/Header/index.test.tsx | 11 ++-- src/components/Header/index.tsx | 17 +++--- src/components/Location/index.tsx | 81 +++++++++----------------- src/components/Location/types.ts | 1 - src/styles/layout.module.css | 2 +- tests/__fixtures__/location.ts | 7 ++- tests/jest.setup.tsx | 6 -- 14 files changed, 61 insertions(+), 96 deletions(-) diff --git a/src/app/[slug]/page.tsx b/src/app/[slug]/page.tsx index ab31357..5c488a5 100644 --- a/src/app/[slug]/page.tsx +++ b/src/app/[slug]/page.tsx @@ -1,6 +1,7 @@ import { Metadata, ResolvingMetadata } from 'next' import { notFound } from 'next/navigation' import meta from '../../../_content/meta.json' +import Header from '../../components/Header' import Project from '../../components/Project' import ProjectNav from '../../components/ProjectNav' import { @@ -44,6 +45,7 @@ export default async function ProjectPage({ params }: Props) { return ( <> +
diff --git a/src/app/__tests__/layout.test.tsx b/src/app/__tests__/layout.test.tsx index 89ae579..b2d0184 100644 --- a/src/app/__tests__/layout.test.tsx +++ b/src/app/__tests__/layout.test.tsx @@ -19,6 +19,6 @@ describe('app: /layout', () => { it('renders correctly', async () => { render(Hello) - await screen.findByText(dataLocation.now.city) + await screen.findByText('Hello') }) }) diff --git a/src/app/actions.ts b/src/app/actions.ts index c76f12f..b842ac3 100644 --- a/src/app/actions.ts +++ b/src/app/actions.ts @@ -5,7 +5,9 @@ import { GiphyFetch } from '@giphy/js-fetch-api' export async function getLocation() { try { - const response = await fetch('https://location.kretschmann.io') + const response = await fetch('https://location.kretschmann.io', { + cache: 'no-store' + }) if (!response.ok) throw new Error('Network response for location was not ok.') diff --git a/src/app/layout.tsx b/src/app/layout.tsx index b6b73cf..5194f3c 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -3,7 +3,6 @@ import { Metadata, Viewport } from 'next' import Script from 'next/script' import meta from '../../_content/meta.json' import Footer from '../components/Footer' -import Header from '../components/Header' import HostnameCheck from '../components/HostnameCheck' import ThemeSwitch from '../components/ThemeSwitch' import { UMAMI_SCRIPT_URL, UMAMI_WEBSITE_ID } from '../lib/umami' @@ -66,7 +65,6 @@ export default function RootLayout({ children }: { children: ReactNode }) { -
{children}