Next.js: metadati
In Next.js, possiamo modificare la sezione head di ciascuna pagina di reazione molto facilmente con l'aiuto di <Head> reagire componente che è integrato.
Aggiorniamo il progetto nextjs utilizzato nel capitolo Pages .
Aggiorna index.js come segue:
import Link from 'next/link'
import Head from 'next/head'
function HomePage() {
   return (
      <>
         <Head>
            <title>Welcome to Next.js!</title>
         </Head>
         <div>Welcome to Next.js!</div>
         <Link href="/posts/first"><a>First Post</a></Link>
         <br/>
         <img src="/logo.png" alt="TutorialsPoint Logo" />
      </>	    
   )
}
export default HomePage 
    Aggiorna first.js come segue:
import Link from 'next/link'
import Head from 'next/head'
export default function FirstPost() {
   return (
      <>
      <Head>
         <title>My First Post</title>
      </Head>
      <h1>My First Post</h1>
      <h2>
         <Link href="/">
            <a>Home</a>
         </Link>
      </h2>
      </>	  
   )
} 
    Qui abbiamo aggiunto un riferimento a logo.png nel file index.js.
Avvia Next.js Server
Eseguire il comando seguente per avviare il server -.
npm run dev
> [email protected] dev \Node\nextjs
> next
ready - started server on http://localhost:3000
event - compiled successfully
event - build page: /
wait  - compiling...
event - compiled successfully
event - build page: /next/dist/pages/_error
wait  - compiling...
event - compiled successfully 
    Verifica output
Apri localhost: 3000 in un browser e vedrai il seguente output.
 
    Fare clic sul collegamento Prima pagina e verificare il titolo modificato anche nella pagina Primo articolo.
                    