manifest.json
新增或產生一個 manifest.(json|webmanifest)
檔案,其符合 Web Manifest 規範 在 app
目錄的根目錄中,以提供關於你的網頁應用程式的資訊給瀏覽器。
靜態 Manifest 檔案
app/manifest.json | app/manifest.webmanifest
{
"name": "My Next.js Application",
"short_name": "Next.js App",
"description": "An application built with Next.js",
"start_url": "/"
// ...
}
產生 Manifest 檔案
新增一個 manifest.js
或 manifest.ts
檔案,其回傳一個 Manifest
物件。
app/manifest.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',
},
],
}
}
Manifest 物件
Manifest 物件包含大量的選項,這些選項可能會因為新的網路標準而更新。關於所有當前選項的資訊,請參考你在程式碼編輯器中使用的 MetadataRoute.Manifest
類型 (如果你使用 TypeScript) 或查看 MDN 文件。
這有幫助嗎?