Unverified Commit 36e8c2f4 authored by SamPhillemon's avatar SamPhillemon Committed by GitHub

Examples: updated the example of head-elements to utilize the App Router (#67829)

This PR updates the head-elements example to use the App Router. Here
are the changes that have been made:

- Renamed the "pages" folder to "app" folder.
- Updated the file `index.tsx` to `page.tsx` to align with App Router
- Added the layout.tsx file as part of the App Router.

cc @samcx

---------
Co-authored-by: 's avatarsamcx <sam@vercel.com>
parent 01cdb26d
......@@ -2,7 +2,7 @@
For every page you can inject elements into the page head. This way you can add stylesheets, JS scripts, meta tags, a custom title or whatever you think is convenient to add inside the `<head>` of your page.
This example shows in `pages/index.tsx` how to add a title and a couple of meta tags.
This example shows in `app/page.tsx` how to add a title and a couple of meta tags.
## Deploy your own
......
export const metadata = {
title: "Next Js",
description: "Generated by Next.js",
};
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}
import Head from "next/head";
export const metadata = {
title: "This page has a title 🤔",
description: "Page description",
};
export default function Home() {
return (
<div>
<Head>
<title>This page has a title 🤔</title>
<meta charSet="utf-8" />
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
</Head>
<h1>This page has a title 🤔</h1>
</div>
);
......
......@@ -7,13 +7,13 @@
},
"dependencies": {
"next": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@types/node": "^18.11.5",
"@types/react": "^18.0.23",
"@types/react-dom": "^18.0.7",
"typescript": "^4.8.4"
"@types/node": "^20.14.11",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"typescript": "^5.5.3"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment