NextJS中文文档 - Manifest
在 app
目录的根目录中添加或生成符合 Web 清单规范 的 manifest.(json|webmanifest)
文件,为浏览器提供有关你的 Web 应用程序的信息。
静态清单文件
json
{
"name": "My Next.js Application",
"short_name": "Next.js App",
"description": "An application built with Next.js",
"start_url": "/"
// ...
}
1
2
3
4
5
6
7
2
3
4
5
6
7
生成清单文件
添加一个返回 Manifest
对象的 manifest.js
或 manifest.ts
文件。
ts
import type { MetadataRoute } from 'next'
export default function manifest(): MetadataRoute.Manifest {
return {
name: 'Next.js App',
short_name: 'Next.js App',
description: 'Next.js App',
start_url: '/',
display: 'standalone',
background_color: '#fff',
theme_color: '#fff',
icons: [
{
src: '/favicon.ico',
sizes: 'any',
type: 'image/x-icon',
},
],
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
js
export default function manifest() {
return {
name: 'Next.js App',
short_name: 'Next.js App',
description: 'Next.js App',
start_url: '/',
display: 'standalone',
background_color: '#fff',
theme_color: '#fff',
icons: [
{
src: '/favicon.ico',
sizes: 'any',
type: 'image/x-icon',
},
],
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Manifest 对象
清单对象包含广泛的选项列表,可能会因新的 Web 标准而更新。有关所有当前选项的信息,如果使用 TypeScript,请参考代码编辑器中的 MetadataRoute.Manifest
类型,或查看 MDN 文档。