@flyo/nitro-next 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server.d.mts +81 -6
- package/dist/server.d.ts +81 -6
- package/dist/server.js +66 -7
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +62 -5
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/server.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
1
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
3
|
import { Metadata } from 'next';
|
|
3
|
-
import { Configuration, ConfigResponse, PagesApi, EntitiesApi, Page, Block } from '@flyo/nitro-typescript';
|
|
4
|
+
import { Configuration, ConfigResponse, PagesApi, EntitiesApi, Entity, Page, Block } from '@flyo/nitro-typescript';
|
|
4
5
|
|
|
5
6
|
declare const initNitro: ({ accessToken, lang, components, showMissingComponentAlert }: {
|
|
6
7
|
accessToken: string;
|
|
@@ -19,6 +20,18 @@ type RouteParams = {
|
|
|
19
20
|
slug?: string[];
|
|
20
21
|
}>;
|
|
21
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Generic route params type for entity routes
|
|
25
|
+
* Allows any param structure from Next.js app router
|
|
26
|
+
*/
|
|
27
|
+
type EntityRouteParams<T = any> = {
|
|
28
|
+
params: Promise<T>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Entity resolver function type
|
|
32
|
+
* Users provide this to resolve entities from their route params
|
|
33
|
+
*/
|
|
34
|
+
type EntityResolver<T = any> = (params: Promise<T>) => Promise<Entity>;
|
|
22
35
|
/**
|
|
23
36
|
* NitroPage component renders all blocks from a Flyo page
|
|
24
37
|
*/
|
|
@@ -47,10 +60,10 @@ declare function nitroPageRoute(props: RouteParams): Promise<react_jsx_runtime.J
|
|
|
47
60
|
* @example
|
|
48
61
|
* ```ts
|
|
49
62
|
* // app/[[...slug]]/page.tsx
|
|
50
|
-
* export {
|
|
63
|
+
* export { nitroPageGenerateMetadata as generateMetadata } from '@flyo/nitro-next/server';
|
|
51
64
|
* ```
|
|
52
65
|
*/
|
|
53
|
-
declare function
|
|
66
|
+
declare function nitroPageGenerateMetadata(props: RouteParams): Promise<Metadata>;
|
|
54
67
|
/**
|
|
55
68
|
* Generate static params for all Nitro pages
|
|
56
69
|
* Enables static site generation (SSG) for all pages
|
|
@@ -59,11 +72,73 @@ declare function nitroGenerateMetadata(props: RouteParams): Promise<Metadata>;
|
|
|
59
72
|
* @example
|
|
60
73
|
* ```ts
|
|
61
74
|
* // app/[[...slug]]/page.tsx
|
|
62
|
-
* export {
|
|
75
|
+
* export { nitroPageGenerateStaticParams as generateStaticParams } from '@flyo/nitro-next/server';
|
|
63
76
|
* ```
|
|
64
77
|
*/
|
|
65
|
-
declare function
|
|
78
|
+
declare function nitroPageGenerateStaticParams(): Promise<{
|
|
66
79
|
slug: string[] | undefined;
|
|
67
80
|
}[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Default entity route handler with custom resolver
|
|
83
|
+
* Flexible solution that works with any route param structure
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* // app/blog/[slug]/page.tsx
|
|
88
|
+
* const resolver = async (params: Promise<{ slug: string }>) => {
|
|
89
|
+
* const { slug } = await params;
|
|
90
|
+
* return getNitroEntities().entityBySlug({ slug, typeId: 123 });
|
|
91
|
+
* };
|
|
92
|
+
*
|
|
93
|
+
* export default (props) => nitroEntityRoute(props, {
|
|
94
|
+
* resolver,
|
|
95
|
+
* render: (entity) => <h1>{entity.entity?.entity_title}</h1>
|
|
96
|
+
* });
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* // app/items/[uniqueid]/page.tsx
|
|
102
|
+
* const resolver = async (params: Promise<{ uniqueid: string }>) => {
|
|
103
|
+
* const { uniqueid } = await params;
|
|
104
|
+
* return getNitroEntities().entityByUniqueid({ uniqueid });
|
|
105
|
+
* };
|
|
106
|
+
*
|
|
107
|
+
* export default (props) => nitroEntityRoute(props, { resolver });
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* // app/custom/[whatever]/page.tsx
|
|
113
|
+
* const resolver = async (params: Promise<{ whatever: string }>) => {
|
|
114
|
+
* const { whatever } = await params;
|
|
115
|
+
* return getNitroEntities().entityBySlug({ slug: whatever });
|
|
116
|
+
* };
|
|
117
|
+
*
|
|
118
|
+
* export default (props) => nitroEntityRoute(props, { resolver });
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
declare function nitroEntityRoute<T = any>(props: EntityRouteParams<T>, options: {
|
|
122
|
+
resolver: EntityResolver<T>;
|
|
123
|
+
render?: (entity: Entity) => React.ReactNode;
|
|
124
|
+
}): Promise<string | number | bigint | boolean | react_jsx_runtime.JSX.Element | Iterable<react.ReactNode> | null | undefined>;
|
|
125
|
+
/**
|
|
126
|
+
* Generate metadata for Nitro entities with custom resolver
|
|
127
|
+
* Works with any route param structure
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```ts
|
|
131
|
+
* // app/blog/[slug]/page.tsx
|
|
132
|
+
* const resolver = async (params: Promise<{ slug: string }>) => {
|
|
133
|
+
* const { slug } = await params;
|
|
134
|
+
* return getNitroEntities().entityBySlug({ slug, typeId: 123 });
|
|
135
|
+
* };
|
|
136
|
+
*
|
|
137
|
+
* export const generateMetadata = (props) => nitroEntityGenerateMetadata(props, { resolver });
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
declare function nitroEntityGenerateMetadata<T = any>(props: EntityRouteParams<T>, options: {
|
|
141
|
+
resolver: EntityResolver<T>;
|
|
142
|
+
}): Promise<Metadata>;
|
|
68
143
|
|
|
69
|
-
export { NitroBlock, NitroPage, getNitroConfig, getNitroEntities, getNitroPages, initNitro,
|
|
144
|
+
export { type EntityResolver, NitroBlock, NitroPage, getNitroConfig, getNitroEntities, getNitroPages, initNitro, nitroEntityGenerateMetadata, nitroEntityRoute, nitroPageGenerateMetadata, nitroPageGenerateStaticParams, nitroPageRoute };
|
package/dist/server.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
1
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
3
|
import { Metadata } from 'next';
|
|
3
|
-
import { Configuration, ConfigResponse, PagesApi, EntitiesApi, Page, Block } from '@flyo/nitro-typescript';
|
|
4
|
+
import { Configuration, ConfigResponse, PagesApi, EntitiesApi, Entity, Page, Block } from '@flyo/nitro-typescript';
|
|
4
5
|
|
|
5
6
|
declare const initNitro: ({ accessToken, lang, components, showMissingComponentAlert }: {
|
|
6
7
|
accessToken: string;
|
|
@@ -19,6 +20,18 @@ type RouteParams = {
|
|
|
19
20
|
slug?: string[];
|
|
20
21
|
}>;
|
|
21
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Generic route params type for entity routes
|
|
25
|
+
* Allows any param structure from Next.js app router
|
|
26
|
+
*/
|
|
27
|
+
type EntityRouteParams<T = any> = {
|
|
28
|
+
params: Promise<T>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Entity resolver function type
|
|
32
|
+
* Users provide this to resolve entities from their route params
|
|
33
|
+
*/
|
|
34
|
+
type EntityResolver<T = any> = (params: Promise<T>) => Promise<Entity>;
|
|
22
35
|
/**
|
|
23
36
|
* NitroPage component renders all blocks from a Flyo page
|
|
24
37
|
*/
|
|
@@ -47,10 +60,10 @@ declare function nitroPageRoute(props: RouteParams): Promise<react_jsx_runtime.J
|
|
|
47
60
|
* @example
|
|
48
61
|
* ```ts
|
|
49
62
|
* // app/[[...slug]]/page.tsx
|
|
50
|
-
* export {
|
|
63
|
+
* export { nitroPageGenerateMetadata as generateMetadata } from '@flyo/nitro-next/server';
|
|
51
64
|
* ```
|
|
52
65
|
*/
|
|
53
|
-
declare function
|
|
66
|
+
declare function nitroPageGenerateMetadata(props: RouteParams): Promise<Metadata>;
|
|
54
67
|
/**
|
|
55
68
|
* Generate static params for all Nitro pages
|
|
56
69
|
* Enables static site generation (SSG) for all pages
|
|
@@ -59,11 +72,73 @@ declare function nitroGenerateMetadata(props: RouteParams): Promise<Metadata>;
|
|
|
59
72
|
* @example
|
|
60
73
|
* ```ts
|
|
61
74
|
* // app/[[...slug]]/page.tsx
|
|
62
|
-
* export {
|
|
75
|
+
* export { nitroPageGenerateStaticParams as generateStaticParams } from '@flyo/nitro-next/server';
|
|
63
76
|
* ```
|
|
64
77
|
*/
|
|
65
|
-
declare function
|
|
78
|
+
declare function nitroPageGenerateStaticParams(): Promise<{
|
|
66
79
|
slug: string[] | undefined;
|
|
67
80
|
}[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Default entity route handler with custom resolver
|
|
83
|
+
* Flexible solution that works with any route param structure
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* // app/blog/[slug]/page.tsx
|
|
88
|
+
* const resolver = async (params: Promise<{ slug: string }>) => {
|
|
89
|
+
* const { slug } = await params;
|
|
90
|
+
* return getNitroEntities().entityBySlug({ slug, typeId: 123 });
|
|
91
|
+
* };
|
|
92
|
+
*
|
|
93
|
+
* export default (props) => nitroEntityRoute(props, {
|
|
94
|
+
* resolver,
|
|
95
|
+
* render: (entity) => <h1>{entity.entity?.entity_title}</h1>
|
|
96
|
+
* });
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* // app/items/[uniqueid]/page.tsx
|
|
102
|
+
* const resolver = async (params: Promise<{ uniqueid: string }>) => {
|
|
103
|
+
* const { uniqueid } = await params;
|
|
104
|
+
* return getNitroEntities().entityByUniqueid({ uniqueid });
|
|
105
|
+
* };
|
|
106
|
+
*
|
|
107
|
+
* export default (props) => nitroEntityRoute(props, { resolver });
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* // app/custom/[whatever]/page.tsx
|
|
113
|
+
* const resolver = async (params: Promise<{ whatever: string }>) => {
|
|
114
|
+
* const { whatever } = await params;
|
|
115
|
+
* return getNitroEntities().entityBySlug({ slug: whatever });
|
|
116
|
+
* };
|
|
117
|
+
*
|
|
118
|
+
* export default (props) => nitroEntityRoute(props, { resolver });
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
declare function nitroEntityRoute<T = any>(props: EntityRouteParams<T>, options: {
|
|
122
|
+
resolver: EntityResolver<T>;
|
|
123
|
+
render?: (entity: Entity) => React.ReactNode;
|
|
124
|
+
}): Promise<string | number | bigint | boolean | react_jsx_runtime.JSX.Element | Iterable<react.ReactNode> | null | undefined>;
|
|
125
|
+
/**
|
|
126
|
+
* Generate metadata for Nitro entities with custom resolver
|
|
127
|
+
* Works with any route param structure
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```ts
|
|
131
|
+
* // app/blog/[slug]/page.tsx
|
|
132
|
+
* const resolver = async (params: Promise<{ slug: string }>) => {
|
|
133
|
+
* const { slug } = await params;
|
|
134
|
+
* return getNitroEntities().entityBySlug({ slug, typeId: 123 });
|
|
135
|
+
* };
|
|
136
|
+
*
|
|
137
|
+
* export const generateMetadata = (props) => nitroEntityGenerateMetadata(props, { resolver });
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
declare function nitroEntityGenerateMetadata<T = any>(props: EntityRouteParams<T>, options: {
|
|
141
|
+
resolver: EntityResolver<T>;
|
|
142
|
+
}): Promise<Metadata>;
|
|
68
143
|
|
|
69
|
-
export { NitroBlock, NitroPage, getNitroConfig, getNitroEntities, getNitroPages, initNitro,
|
|
144
|
+
export { type EntityResolver, NitroBlock, NitroPage, getNitroConfig, getNitroEntities, getNitroPages, initNitro, nitroEntityGenerateMetadata, nitroEntityRoute, nitroPageGenerateMetadata, nitroPageGenerateStaticParams, nitroPageRoute };
|
package/dist/server.js
CHANGED
|
@@ -26,8 +26,10 @@ __export(server_exports, {
|
|
|
26
26
|
getNitroEntities: () => getNitroEntities,
|
|
27
27
|
getNitroPages: () => getNitroPages,
|
|
28
28
|
initNitro: () => initNitro,
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
nitroEntityGenerateMetadata: () => nitroEntityGenerateMetadata,
|
|
30
|
+
nitroEntityRoute: () => nitroEntityRoute,
|
|
31
|
+
nitroPageGenerateMetadata: () => nitroPageGenerateMetadata,
|
|
32
|
+
nitroPageGenerateStaticParams: () => nitroPageGenerateStaticParams,
|
|
31
33
|
nitroPageRoute: () => nitroPageRoute
|
|
32
34
|
});
|
|
33
35
|
module.exports = __toCommonJS(server_exports);
|
|
@@ -78,6 +80,15 @@ var resolveNitroRoute = (0, import_react.cache)(async ({ params }) => {
|
|
|
78
80
|
}
|
|
79
81
|
return { page, path, cfg };
|
|
80
82
|
});
|
|
83
|
+
function createCachedEntityResolver(resolver) {
|
|
84
|
+
return (0, import_react.cache)(async ({ params }) => {
|
|
85
|
+
const entity = await resolver(params);
|
|
86
|
+
if (!entity) {
|
|
87
|
+
(0, import_navigation.notFound)();
|
|
88
|
+
}
|
|
89
|
+
return entity;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
81
92
|
function NitroPage({
|
|
82
93
|
page
|
|
83
94
|
}) {
|
|
@@ -115,23 +126,69 @@ async function nitroPageRoute(props) {
|
|
|
115
126
|
const { page } = await resolveNitroRoute(props);
|
|
116
127
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NitroPage, { page });
|
|
117
128
|
}
|
|
118
|
-
async function
|
|
129
|
+
async function nitroPageGenerateMetadata(props) {
|
|
119
130
|
const { page } = await resolveNitroRoute(props);
|
|
120
131
|
const meta = page.meta_json;
|
|
121
132
|
const title = meta?.title ?? page.title ?? "Page";
|
|
122
133
|
const description = meta?.description ?? "";
|
|
134
|
+
const image = meta?.image ?? "";
|
|
123
135
|
return {
|
|
124
136
|
title,
|
|
125
|
-
description
|
|
137
|
+
description,
|
|
138
|
+
openGraph: {
|
|
139
|
+
title,
|
|
140
|
+
description,
|
|
141
|
+
images: image ? [image] : [],
|
|
142
|
+
type: "website"
|
|
143
|
+
},
|
|
144
|
+
twitter: {
|
|
145
|
+
card: "summary_large_image",
|
|
146
|
+
title,
|
|
147
|
+
description,
|
|
148
|
+
images: image ? [image] : []
|
|
149
|
+
}
|
|
126
150
|
};
|
|
127
151
|
}
|
|
128
|
-
async function
|
|
152
|
+
async function nitroPageGenerateStaticParams() {
|
|
129
153
|
const cfg = await getNitroConfig();
|
|
130
154
|
const pages = cfg.pages ?? [];
|
|
131
155
|
return pages.map((path) => ({
|
|
132
156
|
slug: path === "" ? void 0 : path.split("/")
|
|
133
157
|
}));
|
|
134
158
|
}
|
|
159
|
+
function nitroEntityRoute(props, options) {
|
|
160
|
+
const cachedResolver = createCachedEntityResolver(options.resolver);
|
|
161
|
+
return (async () => {
|
|
162
|
+
const entity = await cachedResolver(props);
|
|
163
|
+
if (options.render) {
|
|
164
|
+
return options.render(entity);
|
|
165
|
+
}
|
|
166
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: entity.entity?.entity_title });
|
|
167
|
+
})();
|
|
168
|
+
}
|
|
169
|
+
async function nitroEntityGenerateMetadata(props, options) {
|
|
170
|
+
const cachedResolver = createCachedEntityResolver(options.resolver);
|
|
171
|
+
const entity = await cachedResolver(props);
|
|
172
|
+
const title = entity.entity?.entity_title ?? "Entity";
|
|
173
|
+
const description = entity.entity?.entity_teaser ?? "";
|
|
174
|
+
const image = entity.entity?.entity_image ?? "";
|
|
175
|
+
return {
|
|
176
|
+
title,
|
|
177
|
+
description,
|
|
178
|
+
openGraph: {
|
|
179
|
+
title,
|
|
180
|
+
description,
|
|
181
|
+
images: image ? [image] : [],
|
|
182
|
+
type: "website"
|
|
183
|
+
},
|
|
184
|
+
twitter: {
|
|
185
|
+
card: "summary_large_image",
|
|
186
|
+
title,
|
|
187
|
+
description,
|
|
188
|
+
images: image ? [image] : []
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
}
|
|
135
192
|
// Annotate the CommonJS export names for ESM import in node:
|
|
136
193
|
0 && (module.exports = {
|
|
137
194
|
NitroBlock,
|
|
@@ -140,8 +197,10 @@ async function nitroGenerateStaticParams() {
|
|
|
140
197
|
getNitroEntities,
|
|
141
198
|
getNitroPages,
|
|
142
199
|
initNitro,
|
|
143
|
-
|
|
144
|
-
|
|
200
|
+
nitroEntityGenerateMetadata,
|
|
201
|
+
nitroEntityRoute,
|
|
202
|
+
nitroPageGenerateMetadata,
|
|
203
|
+
nitroPageGenerateStaticParams,
|
|
145
204
|
nitroPageRoute
|
|
146
205
|
});
|
|
147
206
|
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server.tsx"],"sourcesContent":["import { cache } from 'react';\nimport type { Metadata } from 'next';\nimport { notFound } from 'next/navigation';\nimport {\n Page,\n Block,\n ConfigApi,\n ConfigResponse,\n Configuration,\n PagesApi,\n EntitiesApi\n} from '@flyo/nitro-typescript';\n\nlet globalConfiguration: Configuration | null = null;\nlet globalLang: string | null = null;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet globalComponents: Record<string, any> = {};\nlet globalShowMissingComponentAlert: boolean = false;\n\nexport const initNitro = ({accessToken, lang, components, showMissingComponentAlert}: {accessToken: string, lang?: string, components?: object, showMissingComponentAlert?: boolean}): ( () => Configuration ) => {\n\n if (!globalConfiguration) {\n globalConfiguration = new Configuration({\n apiKey: accessToken,\n });\n }\n\n globalLang = lang ?? null;\n globalComponents = components ?? {};\n globalShowMissingComponentAlert = showMissingComponentAlert ?? false;\n\n return () => globalConfiguration!;\n}\n\nexport const getNitroConfig = cache(async (): Promise<ConfigResponse> => {\n\n const configApi = new ConfigApi(globalConfiguration!);\n const useLang = globalLang ?? undefined;\n\n const config = await configApi.config({ lang: useLang });\n \n return config;\n});\n\nexport function getNitroPages(): PagesApi {\n return new PagesApi(globalConfiguration!);\n}\n\nexport function getNitroEntities(): EntitiesApi {\n return new EntitiesApi(globalConfiguration!);\n}\n\n/**\n * Route params type for Next.js catch-all routes\n */\ntype RouteParams = {\n params: Promise<{ slug?: string[] }>;\n};\n\n/**\n * Internal helper to resolve Nitro page from route params\n * Uses React cache to avoid duplicate fetching\n */\nconst resolveNitroRoute = cache(async ({ params }: RouteParams) => {\n const { slug } = await params;\n const path = slug?.join('/') ?? '';\n\n const cfg = await getNitroConfig();\n\n if (!cfg.pages?.includes(path)) {\n notFound();\n }\n\n const page = await getNitroPages()\n .page({ slug: path })\n .catch((error: unknown) => {\n console.error('Error fetching page:', path, error);\n notFound();\n });\n\n if (!page) {\n notFound();\n }\n\n return { page, path, cfg };\n});\n\n\n/**\n * NitroPage component renders all blocks from a Flyo page\n */\nexport function NitroPage({\n page,\n}: {\n page: Page\n}) {\n if (!page?.json || !Array.isArray(page.json)) {\n return null;\n }\n\n return (\n <>\n {page.json.map((block: Block, index: number) => (\n <NitroBlock\n key={block.uid || index}\n block={block}\n />\n ))}\n </>\n );\n}\n\nexport function NitroBlock({\n block,\n}: {\n block: Block\n}) {\n if (!block) {\n return null;\n }\n\n const Component = block.component ? globalComponents[block.component] : undefined;\n\n if (Component) {\n return <Component block={block} />;\n }\n\n if (globalShowMissingComponentAlert) {\n return (\n <div style={{ border: '1px solid #fff', padding: '1rem', marginBottom: '1rem', backgroundColor: 'red' }}>\n Component <b>{block.component}</b> not found.\n </div>\n );\n }\n\n return null;\n}\n\n/**\n * Default page route handler for Nitro pages\n * Can be re-exported directly from Next.js app routes\n * \n * @example\n * ```ts\n * // app/[[...slug]]/page.tsx\n * export { nitroPageRoute as default } from '@flyo/nitro-next/server';\n * ```\n */\nexport async function nitroPageRoute(props: RouteParams) {\n const { page } = await resolveNitroRoute(props);\n return <NitroPage page={page} />;\n}\n\n/**\n * Generate metadata for Nitro pages\n * Provides basic meta tags based on Flyo page data\n * Can be re-exported directly from Next.js app routes\n * \n * @example\n * ```ts\n * // app/[[...slug]]/page.tsx\n * export { nitroGenerateMetadata as generateMetadata } from '@flyo/nitro-next/server';\n * ```\n */\nexport async function nitroGenerateMetadata(\n props: RouteParams\n): Promise<Metadata> {\n const { page } = await resolveNitroRoute(props);\n\n // Extract meta information from page\n const meta = page.meta_json;\n \n const title = meta?.title ?? page.title ?? 'Page';\n const description = meta?.description ?? '';\n\n return {\n title,\n description,\n };\n}\n\n/**\n * Generate static params for all Nitro pages\n * Enables static site generation (SSG) for all pages\n * Can be re-exported directly from Next.js app routes\n * \n * @example\n * ```ts\n * // app/[[...slug]]/page.tsx\n * export { nitroGenerateStaticParams as generateStaticParams } from '@flyo/nitro-next/server';\n * ```\n */\nexport async function nitroGenerateStaticParams() {\n const cfg = await getNitroConfig();\n const pages = cfg.pages ?? [];\n\n return pages.map((path: string) => ({\n slug: path === '' ? undefined : path.split('/'),\n }));\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AAEtB,wBAAyB;AACzB,8BAQO;AA0FH;AAxFJ,IAAI,sBAA4C;AAChD,IAAI,aAA4B;AAEhC,IAAI,mBAAwC,CAAC;AAC7C,IAAI,kCAA2C;AAExC,IAAM,YAAY,CAAC,EAAC,aAAa,MAAM,YAAY,0BAAyB,MAAiI;AAEhN,MAAI,CAAC,qBAAqB;AACxB,0BAAsB,IAAI,sCAAc;AAAA,MACtC,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AAEA,eAAa,QAAQ;AACrB,qBAAmB,cAAc,CAAC;AAClC,oCAAkC,6BAA6B;AAE/D,SAAO,MAAM;AACjB;AAEO,IAAM,qBAAiB,oBAAM,YAAqC;AAErE,QAAM,YAAY,IAAI,kCAAU,mBAAoB;AACpD,Q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6CAAC,SAAI,OAAO,EAAE,QAAQ,kBAAkB,SAAS,QAAQ,cAAc,QAAQ,iBAAiB,MAAM,GAAG;AAAA;AAAA,MAC7F,4CAAC,OAAG,gBAAM,WAAU;AAAA,MAAI;AAAA,OACpC;AAAA,EAEJ;AAEA,SAAO;AACT;AAYA,eAAsB,eAAe,OAAoB;AACvD,QAAM,EAAE,KAAK,IAAI,MAAM,kBAAkB,KAAK;AAC9C,SAAO,4CAAC,aAAU,MAAY;AAChC;AAaA,eAAsB,sBACpB,OACmB;AACnB,QAAM,EAAE,KAAK,IAAI,MAAM,kBAAkB,KAAK;AAG9C,QAAM,OAAO,KAAK;AAElB,QAAM,QAAQ,MAAM,SAAS,KAAK,SAAS;AAC3C,QAAM,cAAc,MAAM,eAAe;AAEzC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAaA,eAAsB,4BAA4B;AAChD,QAAM,MAAM,MAAM,eAAe;AACjC,QAAM,QAAQ,IAAI,SAAS,CAAC;AAE5B,SAAO,MAAM,IAAI,CAAC,UAAkB;AAAA,IAClC,MAAM,SAAS,KAAK,SAAY,KAAK,MAAM,GAAG;AAAA,EAChD,EAAE;AACJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/server.tsx"],"sourcesContent":["import { cache } from 'react';\nimport type { Metadata } from 'next';\nimport { notFound } from 'next/navigation';\nimport {\n Page,\n Block,\n Entity,\n ConfigApi,\n ConfigResponse,\n Configuration,\n PagesApi,\n EntitiesApi\n} from '@flyo/nitro-typescript';\n\nlet globalConfiguration: Configuration | null = null;\nlet globalLang: string | null = null;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet globalComponents: Record<string, any> = {};\nlet globalShowMissingComponentAlert: boolean = false;\n\nexport const initNitro = ({accessToken, lang, components, showMissingComponentAlert}: {accessToken: string, lang?: string, components?: object, showMissingComponentAlert?: boolean}): ( () => Configuration ) => {\n\n if (!globalConfiguration) {\n globalConfiguration = new Configuration({\n apiKey: accessToken,\n });\n }\n\n globalLang = lang ?? null;\n globalComponents = components ?? {};\n globalShowMissingComponentAlert = showMissingComponentAlert ?? false;\n\n return () => globalConfiguration!;\n}\n\nexport const getNitroConfig = cache(async (): Promise<ConfigResponse> => {\n\n const configApi = new ConfigApi(globalConfiguration!);\n const useLang = globalLang ?? undefined;\n\n const config = await configApi.config({ lang: useLang });\n \n return config;\n});\n\nexport function getNitroPages(): PagesApi {\n return new PagesApi(globalConfiguration!);\n}\n\nexport function getNitroEntities(): EntitiesApi {\n return new EntitiesApi(globalConfiguration!);\n}\n\n/**\n * Route params type for Next.js catch-all routes\n */\ntype RouteParams = {\n params: Promise<{ slug?: string[] }>;\n};\n\n/**\n * Generic route params type for entity routes\n * Allows any param structure from Next.js app router\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype EntityRouteParams<T = any> = {\n params: Promise<T>;\n};\n\n/**\n * Internal helper to resolve Nitro page from route params\n * Uses React cache to avoid duplicate fetching\n */\nconst resolveNitroRoute = cache(async ({ params }: RouteParams) => {\n const { slug } = await params;\n const path = slug?.join('/') ?? '';\n\n const cfg = await getNitroConfig();\n\n if (!cfg.pages?.includes(path)) {\n notFound();\n }\n\n const page = await getNitroPages()\n .page({ slug: path })\n .catch((error: unknown) => {\n console.error('Error fetching page:', path, error);\n notFound();\n });\n\n if (!page) {\n notFound();\n }\n\n return { page, path, cfg };\n});\n\n/**\n * Entity resolver function type\n * Users provide this to resolve entities from their route params\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type EntityResolver<T = any> = (params: Promise<T>) => Promise<Entity>;\n\n/**\n * Internal helper to wrap and cache entity resolvers\n * Ensures the resolver is only called once per unique params\n */\nfunction createCachedEntityResolver<T>(\n resolver: EntityResolver<T>\n): (props: EntityRouteParams<T>) => Promise<Entity> {\n return cache(async ({ params }: EntityRouteParams<T>) => {\n const entity = await resolver(params);\n \n if (!entity) {\n notFound();\n }\n \n return entity;\n });\n}\n\n\n/**\n * NitroPage component renders all blocks from a Flyo page\n */\nexport function NitroPage({\n page,\n}: {\n page: Page\n}) {\n if (!page?.json || !Array.isArray(page.json)) {\n return null;\n }\n\n return (\n <>\n {page.json.map((block: Block, index: number) => (\n <NitroBlock\n key={block.uid || index}\n block={block}\n />\n ))}\n </>\n );\n}\n\nexport function NitroBlock({\n block,\n}: {\n block: Block\n}) {\n if (!block) {\n return null;\n }\n\n const Component = block.component ? globalComponents[block.component] : undefined;\n\n if (Component) {\n return <Component block={block} />;\n }\n\n if (globalShowMissingComponentAlert) {\n return (\n <div style={{ border: '1px solid #fff', padding: '1rem', marginBottom: '1rem', backgroundColor: 'red' }}>\n Component <b>{block.component}</b> not found.\n </div>\n );\n }\n\n return null;\n}\n\n/**\n * Default page route handler for Nitro pages\n * Can be re-exported directly from Next.js app routes\n * \n * @example\n * ```ts\n * // app/[[...slug]]/page.tsx\n * export { nitroPageRoute as default } from '@flyo/nitro-next/server';\n * ```\n */\nexport async function nitroPageRoute(props: RouteParams) {\n const { page } = await resolveNitroRoute(props);\n return <NitroPage page={page} />;\n}\n\n/**\n * Generate metadata for Nitro pages\n * Provides basic meta tags based on Flyo page data\n * Can be re-exported directly from Next.js app routes\n * \n * @example\n * ```ts\n * // app/[[...slug]]/page.tsx\n * export { nitroPageGenerateMetadata as generateMetadata } from '@flyo/nitro-next/server';\n * ```\n */\nexport async function nitroPageGenerateMetadata(\n props: RouteParams\n): Promise<Metadata> {\n const { page } = await resolveNitroRoute(props);\n\n // Extract meta information from page\n const meta = page.meta_json;\n \n const title = meta?.title ?? page.title ?? 'Page';\n const description = meta?.description ?? '';\n const image = meta?.image ?? '';\n\n return {\n title,\n description,\n openGraph: {\n title,\n description,\n images: image ? [image] : [],\n type: 'website',\n },\n twitter: {\n card: 'summary_large_image',\n title,\n description,\n images: image ? [image] : [],\n },\n };\n}\n\n/**\n * Generate static params for all Nitro pages\n * Enables static site generation (SSG) for all pages\n * Can be re-exported directly from Next.js app routes\n * \n * @example\n * ```ts\n * // app/[[...slug]]/page.tsx\n * export { nitroPageGenerateStaticParams as generateStaticParams } from '@flyo/nitro-next/server';\n * ```\n */\nexport async function nitroPageGenerateStaticParams() {\n const cfg = await getNitroConfig();\n const pages = cfg.pages ?? [];\n\n return pages.map((path: string) => ({\n slug: path === '' ? undefined : path.split('/'),\n }));\n}\n\n/**\n * Default entity route handler with custom resolver\n * Flexible solution that works with any route param structure\n * \n * @example\n * ```ts\n * // app/blog/[slug]/page.tsx\n * const resolver = async (params: Promise<{ slug: string }>) => {\n * const { slug } = await params;\n * return getNitroEntities().entityBySlug({ slug, typeId: 123 });\n * };\n * \n * export default (props) => nitroEntityRoute(props, {\n * resolver,\n * render: (entity) => <h1>{entity.entity?.entity_title}</h1>\n * });\n * ```\n * \n * @example\n * ```ts\n * // app/items/[uniqueid]/page.tsx\n * const resolver = async (params: Promise<{ uniqueid: string }>) => {\n * const { uniqueid } = await params;\n * return getNitroEntities().entityByUniqueid({ uniqueid });\n * };\n * \n * export default (props) => nitroEntityRoute(props, { resolver });\n * ```\n * \n * @example\n * ```ts\n * // app/custom/[whatever]/page.tsx\n * const resolver = async (params: Promise<{ whatever: string }>) => {\n * const { whatever } = await params;\n * return getNitroEntities().entityBySlug({ slug: whatever });\n * };\n * \n * export default (props) => nitroEntityRoute(props, { resolver });\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function nitroEntityRoute<T = any>(\n props: EntityRouteParams<T>,\n options: {\n resolver: EntityResolver<T>;\n render?: (entity: Entity) => React.ReactNode;\n }\n) {\n const cachedResolver = createCachedEntityResolver(options.resolver);\n \n return (async () => {\n const entity = await cachedResolver(props);\n \n if (options.render) {\n return options.render(entity);\n }\n\n // Default simple render - users should provide their own render function\n return <div>{entity.entity?.entity_title}</div>;\n })();\n}\n\n/**\n * Generate metadata for Nitro entities with custom resolver\n * Works with any route param structure\n * \n * @example\n * ```ts\n * // app/blog/[slug]/page.tsx\n * const resolver = async (params: Promise<{ slug: string }>) => {\n * const { slug } = await params;\n * return getNitroEntities().entityBySlug({ slug, typeId: 123 });\n * };\n * \n * export const generateMetadata = (props) => nitroEntityGenerateMetadata(props, { resolver });\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function nitroEntityGenerateMetadata<T = any>(\n props: EntityRouteParams<T>,\n options: {\n resolver: EntityResolver<T>;\n }\n): Promise<Metadata> {\n const cachedResolver = createCachedEntityResolver(options.resolver);\n const entity = await cachedResolver(props);\n\n const title = entity.entity?.entity_title ?? 'Entity';\n const description = entity.entity?.entity_teaser ?? '';\n const image = entity.entity?.entity_image ?? '';\n\n return {\n title,\n description,\n openGraph: {\n title,\n description,\n images: image ? [image] : [],\n type: 'website',\n },\n twitter: {\n card: 'summary_large_image',\n title,\n description,\n images: image ? [image] : [],\n },\n };\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AAEtB,wBAAyB;AACzB,8BASO;AA4HH;AA1HJ,IAAI,sBAA4C;AAChD,IAAI,aAA4B;AAEhC,IAAI,mBAAwC,CAAC;AAC7C,IAAI,kCAA2C;AAExC,IAAM,YAAY,CAAC,EAAC,aAAa,MAAM,YAAY,0BAAyB,MAAiI;AAEhN,MAAI,CAAC,qBAAqB;AACxB,0BAAsB,IAAI,sCAAc;AAAA,MACtC,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AAEA,eAAa,QAAQ;AACrB,qBAAmB,cAAc,CAAC;AAClC,oCAAkC,6BAA6B;AAE/D,SAAO,MAAM;AACjB;AAEO,IAAM,qBAAiB,oBAAM,YAAqC;AAErE,QAAM,YAAY,IAAI,kCAAU,mBAAoB;AACpD,QAAM,UAAU,cAAc;AAE9B,QAAM,SAAS,MAAM,UAAU,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEvD,SAAO;AACX,CAAC;AAEM,SAAS,gBAA0B;AACxC,SAAO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OAAO,MAAM;AAAA,IAC9B;AAGA,WAAO,4CAAC,SAAK,iBAAO,QAAQ,cAAa;AAAA,EAC3C,GAAG;AACL;AAkBA,eAAsB,4BACpB,OACA,SAGmB;AACnB,QAAM,iBAAiB,2BAA2B,QAAQ,QAAQ;AAClE,QAAM,SAAS,MAAM,eAAe,KAAK;AAEzC,QAAM,QAAQ,OAAO,QAAQ,gBAAgB;AAC7C,QAAM,cAAc,OAAO,QAAQ,iBAAiB;AACpD,QAAM,QAAQ,OAAO,QAAQ,gBAAgB;AAE7C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA;AAAA,MACA,QAAQ,QAAQ,CAAC,KAAK,IAAI,CAAC;AAAA,MAC3B,MAAM;AAAA,IACR;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA,QAAQ,QAAQ,CAAC,KAAK,IAAI,CAAC;AAAA,IAC7B;AAAA,EACF;AACF;","names":[]}
|
package/dist/server.mjs
CHANGED
|
@@ -51,6 +51,15 @@ var resolveNitroRoute = cache(async ({ params }) => {
|
|
|
51
51
|
}
|
|
52
52
|
return { page, path, cfg };
|
|
53
53
|
});
|
|
54
|
+
function createCachedEntityResolver(resolver) {
|
|
55
|
+
return cache(async ({ params }) => {
|
|
56
|
+
const entity = await resolver(params);
|
|
57
|
+
if (!entity) {
|
|
58
|
+
notFound();
|
|
59
|
+
}
|
|
60
|
+
return entity;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
54
63
|
function NitroPage({
|
|
55
64
|
page
|
|
56
65
|
}) {
|
|
@@ -88,23 +97,69 @@ async function nitroPageRoute(props) {
|
|
|
88
97
|
const { page } = await resolveNitroRoute(props);
|
|
89
98
|
return /* @__PURE__ */ jsx(NitroPage, { page });
|
|
90
99
|
}
|
|
91
|
-
async function
|
|
100
|
+
async function nitroPageGenerateMetadata(props) {
|
|
92
101
|
const { page } = await resolveNitroRoute(props);
|
|
93
102
|
const meta = page.meta_json;
|
|
94
103
|
const title = meta?.title ?? page.title ?? "Page";
|
|
95
104
|
const description = meta?.description ?? "";
|
|
105
|
+
const image = meta?.image ?? "";
|
|
96
106
|
return {
|
|
97
107
|
title,
|
|
98
|
-
description
|
|
108
|
+
description,
|
|
109
|
+
openGraph: {
|
|
110
|
+
title,
|
|
111
|
+
description,
|
|
112
|
+
images: image ? [image] : [],
|
|
113
|
+
type: "website"
|
|
114
|
+
},
|
|
115
|
+
twitter: {
|
|
116
|
+
card: "summary_large_image",
|
|
117
|
+
title,
|
|
118
|
+
description,
|
|
119
|
+
images: image ? [image] : []
|
|
120
|
+
}
|
|
99
121
|
};
|
|
100
122
|
}
|
|
101
|
-
async function
|
|
123
|
+
async function nitroPageGenerateStaticParams() {
|
|
102
124
|
const cfg = await getNitroConfig();
|
|
103
125
|
const pages = cfg.pages ?? [];
|
|
104
126
|
return pages.map((path) => ({
|
|
105
127
|
slug: path === "" ? void 0 : path.split("/")
|
|
106
128
|
}));
|
|
107
129
|
}
|
|
130
|
+
function nitroEntityRoute(props, options) {
|
|
131
|
+
const cachedResolver = createCachedEntityResolver(options.resolver);
|
|
132
|
+
return (async () => {
|
|
133
|
+
const entity = await cachedResolver(props);
|
|
134
|
+
if (options.render) {
|
|
135
|
+
return options.render(entity);
|
|
136
|
+
}
|
|
137
|
+
return /* @__PURE__ */ jsx("div", { children: entity.entity?.entity_title });
|
|
138
|
+
})();
|
|
139
|
+
}
|
|
140
|
+
async function nitroEntityGenerateMetadata(props, options) {
|
|
141
|
+
const cachedResolver = createCachedEntityResolver(options.resolver);
|
|
142
|
+
const entity = await cachedResolver(props);
|
|
143
|
+
const title = entity.entity?.entity_title ?? "Entity";
|
|
144
|
+
const description = entity.entity?.entity_teaser ?? "";
|
|
145
|
+
const image = entity.entity?.entity_image ?? "";
|
|
146
|
+
return {
|
|
147
|
+
title,
|
|
148
|
+
description,
|
|
149
|
+
openGraph: {
|
|
150
|
+
title,
|
|
151
|
+
description,
|
|
152
|
+
images: image ? [image] : [],
|
|
153
|
+
type: "website"
|
|
154
|
+
},
|
|
155
|
+
twitter: {
|
|
156
|
+
card: "summary_large_image",
|
|
157
|
+
title,
|
|
158
|
+
description,
|
|
159
|
+
images: image ? [image] : []
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
108
163
|
export {
|
|
109
164
|
NitroBlock,
|
|
110
165
|
NitroPage,
|
|
@@ -112,8 +167,10 @@ export {
|
|
|
112
167
|
getNitroEntities,
|
|
113
168
|
getNitroPages,
|
|
114
169
|
initNitro,
|
|
115
|
-
|
|
116
|
-
|
|
170
|
+
nitroEntityGenerateMetadata,
|
|
171
|
+
nitroEntityRoute,
|
|
172
|
+
nitroPageGenerateMetadata,
|
|
173
|
+
nitroPageGenerateStaticParams,
|
|
117
174
|
nitroPageRoute
|
|
118
175
|
};
|
|
119
176
|
//# sourceMappingURL=server.mjs.map
|
package/dist/server.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server.tsx"],"sourcesContent":["import { cache } from 'react';\nimport type { Metadata } from 'next';\nimport { notFound } from 'next/navigation';\nimport {\n Page,\n Block,\n ConfigApi,\n ConfigResponse,\n Configuration,\n PagesApi,\n EntitiesApi\n} from '@flyo/nitro-typescript';\n\nlet globalConfiguration: Configuration | null = null;\nlet globalLang: string | null = null;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet globalComponents: Record<string, any> = {};\nlet globalShowMissingComponentAlert: boolean = false;\n\nexport const initNitro = ({accessToken, lang, components, showMissingComponentAlert}: {accessToken: string, lang?: string, components?: object, showMissingComponentAlert?: boolean}): ( () => Configuration ) => {\n\n if (!globalConfiguration) {\n globalConfiguration = new Configuration({\n apiKey: accessToken,\n });\n }\n\n globalLang = lang ?? null;\n globalComponents = components ?? {};\n globalShowMissingComponentAlert = showMissingComponentAlert ?? false;\n\n return () => globalConfiguration!;\n}\n\nexport const getNitroConfig = cache(async (): Promise<ConfigResponse> => {\n\n const configApi = new ConfigApi(globalConfiguration!);\n const useLang = globalLang ?? undefined;\n\n const config = await configApi.config({ lang: useLang });\n \n return config;\n});\n\nexport function getNitroPages(): PagesApi {\n return new PagesApi(globalConfiguration!);\n}\n\nexport function getNitroEntities(): EntitiesApi {\n return new EntitiesApi(globalConfiguration!);\n}\n\n/**\n * Route params type for Next.js catch-all routes\n */\ntype RouteParams = {\n params: Promise<{ slug?: string[] }>;\n};\n\n/**\n * Internal helper to resolve Nitro page from route params\n * Uses React cache to avoid duplicate fetching\n */\nconst resolveNitroRoute = cache(async ({ params }: RouteParams) => {\n const { slug } = await params;\n const path = slug?.join('/') ?? '';\n\n const cfg = await getNitroConfig();\n\n if (!cfg.pages?.includes(path)) {\n notFound();\n }\n\n const page = await getNitroPages()\n .page({ slug: path })\n .catch((error: unknown) => {\n console.error('Error fetching page:', path, error);\n notFound();\n });\n\n if (!page) {\n notFound();\n }\n\n return { page, path, cfg };\n});\n\n\n/**\n * NitroPage component renders all blocks from a Flyo page\n */\nexport function NitroPage({\n page,\n}: {\n page: Page\n}) {\n if (!page?.json || !Array.isArray(page.json)) {\n return null;\n }\n\n return (\n <>\n {page.json.map((block: Block, index: number) => (\n <NitroBlock\n key={block.uid || index}\n block={block}\n />\n ))}\n </>\n );\n}\n\nexport function NitroBlock({\n block,\n}: {\n block: Block\n}) {\n if (!block) {\n return null;\n }\n\n const Component = block.component ? globalComponents[block.component] : undefined;\n\n if (Component) {\n return <Component block={block} />;\n }\n\n if (globalShowMissingComponentAlert) {\n return (\n <div style={{ border: '1px solid #fff', padding: '1rem', marginBottom: '1rem', backgroundColor: 'red' }}>\n Component <b>{block.component}</b> not found.\n </div>\n );\n }\n\n return null;\n}\n\n/**\n * Default page route handler for Nitro pages\n * Can be re-exported directly from Next.js app routes\n * \n * @example\n * ```ts\n * // app/[[...slug]]/page.tsx\n * export { nitroPageRoute as default } from '@flyo/nitro-next/server';\n * ```\n */\nexport async function nitroPageRoute(props: RouteParams) {\n const { page } = await resolveNitroRoute(props);\n return <NitroPage page={page} />;\n}\n\n/**\n * Generate metadata for Nitro pages\n * Provides basic meta tags based on Flyo page data\n * Can be re-exported directly from Next.js app routes\n * \n * @example\n * ```ts\n * // app/[[...slug]]/page.tsx\n * export { nitroGenerateMetadata as generateMetadata } from '@flyo/nitro-next/server';\n * ```\n */\nexport async function nitroGenerateMetadata(\n props: RouteParams\n): Promise<Metadata> {\n const { page } = await resolveNitroRoute(props);\n\n // Extract meta information from page\n const meta = page.meta_json;\n \n const title = meta?.title ?? page.title ?? 'Page';\n const description = meta?.description ?? '';\n\n return {\n title,\n description,\n };\n}\n\n/**\n * Generate static params for all Nitro pages\n * Enables static site generation (SSG) for all pages\n * Can be re-exported directly from Next.js app routes\n * \n * @example\n * ```ts\n * // app/[[...slug]]/page.tsx\n * export { nitroGenerateStaticParams as generateStaticParams } from '@flyo/nitro-next/server';\n * ```\n */\nexport async function nitroGenerateStaticParams() {\n const cfg = await getNitroConfig();\n const pages = cfg.pages ?? [];\n\n return pages.map((path: string) => ({\n slug: path === '' ? undefined : path.split('/'),\n }));\n}"],"mappings":";AAAA,SAAS,aAAa;AAEtB,SAAS,gBAAgB;AACzB;AAAA,EAGE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA0FH,mBAEI,KA0BF,YA5BF;AAxFJ,IAAI,sBAA4C;AAChD,IAAI,aAA4B;AAEhC,IAAI,mBAAwC,CAAC;AAC7C,IAAI,kCAA2C;AAExC,IAAM,YAAY,CAAC,EAAC,aAAa,MAAM,YAAY,0BAAyB,MAAiI;AAEhN,MAAI,CAAC,qBAAqB;AACxB,0BAAsB,IAAI,cAAc;AAAA,MACtC,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AAEA,eAAa,QAAQ;AACrB,qBAAmB,cAAc,CAAC;AAClC,oCAAkC,6BAA6B;AAE/D,SAAO,MAAM;AACjB;AAEO,IAAM,iBAAiB,MAAM,YAAqC;AAErE,QAAM,YAAY,I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iCAAiC;AACnC,WACE,qBAAC,SAAI,OAAO,EAAE,QAAQ,kBAAkB,SAAS,QAAQ,cAAc,QAAQ,iBAAiB,MAAM,GAAG;AAAA;AAAA,MAC7F,oBAAC,OAAG,gBAAM,WAAU;AAAA,MAAI;AAAA,OACpC;AAAA,EAEJ;AAEA,SAAO;AACT;AAYA,eAAsB,eAAe,OAAoB;AACvD,QAAM,EAAE,KAAK,IAAI,MAAM,kBAAkB,KAAK;AAC9C,SAAO,oBAAC,aAAU,MAAY;AAChC;AAaA,eAAsB,sBACpB,OACmB;AACnB,QAAM,EAAE,KAAK,IAAI,MAAM,kBAAkB,KAAK;AAG9C,QAAM,OAAO,KAAK;AAElB,QAAM,QAAQ,MAAM,SAAS,KAAK,SAAS;AAC3C,QAAM,cAAc,MAAM,eAAe;AAEzC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAaA,eAAsB,4BAA4B;AAChD,QAAM,MAAM,MAAM,eAAe;AACjC,QAAM,QAAQ,IAAI,SAAS,CAAC;AAE5B,SAAO,MAAM,IAAI,CAAC,UAAkB;AAAA,IAClC,MAAM,SAAS,KAAK,SAAY,KAAK,MAAM,GAAG;AAAA,EAChD,EAAE;AACJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/server.tsx"],"sourcesContent":["import { cache } from 'react';\nimport type { Metadata } from 'next';\nimport { notFound } from 'next/navigation';\nimport {\n Page,\n Block,\n Entity,\n ConfigApi,\n ConfigResponse,\n Configuration,\n PagesApi,\n EntitiesApi\n} from '@flyo/nitro-typescript';\n\nlet globalConfiguration: Configuration | null = null;\nlet globalLang: string | null = null;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet globalComponents: Record<string, any> = {};\nlet globalShowMissingComponentAlert: boolean = false;\n\nexport const initNitro = ({accessToken, lang, components, showMissingComponentAlert}: {accessToken: string, lang?: string, components?: object, showMissingComponentAlert?: boolean}): ( () => Configuration ) => {\n\n if (!globalConfiguration) {\n globalConfiguration = new Configuration({\n apiKey: accessToken,\n });\n }\n\n globalLang = lang ?? null;\n globalComponents = components ?? {};\n globalShowMissingComponentAlert = showMissingComponentAlert ?? false;\n\n return () => globalConfiguration!;\n}\n\nexport const getNitroConfig = cache(async (): Promise<ConfigResponse> => {\n\n const configApi = new ConfigApi(globalConfiguration!);\n const useLang = globalLang ?? undefined;\n\n const config = await configApi.config({ lang: useLang });\n \n return config;\n});\n\nexport function getNitroPages(): PagesApi {\n return new PagesApi(globalConfiguration!);\n}\n\nexport function getNitroEntities(): EntitiesApi {\n return new EntitiesApi(globalConfiguration!);\n}\n\n/**\n * Route params type for Next.js catch-all routes\n */\ntype RouteParams = {\n params: Promise<{ slug?: string[] }>;\n};\n\n/**\n * Generic route params type for entity routes\n * Allows any param structure from Next.js app router\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype EntityRouteParams<T = any> = {\n params: Promise<T>;\n};\n\n/**\n * Internal helper to resolve Nitro page from route params\n * Uses React cache to avoid duplicate fetching\n */\nconst resolveNitroRoute = cache(async ({ params }: RouteParams) => {\n const { slug } = await params;\n const path = slug?.join('/') ?? '';\n\n const cfg = await getNitroConfig();\n\n if (!cfg.pages?.includes(path)) {\n notFound();\n }\n\n const page = await getNitroPages()\n .page({ slug: path })\n .catch((error: unknown) => {\n console.error('Error fetching page:', path, error);\n notFound();\n });\n\n if (!page) {\n notFound();\n }\n\n return { page, path, cfg };\n});\n\n/**\n * Entity resolver function type\n * Users provide this to resolve entities from their route params\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type EntityResolver<T = any> = (params: Promise<T>) => Promise<Entity>;\n\n/**\n * Internal helper to wrap and cache entity resolvers\n * Ensures the resolver is only called once per unique params\n */\nfunction createCachedEntityResolver<T>(\n resolver: EntityResolver<T>\n): (props: EntityRouteParams<T>) => Promise<Entity> {\n return cache(async ({ params }: EntityRouteParams<T>) => {\n const entity = await resolver(params);\n \n if (!entity) {\n notFound();\n }\n \n return entity;\n });\n}\n\n\n/**\n * NitroPage component renders all blocks from a Flyo page\n */\nexport function NitroPage({\n page,\n}: {\n page: Page\n}) {\n if (!page?.json || !Array.isArray(page.json)) {\n return null;\n }\n\n return (\n <>\n {page.json.map((block: Block, index: number) => (\n <NitroBlock\n key={block.uid || index}\n block={block}\n />\n ))}\n </>\n );\n}\n\nexport function NitroBlock({\n block,\n}: {\n block: Block\n}) {\n if (!block) {\n return null;\n }\n\n const Component = block.component ? globalComponents[block.component] : undefined;\n\n if (Component) {\n return <Component block={block} />;\n }\n\n if (globalShowMissingComponentAlert) {\n return (\n <div style={{ border: '1px solid #fff', padding: '1rem', marginBottom: '1rem', backgroundColor: 'red' }}>\n Component <b>{block.component}</b> not found.\n </div>\n );\n }\n\n return null;\n}\n\n/**\n * Default page route handler for Nitro pages\n * Can be re-exported directly from Next.js app routes\n * \n * @example\n * ```ts\n * // app/[[...slug]]/page.tsx\n * export { nitroPageRoute as default } from '@flyo/nitro-next/server';\n * ```\n */\nexport async function nitroPageRoute(props: RouteParams) {\n const { page } = await resolveNitroRoute(props);\n return <NitroPage page={page} />;\n}\n\n/**\n * Generate metadata for Nitro pages\n * Provides basic meta tags based on Flyo page data\n * Can be re-exported directly from Next.js app routes\n * \n * @example\n * ```ts\n * // app/[[...slug]]/page.tsx\n * export { nitroPageGenerateMetadata as generateMetadata } from '@flyo/nitro-next/server';\n * ```\n */\nexport async function nitroPageGenerateMetadata(\n props: RouteParams\n): Promise<Metadata> {\n const { page } = await resolveNitroRoute(props);\n\n // Extract meta information from page\n const meta = page.meta_json;\n \n const title = meta?.title ?? page.title ?? 'Page';\n const description = meta?.description ?? '';\n const image = meta?.image ?? '';\n\n return {\n title,\n description,\n openGraph: {\n title,\n description,\n images: image ? [image] : [],\n type: 'website',\n },\n twitter: {\n card: 'summary_large_image',\n title,\n description,\n images: image ? [image] : [],\n },\n };\n}\n\n/**\n * Generate static params for all Nitro pages\n * Enables static site generation (SSG) for all pages\n * Can be re-exported directly from Next.js app routes\n * \n * @example\n * ```ts\n * // app/[[...slug]]/page.tsx\n * export { nitroPageGenerateStaticParams as generateStaticParams } from '@flyo/nitro-next/server';\n * ```\n */\nexport async function nitroPageGenerateStaticParams() {\n const cfg = await getNitroConfig();\n const pages = cfg.pages ?? [];\n\n return pages.map((path: string) => ({\n slug: path === '' ? undefined : path.split('/'),\n }));\n}\n\n/**\n * Default entity route handler with custom resolver\n * Flexible solution that works with any route param structure\n * \n * @example\n * ```ts\n * // app/blog/[slug]/page.tsx\n * const resolver = async (params: Promise<{ slug: string }>) => {\n * const { slug } = await params;\n * return getNitroEntities().entityBySlug({ slug, typeId: 123 });\n * };\n * \n * export default (props) => nitroEntityRoute(props, {\n * resolver,\n * render: (entity) => <h1>{entity.entity?.entity_title}</h1>\n * });\n * ```\n * \n * @example\n * ```ts\n * // app/items/[uniqueid]/page.tsx\n * const resolver = async (params: Promise<{ uniqueid: string }>) => {\n * const { uniqueid } = await params;\n * return getNitroEntities().entityByUniqueid({ uniqueid });\n * };\n * \n * export default (props) => nitroEntityRoute(props, { resolver });\n * ```\n * \n * @example\n * ```ts\n * // app/custom/[whatever]/page.tsx\n * const resolver = async (params: Promise<{ whatever: string }>) => {\n * const { whatever } = await params;\n * return getNitroEntities().entityBySlug({ slug: whatever });\n * };\n * \n * export default (props) => nitroEntityRoute(props, { resolver });\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function nitroEntityRoute<T = any>(\n props: EntityRouteParams<T>,\n options: {\n resolver: EntityResolver<T>;\n render?: (entity: Entity) => React.ReactNode;\n }\n) {\n const cachedResolver = createCachedEntityResolver(options.resolver);\n \n return (async () => {\n const entity = await cachedResolver(props);\n \n if (options.render) {\n return options.render(entity);\n }\n\n // Default simple render - users should provide their own render function\n return <div>{entity.entity?.entity_title}</div>;\n })();\n}\n\n/**\n * Generate metadata for Nitro entities with custom resolver\n * Works with any route param structure\n * \n * @example\n * ```ts\n * // app/blog/[slug]/page.tsx\n * const resolver = async (params: Promise<{ slug: string }>) => {\n * const { slug } = await params;\n * return getNitroEntities().entityBySlug({ slug, typeId: 123 });\n * };\n * \n * export const generateMetadata = (props) => nitroEntityGenerateMetadata(props, { resolver });\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function nitroEntityGenerateMetadata<T = any>(\n props: EntityRouteParams<T>,\n options: {\n resolver: EntityResolver<T>;\n }\n): Promise<Metadata> {\n const cachedResolver = createCachedEntityResolver(options.resolver);\n const entity = await cachedResolver(props);\n\n const title = entity.entity?.entity_title ?? 'Entity';\n const description = entity.entity?.entity_teaser ?? '';\n const image = entity.entity?.entity_image ?? '';\n\n return {\n title,\n description,\n openGraph: {\n title,\n description,\n images: image ? [image] : [],\n type: 'website',\n },\n twitter: {\n card: 'summary_large_image',\n title,\n description,\n images: image ? [image] : [],\n },\n };\n}"],"mappings":";AAAA,SAAS,aAAa;AAEtB,SAAS,gBAAgB;AACzB;AAAA,EAIE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA4HH,mBAEI,KA0BF,YA5BF;AA1HJ,IAAI,sBAA4C;AAChD,IAAI,aAA4B;AAEhC,IAAI,mBAAwC,CAAC;AAC7C,IAAI,kCAA2C;AAExC,IAAM,YAAY,CAAC,EAAC,aAAa,MAAM,YAAY,0BAAyB,MAAiI;AAEhN,MAAI,CAAC,qBAAqB;AACxB,0BAAsB,IAAI,cAAc;AAAA,MACtC,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AAEA,eAAa,QAAQ;AACrB,qBAAmB,cAAc,CAAC;AAClC,oCAAkC,6BAA6B;AAE/D,SAAO,MAAM;AACjB;AAEO,IAAM,iBAAiB,MAAM,YAAqC;AAErE,QAAM,YAAY,IAAI,UAAU,mBAAoB;AACpD,QAAM,UAAU,cAAc;AAE9B,QAAM,SAAS,MAAM,UAAU,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEvD,SAAO;AACX,CAAC;AAEM,SAAS,gBAA0B;AACxC,SAAO,IAAI,SAAS,mB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