43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import type { BasePayload } from 'payload';
|
|
import type { I18nConfig } from '../i18n/index.js';
|
|
type ManifestIcon = {
|
|
sizes?: string;
|
|
src: string;
|
|
type?: string;
|
|
};
|
|
type Manifest = {
|
|
background_color?: string;
|
|
display: 'standalone';
|
|
icons: ManifestIcon[];
|
|
name?: string;
|
|
short_name?: string;
|
|
start_url: string;
|
|
theme_color?: string;
|
|
};
|
|
/**
|
|
* Builds a Next Web App Manifest from SiteSettings — replaces the ~50 lines of
|
|
* icon/mimeType parsing copied into every project's manifest.ts. Values come
|
|
* from the panel; missing fields are omitted (no hardcoded client data).
|
|
*
|
|
* // app/manifest.ts
|
|
* import { createManifestHandler } from '@intecion/ipal-kit'
|
|
* import { getCachedPayload } from '@/lib/content'
|
|
* import { i18nConfig } from '@/i18n.config'
|
|
* export default createManifestHandler({ getCachedPayload, config: i18nConfig })
|
|
*
|
|
* NOTE on Docker/CI builds: the whole DB access is wrapped in try/catch, so a
|
|
* `next build` with no reachable database (the usual Coolify/Docker case) gets
|
|
* a minimal valid manifest instead of a crash — same contract as
|
|
* generateStaticParams and the sitemap handler. Projects should still mark the
|
|
* route dynamic so Next doesn't prerender it at build time:
|
|
*
|
|
* // app/manifest.ts
|
|
* export const dynamic = 'force-dynamic'
|
|
*/
|
|
export declare function createManifestHandler(opts: {
|
|
config: I18nConfig;
|
|
getCachedPayload: () => Promise<BasePayload>;
|
|
settingsSlug?: string;
|
|
}): () => Promise<Manifest>;
|
|
export {};
|