rsnext/test/e2e/app-dir/metadata/app
Jiachi Liu a301eb6a9f
Viewport exports (#57302)
## Story Time

Metadata API introduced two exports `metadata` and `generateMetadata` to the pages and layouts under app router, as partial prerendering work is going on and people are desiring to render the metadata asynchronizly, this change will be the preparation for moving to the dynamic & asynchronized land. In short, if we can render the metadata asynchronizedly, it will benefit the performance of the initial page loading and client page transiation a lot. Any slow data fetching can be handled while the essential page "shell" is rendered. 

For meta tags, there're few ones will visually affect your web page, such as `<meta name="viewport">`, `<meta name="theme color">` and `<meta name="color-scheme">`, rendering them lately after the page frame is ready might bring flickering to the page such as revreting whole page's theme color or shaking due to viewport updates. Those meta are not majorly the "metadata" for SEO, but more for user experience when opening the page. If we're rendering everything as async meta tags, it won't be ideal due to the flickering on your web pages.

## Solution Preparation 

We'll want to render the meta tags separately to make sure the visual ones are rendered as blocking along with web page, and then the ones for SEO or bots can be flushed later by later, like a suspense boundary keeps emitting them into the head of html. 

We optionally picked up 3 meta tag "viewport", "theme-color" and "color-scheme" to be render first into the web page with html "shell", to guarantee the layout viewport and basic styling are rendered first.

This PR introduced two module export in the page and layout files: `viewport` and `generateViewport`, in order to separate the visual meta tags from the SEO metadata.

### API

```ts
// page.js | layout.js
export const viewport = {
  // viewport meta tag
  width: 'device-width',
  initialScale: 1,
  maximumScale: 1,
  interactiveWidget: 'resizes-visual',
  // visual meta tags
  colorScheme: 'dark',
  themeColor: { color: 'cyan', media: '(prefers-color-scheme: dark)' },
}
```

There's also a dynamic API like what we did for metadata API

```ts
// page.js | layout.js
export function generateViewport() {
   return { ... }
}
```

## Notice 

This PR won't get SEO metadata rendered asyncronizedly, instead it's a preparation for the later work in partial prerendering and async metadata. We'll encourage the Next.js community moving to the new metadata viewport API if you're customzing those 3 meta tags. Usually you don't have to change viewport itself, so mostly like only theme-color and color-scheme could relate to it.
2023-10-25 05:20:23 +00:00
..
alternates Fix canonical url for dynamic routes (#49512) 2023-05-09 16:31:06 -07:00
api Viewport exports (#57302) 2023-10-25 05:20:23 +00:00
app-links Support generateMetadata export (#45401)Co-authored-by: Tim Neutkens <tim@timneutkens.nl> 2023-02-01 12:54:39 +01:00
apple Support generateMetadata export (#45401)Co-authored-by: Tim Neutkens <tim@timneutkens.nl> 2023-02-01 12:54:39 +01:00
async Fix dynamic route not-found boundary matching (#53564) 2023-08-04 16:07:58 +00:00
basic Viewport exports (#57302) 2023-10-25 05:20:23 +00:00
basic-edge Viewport exports (#57302) 2023-10-25 05:20:23 +00:00
cache-deduping Support generateMetadata export (#45401)Co-authored-by: Tim Neutkens <tim@timneutkens.nl> 2023-02-01 12:54:39 +01:00
icons Fix icons metadata missing from layout (#52673) 2023-07-14 12:04:31 +00:00
metadata-base Support relative url for openGraph.url and itunes.appArgument (#51877) 2023-06-27 17:01:49 +00:00
opengraph Override file based images with social images property (#52416) 2023-07-10 09:09:01 +02:00
robots Update robots meta and add verification rendering (#45409) 2023-01-30 20:49:30 +00:00
title Support static file robots.txt and sitemap.xml as metadata route (#46963) 2023-03-09 11:10:18 -08:00
title-template skip hot reload sync event for applying hmr updates (#52270) 2023-07-05 17:06:11 -07:00
twitter Use summary_large_image as twitter card if images present by default (#53919) 2023-08-11 17:52:45 +00:00
type-checking Expose metadata types (#47630) 2023-03-29 11:16:47 +00:00
verification Update robots meta and add verification rendering (#45409) 2023-01-30 20:49:30 +00:00
viewport Viewport exports (#57302) 2023-10-25 05:20:23 +00:00
favicon.ico Support filebased metadata icon and apple touch icons (#45612) 2023-02-07 18:30:59 +01:00
icon.svg Fix missing favicon when other icon exist (#48311) 2023-04-12 21:07:47 +00:00
layout.tsx Support metadata exports for server components not-found (#52678) 2023-07-14 22:33:47 +00:00
manifest.webmanifest Support manifest.json static and dynamic route (#47240) 2023-03-17 12:11:34 -07:00
not-found.tsx Reland "Refine the not-found rendering process for app router" (#52985) 2023-07-21 10:09:30 -07:00
page.tsx Fix unexpected hoist meta tags by react in app dir (#46917) 2023-03-08 11:34:51 +00:00
robots.txt Support static file robots.txt and sitemap.xml as metadata route (#46963) 2023-03-09 11:10:18 -08:00
sitemap.xml Support static file robots.txt and sitemap.xml as metadata route (#46963) 2023-03-09 11:10:18 -08:00