From fb6f86c5637e3be590f6340675c895c72fe770b2 Mon Sep 17 00:00:00 2001 From: ruucm Date: Mon, 26 Feb 2024 00:49:35 -0800 Subject: [PATCH] app router structure support --- app/[...all]/page.tsx | 13 +++++++++++ pages/_app.tsx => app/layout.tsx | 35 ++++++++++++++++++------------ pages/[...all].tsx => app/page.tsx | 4 ++-- components/AppShell.tsx | 1 + pages/index.tsx | 9 -------- 5 files changed, 37 insertions(+), 25 deletions(-) create mode 100644 app/[...all]/page.tsx rename pages/_app.tsx => app/layout.tsx (69%) rename pages/[...all].tsx => app/page.tsx (79%) delete mode 100644 pages/index.tsx diff --git a/app/[...all]/page.tsx b/app/[...all]/page.tsx new file mode 100644 index 0000000..76c6ba9 --- /dev/null +++ b/app/[...all]/page.tsx @@ -0,0 +1,13 @@ +import dynamic from 'next/dynamic'; + +const App = dynamic(() => import('../../components/AppShell'), { + ssr: false, +}); + +export function generateStaticParams() { + return [{ all: ['tabs', 'feed'] }] +} + +export default function Page() { + return ; +} \ No newline at end of file diff --git a/pages/_app.tsx b/app/layout.tsx similarity index 69% rename from pages/_app.tsx rename to app/layout.tsx index 7faff10..8b4a936 100644 --- a/pages/_app.tsx +++ b/app/layout.tsx @@ -1,7 +1,5 @@ -import Head from 'next/head'; +import type { Metadata, Viewport } from "next"; import Script from 'next/script'; -import { AppProps } from 'next/app' -import { setupIonicReact } from '@ionic/react'; import 'tailwindcss/tailwind.css'; /* Core CSS required for Ionic components to work properly */ @@ -23,23 +21,32 @@ import '@ionic/react/css/display.css'; import '../styles/global.css'; import '../styles/variables.css'; -function MyApp({ Component, pageProps }: AppProps) { +export const metadata: Metadata = { + title: "Create Next App", + description: "Generated by create next app", +}; + +export const viewport: Viewport = { + initialScale: 1, + width: 'device-width', + viewportFit: 'cover' +} + +export default function RootLayout({ + children, +}: Readonly<{ + children: React.ReactNode; +}>) { return ( - <> - - - - + - + {children} + ); } -export default MyApp; + diff --git a/pages/[...all].tsx b/app/page.tsx similarity index 79% rename from pages/[...all].tsx rename to app/page.tsx index 9b74aa5..a46946c 100644 --- a/pages/[...all].tsx +++ b/app/page.tsx @@ -4,6 +4,6 @@ const App = dynamic(() => import('../components/AppShell'), { ssr: false, }); -export default function Index() { +export default function Page() { return ; -} +} \ No newline at end of file diff --git a/components/AppShell.tsx b/components/AppShell.tsx index 2fa58ad..b8d252d 100644 --- a/components/AppShell.tsx +++ b/components/AppShell.tsx @@ -1,3 +1,4 @@ +'use client' import { IonApp, IonLabel, IonRouterOutlet, setupIonicReact, IonTabs, IonTabBar, IonTabButton, IonIcon } from '@ionic/react'; import { cog, flash, list } from 'ionicons/icons'; import { StatusBar, Style } from '@capacitor/status-bar'; diff --git a/pages/index.tsx b/pages/index.tsx deleted file mode 100644 index 9b74aa5..0000000 --- a/pages/index.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import dynamic from 'next/dynamic'; - -const App = dynamic(() => import('../components/AppShell'), { - ssr: false, -}); - -export default function Index() { - return ; -}