@olmocms/front 0.1.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/README.md +277 -0
- package/dist/chunk-3DP2A2OG.js +52 -0
- package/dist/chunk-3DP2A2OG.js.map +1 -0
- package/dist/chunk-GQITFXCV.js +66 -0
- package/dist/chunk-GQITFXCV.js.map +1 -0
- package/dist/chunk-JISDMUJ3.js +79 -0
- package/dist/chunk-JISDMUJ3.js.map +1 -0
- package/dist/chunk-RG54JLA2.js +61 -0
- package/dist/chunk-RG54JLA2.js.map +1 -0
- package/dist/cli/index.js +344 -0
- package/dist/client/index.cjs +105 -0
- package/dist/client/index.cjs.map +1 -0
- package/dist/client/index.d.cts +5 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.js +11 -0
- package/dist/client/index.js.map +1 -0
- package/dist/components/index.cjs +113 -0
- package/dist/components/index.cjs.map +1 -0
- package/dist/components/index.d.cts +46 -0
- package/dist/components/index.d.ts +46 -0
- package/dist/components/index.js +79 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.cjs +370 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +51 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +110 -0
- package/dist/index.js.map +1 -0
- package/dist/jsonld/index.cjs +88 -0
- package/dist/jsonld/index.cjs.map +1 -0
- package/dist/jsonld/index.d.cts +33 -0
- package/dist/jsonld/index.d.ts +33 -0
- package/dist/jsonld/index.js +13 -0
- package/dist/jsonld/index.js.map +1 -0
- package/dist/middleware/index.cjs +94 -0
- package/dist/middleware/index.cjs.map +1 -0
- package/dist/middleware/index.d.cts +10 -0
- package/dist/middleware/index.d.ts +10 -0
- package/dist/middleware/index.js +11 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/seo/index.cjs +76 -0
- package/dist/seo/index.cjs.map +1 -0
- package/dist/seo/index.d.cts +45 -0
- package/dist/seo/index.d.ts +45 -0
- package/dist/seo/index.js +7 -0
- package/dist/seo/index.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli/index.ts
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
|
|
6
|
+
// src/cli/commands/add-route.ts
|
|
7
|
+
import { Command } from "commander";
|
|
8
|
+
import prompts from "prompts";
|
|
9
|
+
import path from "path";
|
|
10
|
+
import fs from "fs";
|
|
11
|
+
|
|
12
|
+
// src/cli/templates/page-simple.ts
|
|
13
|
+
function generateSimplePage({ componentName }) {
|
|
14
|
+
return `import type { Metadata } from 'next';
|
|
15
|
+
import { getting } from '@olmo/front/client';
|
|
16
|
+
import { setSeoData } from '@olmo/front/seo';
|
|
17
|
+
import { JsonLd } from '@olmo/front/components';
|
|
18
|
+
import { GtmPage } from '@olmo/front/components';
|
|
19
|
+
import { buildBreadcrumb } from '@olmo/front/jsonld';
|
|
20
|
+
import { headers } from 'next/headers';
|
|
21
|
+
import { notFound } from 'next/navigation';
|
|
22
|
+
import { getLocale, getMessages } from 'next-intl/server';
|
|
23
|
+
import { Content } from '@/components/${componentName}/Content';
|
|
24
|
+
|
|
25
|
+
export async function generateMetadata(): Promise<Metadata> {
|
|
26
|
+
const headerList = await headers();
|
|
27
|
+
const pathname = headerList.get('x-current-path') ?? '';
|
|
28
|
+
const locale = await getLocale();
|
|
29
|
+
const page = await getting<{ seo: any; route: any }>(locale, pathname, 'page');
|
|
30
|
+
if (!page) return {};
|
|
31
|
+
return setSeoData({ seo: page.seo, route: page.route }) as Metadata;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default async function Page() {
|
|
35
|
+
const headerList = await headers();
|
|
36
|
+
const pathname = headerList.get('x-current-path') ?? '';
|
|
37
|
+
const locale = await getLocale();
|
|
38
|
+
const messages = await getMessages();
|
|
39
|
+
const page = await getting<{ name: string; template: any }>(locale, pathname, 'page');
|
|
40
|
+
if (!page) notFound();
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<>
|
|
44
|
+
<GtmPage slug={pathname} lang={locale} name={page.name} template={page.template} />
|
|
45
|
+
<JsonLd schema={buildBreadcrumb([
|
|
46
|
+
{ name: 'Home', url: \`\${process.env.NEXT_PUBLIC_BASE_URL}/\${locale}/\` },
|
|
47
|
+
// TODO: add page breadcrumb item
|
|
48
|
+
])} />
|
|
49
|
+
<Content page={page} locale={locale} t={messages} />
|
|
50
|
+
</>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/cli/templates/page-list.ts
|
|
57
|
+
function generateListPage({
|
|
58
|
+
componentName,
|
|
59
|
+
modelName,
|
|
60
|
+
fields
|
|
61
|
+
}) {
|
|
62
|
+
const fieldsJson = JSON.stringify(fields, null, 4).split("\n").map((l, i) => i === 0 ? l : " " + l).join("\n");
|
|
63
|
+
return `import type { Metadata } from 'next';
|
|
64
|
+
import { getting, posting } from '@olmo/front/client';
|
|
65
|
+
import { setSeoData } from '@olmo/front/seo';
|
|
66
|
+
import { JsonLd } from '@olmo/front/components';
|
|
67
|
+
import { GtmPage } from '@olmo/front/components';
|
|
68
|
+
import { buildBreadcrumb, buildItemList } from '@olmo/front/jsonld';
|
|
69
|
+
import { headers } from 'next/headers';
|
|
70
|
+
import { notFound } from 'next/navigation';
|
|
71
|
+
import { getLocale, getMessages } from 'next-intl/server';
|
|
72
|
+
import { Content } from '@/components/${componentName}/Content';
|
|
73
|
+
|
|
74
|
+
export async function generateMetadata(): Promise<Metadata> {
|
|
75
|
+
const headerList = await headers();
|
|
76
|
+
const pathname = headerList.get('x-current-path') ?? '';
|
|
77
|
+
const locale = await getLocale();
|
|
78
|
+
const page = await getting<{ seo: any; route: any }>(locale, pathname, 'page');
|
|
79
|
+
if (!page) return {};
|
|
80
|
+
return setSeoData({ seo: page.seo, route: page.route }) as Metadata;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export default async function Page() {
|
|
84
|
+
const headerList = await headers();
|
|
85
|
+
const pathname = headerList.get('x-current-path') ?? '';
|
|
86
|
+
const locale = await getLocale();
|
|
87
|
+
const messages = await getMessages();
|
|
88
|
+
const page = await getting<{ name: string; template: any }>(locale, pathname, 'page');
|
|
89
|
+
if (!page) notFound();
|
|
90
|
+
|
|
91
|
+
const body = {
|
|
92
|
+
page: '1',
|
|
93
|
+
offset: '999',
|
|
94
|
+
order: 'DESC',
|
|
95
|
+
orderby: 'id',
|
|
96
|
+
fields: ${fieldsJson},
|
|
97
|
+
};
|
|
98
|
+
const items = await posting<any[]>(locale, 'allmodel/${modelName}', body);
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<>
|
|
102
|
+
<GtmPage slug={pathname} lang={locale} name={page.name} template={page.template} />
|
|
103
|
+
<JsonLd schema={buildBreadcrumb([
|
|
104
|
+
{ name: 'Home', url: \`\${process.env.NEXT_PUBLIC_BASE_URL}/\${locale}/\` },
|
|
105
|
+
// TODO: add page breadcrumb item
|
|
106
|
+
])} />
|
|
107
|
+
{items?.length > 0 && (
|
|
108
|
+
<JsonLd schema={buildItemList(items, \`\${process.env.NEXT_PUBLIC_BASE_URL}/\${locale}/TODO_SLUG/\`)} />
|
|
109
|
+
)}
|
|
110
|
+
<Content page={page} locale={locale} t={messages} items={items} />
|
|
111
|
+
</>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/cli/templates/page-single.ts
|
|
118
|
+
function generateSinglePage({
|
|
119
|
+
componentName,
|
|
120
|
+
withRouteSetter,
|
|
121
|
+
jsonLdType,
|
|
122
|
+
articleType = "Article"
|
|
123
|
+
}) {
|
|
124
|
+
const needsArticle = jsonLdType === "article" || jsonLdType === "both";
|
|
125
|
+
const jsonldImports = ["buildBreadcrumb", ...needsArticle ? ["buildArticle"] : []].join(", ");
|
|
126
|
+
const routeSetterImport = withRouteSetter ? `import { RouteSetter } from '@olmo/front/components';
|
|
127
|
+
` : "";
|
|
128
|
+
const routeSetterJsx = withRouteSetter ? ` <RouteSetter slugs={(page as any).route?.slug ?? {}} />
|
|
129
|
+
` : "";
|
|
130
|
+
const articleJsx = needsArticle ? ` <JsonLd schema={buildArticle(page, pathname, '${articleType}')} />
|
|
131
|
+
` : "";
|
|
132
|
+
return `import type { Metadata } from 'next';
|
|
133
|
+
import { getting } from '@olmo/front/client';
|
|
134
|
+
import { setSeoData } from '@olmo/front/seo';
|
|
135
|
+
import { JsonLd } from '@olmo/front/components';
|
|
136
|
+
import { GtmPage } from '@olmo/front/components';
|
|
137
|
+
${routeSetterImport}import { ${jsonldImports} } from '@olmo/front/jsonld';
|
|
138
|
+
import { headers } from 'next/headers';
|
|
139
|
+
import { notFound } from 'next/navigation';
|
|
140
|
+
import { getLocale, getMessages } from 'next-intl/server';
|
|
141
|
+
import { Content } from '@/components/${componentName}/Content';
|
|
142
|
+
|
|
143
|
+
export async function generateMetadata(): Promise<Metadata> {
|
|
144
|
+
const headerList = await headers();
|
|
145
|
+
const pathname = headerList.get('x-current-path') ?? '';
|
|
146
|
+
const locale = await getLocale();
|
|
147
|
+
const page = await getting<{ seo: any; route: any }>(locale, pathname, 'page');
|
|
148
|
+
if (!page) return {};
|
|
149
|
+
return setSeoData({ seo: page.seo, route: page.route }) as Metadata;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export default async function Page() {
|
|
153
|
+
const headerList = await headers();
|
|
154
|
+
const pathname = headerList.get('x-current-path') ?? '';
|
|
155
|
+
const locale = await getLocale();
|
|
156
|
+
const messages = await getMessages();
|
|
157
|
+
const page = await getting<{ name: string; template: any; route: any }>(locale, pathname, 'page');
|
|
158
|
+
if (!page) notFound();
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<>
|
|
162
|
+
<GtmPage slug={pathname} lang={locale} name={page.name} template={page.template} />
|
|
163
|
+
${routeSetterJsx} <JsonLd schema={buildBreadcrumb([
|
|
164
|
+
{ name: 'Home', url: \`\${process.env.NEXT_PUBLIC_BASE_URL}/\${locale}/\` },
|
|
165
|
+
// TODO: add parent section breadcrumb item
|
|
166
|
+
{ name: page.name, url: \`\${process.env.NEXT_PUBLIC_BASE_URL}\${pathname.endsWith('/') ? pathname : pathname + '/'}\` },
|
|
167
|
+
])} />
|
|
168
|
+
${articleJsx} <Content page={page} locale={locale} t={messages} />
|
|
169
|
+
</>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
`;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/cli/templates/content.ts
|
|
176
|
+
function generateContent({ componentName, withItems }) {
|
|
177
|
+
const itemsProp = withItems ? "\n items?: any[];" : "";
|
|
178
|
+
const itemsParam = withItems ? "\n items," : "";
|
|
179
|
+
return `interface Props {
|
|
180
|
+
page: any;
|
|
181
|
+
locale: string;
|
|
182
|
+
t: any;${itemsProp}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export function Content({ page, locale, t,${itemsParam} }: Props) {
|
|
186
|
+
return (
|
|
187
|
+
<main>
|
|
188
|
+
<h1>{page.name}</h1>
|
|
189
|
+
{/* TODO: build out the ${componentName} layout */}
|
|
190
|
+
</main>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
`;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// src/cli/commands/add-route.ts
|
|
197
|
+
var COMMON_FIELDS = [
|
|
198
|
+
"id",
|
|
199
|
+
"name_txt_general",
|
|
200
|
+
"slug_txt_general",
|
|
201
|
+
"cover_filemanager_content",
|
|
202
|
+
"title_txt_content",
|
|
203
|
+
"abstract_txt_content",
|
|
204
|
+
"subtitle_txt_content",
|
|
205
|
+
"position_ord_general",
|
|
206
|
+
"status_select_general"
|
|
207
|
+
];
|
|
208
|
+
function findProjectRoot(from) {
|
|
209
|
+
let dir = from;
|
|
210
|
+
while (dir !== path.parse(dir).root) {
|
|
211
|
+
if (fs.existsSync(path.join(dir, "package.json"))) return dir;
|
|
212
|
+
dir = path.dirname(dir);
|
|
213
|
+
}
|
|
214
|
+
console.error("Could not find project root (no package.json found).");
|
|
215
|
+
process.exit(1);
|
|
216
|
+
}
|
|
217
|
+
function toComponentName(routePath) {
|
|
218
|
+
const first = routePath.split("/")[0].replace(/\[.*?\]/g, "").replace(/[^a-zA-Z0-9]/g, "");
|
|
219
|
+
const pascal = first.charAt(0).toUpperCase() + first.slice(1);
|
|
220
|
+
const isSlug = routePath.includes("[") || routePath.includes("/");
|
|
221
|
+
return isSlug ? `${pascal}Single` : pascal;
|
|
222
|
+
}
|
|
223
|
+
function toRoutingHint(routePath) {
|
|
224
|
+
const base = routePath.split("/")[0];
|
|
225
|
+
const hasSlug = routePath.includes("[slug]");
|
|
226
|
+
const key = hasSlug ? `'/${base}/[slug]'` : `'/${base}'`;
|
|
227
|
+
return ` ${key}: {
|
|
228
|
+
it: '/${base}', // \u2190 set per-locale slugs
|
|
229
|
+
en: '/${base}',
|
|
230
|
+
},`;
|
|
231
|
+
}
|
|
232
|
+
var addRouteCommand = new Command("route").description("Scaffold a new Olmo page route").argument("[route-path]", "Route path, e.g. contacts or news/[slug]").option("--type <type>", "Route type: simple | list | single").option("--model <model>", "Olmo model name for list pages (e.g. news)").action(async (routePathArg, opts) => {
|
|
233
|
+
const root = findProjectRoot(process.cwd());
|
|
234
|
+
let routePath = routePathArg ?? "";
|
|
235
|
+
if (!routePath) {
|
|
236
|
+
const res = await prompts({ type: "text", name: "value", message: "Route path? (e.g. contacts or news/[slug])" });
|
|
237
|
+
if (!res.value) process.exit(0);
|
|
238
|
+
routePath = res.value.trim().replace(/^\//, "");
|
|
239
|
+
}
|
|
240
|
+
let routeType = opts.type ?? "";
|
|
241
|
+
const isSlugPath = routePath.includes("[");
|
|
242
|
+
if (!routeType) {
|
|
243
|
+
const defaultType = isSlugPath ? "single" : "simple";
|
|
244
|
+
const res = await prompts({
|
|
245
|
+
type: "select",
|
|
246
|
+
name: "value",
|
|
247
|
+
message: "Route type?",
|
|
248
|
+
choices: [
|
|
249
|
+
{ title: "Simple page (no list data)", value: "simple" },
|
|
250
|
+
{ title: "List page (fetches a collection)", value: "list" },
|
|
251
|
+
{ title: "Single/detail page (slug route)", value: "single" }
|
|
252
|
+
],
|
|
253
|
+
initial: defaultType === "list" ? 1 : defaultType === "single" ? 2 : 0
|
|
254
|
+
});
|
|
255
|
+
if (!res.value) process.exit(0);
|
|
256
|
+
routeType = res.value;
|
|
257
|
+
}
|
|
258
|
+
const componentName = toComponentName(routePath);
|
|
259
|
+
let modelName = opts.model ?? "";
|
|
260
|
+
let fields = [];
|
|
261
|
+
if (routeType === "list") {
|
|
262
|
+
if (!modelName) {
|
|
263
|
+
const res2 = await prompts({ type: "text", name: "value", message: "Model name? (e.g. news)", initial: routePath.split("/")[0] });
|
|
264
|
+
if (!res2.value) process.exit(0);
|
|
265
|
+
modelName = res2.value.trim();
|
|
266
|
+
}
|
|
267
|
+
const res = await prompts({
|
|
268
|
+
type: "multiselect",
|
|
269
|
+
name: "value",
|
|
270
|
+
message: "Fields to include?",
|
|
271
|
+
choices: COMMON_FIELDS.map((f) => ({ title: f, value: f, selected: ["id", "name_txt_general", "slug_txt_general", "cover_filemanager_content", "title_txt_content"].includes(f) })),
|
|
272
|
+
hint: "- Space to select, Enter to confirm"
|
|
273
|
+
});
|
|
274
|
+
fields = res.value ?? ["id", "name_txt_general", "slug_txt_general"];
|
|
275
|
+
}
|
|
276
|
+
let withRouteSetter = false;
|
|
277
|
+
let jsonLdType = "breadcrumb";
|
|
278
|
+
let articleType = "Article";
|
|
279
|
+
if (routeType === "single") {
|
|
280
|
+
const rsRes = await prompts({ type: "confirm", name: "value", message: "Include RouteSetter for language switcher?", initial: true });
|
|
281
|
+
withRouteSetter = rsRes.value ?? true;
|
|
282
|
+
const jldRes = await prompts({
|
|
283
|
+
type: "select",
|
|
284
|
+
name: "value",
|
|
285
|
+
message: "JSON-LD schema?",
|
|
286
|
+
choices: [
|
|
287
|
+
{ title: "Breadcrumb only", value: "breadcrumb" },
|
|
288
|
+
{ title: "Breadcrumb + Article", value: "both" },
|
|
289
|
+
{ title: "Article only", value: "article" },
|
|
290
|
+
{ title: "None", value: "none" }
|
|
291
|
+
]
|
|
292
|
+
});
|
|
293
|
+
jsonLdType = jldRes.value ?? "breadcrumb";
|
|
294
|
+
if (jsonLdType === "article" || jsonLdType === "both") {
|
|
295
|
+
const atRes = await prompts({
|
|
296
|
+
type: "select",
|
|
297
|
+
name: "value",
|
|
298
|
+
message: "Article type?",
|
|
299
|
+
choices: [
|
|
300
|
+
{ title: "Article", value: "Article" },
|
|
301
|
+
{ title: "NewsArticle", value: "NewsArticle" }
|
|
302
|
+
]
|
|
303
|
+
});
|
|
304
|
+
articleType = atRes.value ?? "Article";
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
let pageContent;
|
|
308
|
+
if (routeType === "list") {
|
|
309
|
+
pageContent = generateListPage({ componentName, modelName, fields });
|
|
310
|
+
} else if (routeType === "single") {
|
|
311
|
+
pageContent = generateSinglePage({ componentName, withRouteSetter, jsonLdType, articleType });
|
|
312
|
+
} else {
|
|
313
|
+
pageContent = generateSimplePage({ componentName });
|
|
314
|
+
}
|
|
315
|
+
const contentContent = generateContent({ componentName, withItems: routeType === "list" });
|
|
316
|
+
const pagePath = path.join(root, "src", "app", "[locale]", "(website)", routePath, "page.tsx");
|
|
317
|
+
const contentPath = path.join(root, "src", "components", componentName, "Content.tsx");
|
|
318
|
+
for (const [label, filePath] of [[`page.tsx`, pagePath], [`Content.tsx`, contentPath]]) {
|
|
319
|
+
if (fs.existsSync(filePath)) {
|
|
320
|
+
const res = await prompts({ type: "confirm", name: "value", message: `${label} already exists at ${path.relative(root, filePath)}. Overwrite?`, initial: false });
|
|
321
|
+
if (!res.value) {
|
|
322
|
+
console.log("Aborted.");
|
|
323
|
+
process.exit(0);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
fs.mkdirSync(path.dirname(pagePath), { recursive: true });
|
|
328
|
+
fs.mkdirSync(path.dirname(contentPath), { recursive: true });
|
|
329
|
+
fs.writeFileSync(pagePath, pageContent, "utf8");
|
|
330
|
+
fs.writeFileSync(contentPath, contentContent, "utf8");
|
|
331
|
+
console.log(`
|
|
332
|
+
\u2714 Created ${path.relative(root, pagePath)}`);
|
|
333
|
+
console.log(`\u2714 Created ${path.relative(root, contentPath)}`);
|
|
334
|
+
console.log(`
|
|
335
|
+
Add this to your i18n/routing.ts pathnames:
|
|
336
|
+
|
|
337
|
+
${toRoutingHint(routePath)}
|
|
338
|
+
`);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
// src/cli/index.ts
|
|
342
|
+
var add = program.command("add").description("Add a new resource to the project");
|
|
343
|
+
add.addCommand(addRouteCommand);
|
|
344
|
+
program.name("olmo-front").description("CLI for Olmo Next.js frontends").version("0.1.0").parse();
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/client/index.ts
|
|
21
|
+
var client_exports = {};
|
|
22
|
+
__export(client_exports, {
|
|
23
|
+
filter: () => filter,
|
|
24
|
+
getting: () => getting,
|
|
25
|
+
posting: () => posting
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(client_exports);
|
|
28
|
+
var API_BASE_URL = process.env.NEXT_PUBLIC_API_URL;
|
|
29
|
+
var API_TOKEN = process.env.NEXT_PUBLIC_OLMO_TOKEN;
|
|
30
|
+
var BASE_HEADERS = {
|
|
31
|
+
Accept: "application/json",
|
|
32
|
+
"Content-Type": "application/json",
|
|
33
|
+
"front-token": API_TOKEN
|
|
34
|
+
};
|
|
35
|
+
async function getting(lang, path, model = "") {
|
|
36
|
+
const isPreview = path.includes("?olmopreview");
|
|
37
|
+
try {
|
|
38
|
+
const response = await fetch(`${API_BASE_URL}${path}`, {
|
|
39
|
+
method: "GET",
|
|
40
|
+
headers: BASE_HEADERS,
|
|
41
|
+
cache: isPreview ? "no-cache" : "force-cache",
|
|
42
|
+
next: { tags: ["olmo", lang, path, model] }
|
|
43
|
+
});
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
console.error(`[olmo:get] ${response.status} ${response.statusText} \u2014 ${path}`);
|
|
46
|
+
return void 0;
|
|
47
|
+
}
|
|
48
|
+
return await response.json();
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error(`[olmo:get] Network error \u2014 ${path}:`, error);
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async function posting(lang = "it", path, body) {
|
|
55
|
+
try {
|
|
56
|
+
const response = await fetch(`${API_BASE_URL}/${lang}/${path}`, {
|
|
57
|
+
method: "POST",
|
|
58
|
+
headers: BASE_HEADERS,
|
|
59
|
+
body: JSON.stringify(body),
|
|
60
|
+
cache: "force-cache",
|
|
61
|
+
next: { tags: ["olmo", `/${lang}/allmodel/${path}`] }
|
|
62
|
+
});
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
console.error(`[olmo:post] ${response.status} ${response.statusText} \u2014 /${lang}/${path}`);
|
|
65
|
+
throw new Error(`Olmo API error: ${response.status} ${response.statusText}`);
|
|
66
|
+
}
|
|
67
|
+
const data = await response.json();
|
|
68
|
+
if (data.errors) {
|
|
69
|
+
throw new Error(`Olmo API returned errors for /${lang}/${path}: ${JSON.stringify(data.errors)}`);
|
|
70
|
+
}
|
|
71
|
+
return data.response;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error(`[olmo:post] Error \u2014 /${lang}/${path}:`, error);
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function filter(lang = "it", path, body) {
|
|
78
|
+
try {
|
|
79
|
+
const response = await fetch(`${API_BASE_URL}/${lang}/filters/${path}`, {
|
|
80
|
+
method: "POST",
|
|
81
|
+
headers: BASE_HEADERS,
|
|
82
|
+
body: JSON.stringify(body)
|
|
83
|
+
});
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
console.error(`[olmo:filter] ${response.status} ${response.statusText} \u2014 /${lang}/filters/${path}`);
|
|
86
|
+
throw new Error(`Olmo API error: ${response.status} ${response.statusText}`);
|
|
87
|
+
}
|
|
88
|
+
const data = await response.json();
|
|
89
|
+
if (data.errors) {
|
|
90
|
+
console.error(`[olmo:filter] API errors \u2014 /${lang}/filters/${path}:`, data.errors);
|
|
91
|
+
throw new Error(`Olmo API returned errors for /${lang}/filters/${path}: ${JSON.stringify(data.errors)}`);
|
|
92
|
+
}
|
|
93
|
+
return data;
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.error(`[olmo:filter] Error \u2014 /${lang}/filters/${path}:`, error);
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
+
0 && (module.exports = {
|
|
101
|
+
filter,
|
|
102
|
+
getting,
|
|
103
|
+
posting
|
|
104
|
+
});
|
|
105
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/index.ts"],"sourcesContent":["// Next.js extends RequestInit with a `next` property for cache tags / revalidation.\ntype NextRequestInit = RequestInit & {\n next?: { revalidate?: number | false; tags?: string[] };\n};\n\nconst API_BASE_URL = process.env.NEXT_PUBLIC_API_URL;\nconst API_TOKEN = process.env.NEXT_PUBLIC_OLMO_TOKEN as string;\n\nconst BASE_HEADERS: HeadersInit = {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n 'front-token': API_TOKEN,\n};\n\nexport async function getting<T = unknown>(\n lang: string,\n path: string,\n model = '',\n): Promise<T | undefined> {\n const isPreview = path.includes('?olmopreview');\n\n try {\n const response = await fetch(`${API_BASE_URL}${path}`, {\n method: 'GET',\n headers: BASE_HEADERS,\n cache: isPreview ? 'no-cache' : 'force-cache',\n next: { tags: ['olmo', lang, path, model] },\n } as NextRequestInit);\n\n if (!response.ok) {\n console.error(`[olmo:get] ${response.status} ${response.statusText} — ${path}`);\n return undefined;\n }\n\n return (await response.json()) as T;\n } catch (error) {\n console.error(`[olmo:get] Network error — ${path}:`, error);\n throw error;\n }\n}\n\nexport async function posting<T = unknown>(\n lang = 'it',\n path: string,\n body: object,\n): Promise<T> {\n try {\n const response = await fetch(`${API_BASE_URL}/${lang}/${path}`, {\n method: 'POST',\n headers: BASE_HEADERS,\n body: JSON.stringify(body),\n cache: 'force-cache',\n next: { tags: ['olmo', `/${lang}/allmodel/${path}`] },\n } as NextRequestInit);\n\n if (!response.ok) {\n console.error(`[olmo:post] ${response.status} ${response.statusText} — /${lang}/${path}`);\n throw new Error(`Olmo API error: ${response.status} ${response.statusText}`);\n }\n\n const data = await response.json();\n\n if (data.errors) {\n throw new Error(`Olmo API returned errors for /${lang}/${path}: ${JSON.stringify(data.errors)}`);\n }\n\n return data.response as T;\n } catch (error) {\n console.error(`[olmo:post] Error — /${lang}/${path}:`, error);\n throw error;\n }\n}\n\nexport async function filter<T = unknown>(\n lang = 'it',\n path: string,\n body: object,\n): Promise<T> {\n try {\n const response = await fetch(`${API_BASE_URL}/${lang}/filters/${path}`, {\n method: 'POST',\n headers: BASE_HEADERS,\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n console.error(`[olmo:filter] ${response.status} ${response.statusText} — /${lang}/filters/${path}`);\n throw new Error(`Olmo API error: ${response.status} ${response.statusText}`);\n }\n\n const data = await response.json();\n\n if (data.errors) {\n console.error(`[olmo:filter] API errors — /${lang}/filters/${path}:`, data.errors);\n throw new Error(`Olmo API returned errors for /${lang}/filters/${path}: ${JSON.stringify(data.errors)}`);\n }\n\n return data as T;\n } catch (error) {\n console.error(`[olmo:filter] Error — /${lang}/filters/${path}:`, error);\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,IAAM,eAAe,QAAQ,IAAI;AACjC,IAAM,YAAY,QAAQ,IAAI;AAE9B,IAAM,eAA4B;AAAA,EAChC,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,eAAe;AACjB;AAEA,eAAsB,QACpB,MACA,MACA,QAAQ,IACgB;AACxB,QAAM,YAAY,KAAK,SAAS,cAAc;AAE9C,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,GAAG,YAAY,GAAG,IAAI,IAAI;AAAA,MACrD,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,OAAO,YAAY,aAAa;AAAA,MAChC,MAAM,EAAE,MAAM,CAAC,QAAQ,MAAM,MAAM,KAAK,EAAE;AAAA,IAC5C,CAAoB;AAEpB,QAAI,CAAC,SAAS,IAAI;AAChB,cAAQ,MAAM,cAAc,SAAS,MAAM,IAAI,SAAS,UAAU,WAAM,IAAI,EAAE;AAC9E,aAAO;AAAA,IACT;AAEA,WAAQ,MAAM,SAAS,KAAK;AAAA,EAC9B,SAAS,OAAO;AACd,YAAQ,MAAM,mCAA8B,IAAI,KAAK,KAAK;AAC1D,UAAM;AAAA,EACR;AACF;AAEA,eAAsB,QACpB,OAAO,MACP,MACA,MACY;AACZ,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,GAAG,YAAY,IAAI,IAAI,IAAI,IAAI,IAAI;AAAA,MAC9D,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,MAAM,KAAK,UAAU,IAAI;AAAA,MACzB,OAAO;AAAA,MACP,MAAM,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI,aAAa,IAAI,EAAE,EAAE;AAAA,IACtD,CAAoB;AAEpB,QAAI,CAAC,SAAS,IAAI;AAChB,cAAQ,MAAM,eAAe,SAAS,MAAM,IAAI,SAAS,UAAU,YAAO,IAAI,IAAI,IAAI,EAAE;AACxF,YAAM,IAAI,MAAM,mBAAmB,SAAS,MAAM,IAAI,SAAS,UAAU,EAAE;AAAA,IAC7E;AAEA,UAAM,OAAO,MAAM,SAAS,KAAK;AAEjC,QAAI,KAAK,QAAQ;AACf,YAAM,IAAI,MAAM,iCAAiC,IAAI,IAAI,IAAI,KAAK,KAAK,UAAU,KAAK,MAAM,CAAC,EAAE;AAAA,IACjG;AAEA,WAAO,KAAK;AAAA,EACd,SAAS,OAAO;AACd,YAAQ,MAAM,6BAAwB,IAAI,IAAI,IAAI,KAAK,KAAK;AAC5D,UAAM;AAAA,EACR;AACF;AAEA,eAAsB,OACpB,OAAO,MACP,MACA,MACY;AACZ,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,GAAG,YAAY,IAAI,IAAI,YAAY,IAAI,IAAI;AAAA,MACtE,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,MAAM,KAAK,UAAU,IAAI;AAAA,IAC3B,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,cAAQ,MAAM,iBAAiB,SAAS,MAAM,IAAI,SAAS,UAAU,YAAO,IAAI,YAAY,IAAI,EAAE;AAClG,YAAM,IAAI,MAAM,mBAAmB,SAAS,MAAM,IAAI,SAAS,UAAU,EAAE;AAAA,IAC7E;AAEA,UAAM,OAAO,MAAM,SAAS,KAAK;AAEjC,QAAI,KAAK,QAAQ;AACf,cAAQ,MAAM,oCAA+B,IAAI,YAAY,IAAI,KAAK,KAAK,MAAM;AACjF,YAAM,IAAI,MAAM,iCAAiC,IAAI,YAAY,IAAI,KAAK,KAAK,UAAU,KAAK,MAAM,CAAC,EAAE;AAAA,IACzG;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,+BAA0B,IAAI,YAAY,IAAI,KAAK,KAAK;AACtE,UAAM;AAAA,EACR;AACF;","names":[]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare function getting<T = unknown>(lang: string, path: string, model?: string): Promise<T | undefined>;
|
|
2
|
+
declare function posting<T = unknown>(lang: string | undefined, path: string, body: object): Promise<T>;
|
|
3
|
+
declare function filter<T = unknown>(lang: string | undefined, path: string, body: object): Promise<T>;
|
|
4
|
+
|
|
5
|
+
export { filter, getting, posting };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare function getting<T = unknown>(lang: string, path: string, model?: string): Promise<T | undefined>;
|
|
2
|
+
declare function posting<T = unknown>(lang: string | undefined, path: string, body: object): Promise<T>;
|
|
3
|
+
declare function filter<T = unknown>(lang: string | undefined, path: string, body: object): Promise<T>;
|
|
4
|
+
|
|
5
|
+
export { filter, getting, posting };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/index.ts
|
|
21
|
+
var components_exports = {};
|
|
22
|
+
__export(components_exports, {
|
|
23
|
+
GtmPage: () => GtmPage,
|
|
24
|
+
JsonLd: () => JsonLd,
|
|
25
|
+
RouteProvider: () => RouteProvider,
|
|
26
|
+
RouteSetter: () => RouteSetter,
|
|
27
|
+
gtmClick: () => gtmClick,
|
|
28
|
+
gtmFormSent: () => gtmFormSent,
|
|
29
|
+
gtmPageView: () => gtmPageView,
|
|
30
|
+
useRoute: () => useRoute
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(components_exports);
|
|
33
|
+
|
|
34
|
+
// src/components/RouteContext.tsx
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
+
var RouteContext = (0, import_react.createContext)({ slugs: {}, setSlugs: () => {
|
|
38
|
+
} });
|
|
39
|
+
function RouteProvider({ children }) {
|
|
40
|
+
const [slugs, setSlugs] = (0, import_react.useState)({});
|
|
41
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RouteContext.Provider, { value: { slugs, setSlugs }, children });
|
|
42
|
+
}
|
|
43
|
+
var useRoute = () => (0, import_react.useContext)(RouteContext);
|
|
44
|
+
|
|
45
|
+
// src/components/RouteSetter.tsx
|
|
46
|
+
var import_react2 = require("react");
|
|
47
|
+
function RouteSetter({ slugs }) {
|
|
48
|
+
const { setSlugs } = useRoute();
|
|
49
|
+
(0, import_react2.useEffect)(() => {
|
|
50
|
+
const leafSlugs = Object.fromEntries(
|
|
51
|
+
Object.entries(slugs).map(([locale, slug]) => [locale, slug.split("/").pop() ?? slug])
|
|
52
|
+
);
|
|
53
|
+
setSlugs(leafSlugs);
|
|
54
|
+
return () => setSlugs({});
|
|
55
|
+
}, [JSON.stringify(slugs)]);
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/components/JsonLd.tsx
|
|
60
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
61
|
+
function JsonLd({ schema }) {
|
|
62
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
63
|
+
"script",
|
|
64
|
+
{
|
|
65
|
+
type: "application/ld+json",
|
|
66
|
+
dangerouslySetInnerHTML: { __html: JSON.stringify(schema) }
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/components/GtmPage.tsx
|
|
72
|
+
var import_react3 = require("react");
|
|
73
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
74
|
+
function GtmPage({ slug, lang, name, template }) {
|
|
75
|
+
(0, import_react3.useEffect)(() => {
|
|
76
|
+
if (slug) {
|
|
77
|
+
gtmPageView({
|
|
78
|
+
page_name: name,
|
|
79
|
+
page_category: template?.name,
|
|
80
|
+
page_language: lang,
|
|
81
|
+
path_clean: slug
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}, [slug]);
|
|
85
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {});
|
|
86
|
+
}
|
|
87
|
+
function gtmPageView(props) {
|
|
88
|
+
return window.dataLayer?.push({ event: "page_view", url: window.location.href, ...props });
|
|
89
|
+
}
|
|
90
|
+
function gtmFormSent({ data, name }) {
|
|
91
|
+
return window.dataLayer?.push({ ...data, event: "form_sent", form: name });
|
|
92
|
+
}
|
|
93
|
+
function gtmClick({ category, action, label }) {
|
|
94
|
+
const cleanLabel = label?.split("/") ?? [];
|
|
95
|
+
return window.dataLayer?.push({
|
|
96
|
+
event: "click",
|
|
97
|
+
category,
|
|
98
|
+
action,
|
|
99
|
+
label: cleanLabel[cleanLabel.length - 1]
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
+
0 && (module.exports = {
|
|
104
|
+
GtmPage,
|
|
105
|
+
JsonLd,
|
|
106
|
+
RouteProvider,
|
|
107
|
+
RouteSetter,
|
|
108
|
+
gtmClick,
|
|
109
|
+
gtmFormSent,
|
|
110
|
+
gtmPageView,
|
|
111
|
+
useRoute
|
|
112
|
+
});
|
|
113
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/index.ts","../../src/components/RouteContext.tsx","../../src/components/RouteSetter.tsx","../../src/components/JsonLd.tsx","../../src/components/GtmPage.tsx"],"sourcesContent":["export { RouteProvider, useRoute } from './RouteContext.js';\nexport { RouteSetter } from './RouteSetter.js';\nexport { JsonLd } from './JsonLd.js';\nexport { GtmPage, gtmPageView, gtmFormSent, gtmClick } from './GtmPage.js';\n","'use client';\n\nimport { createContext, useContext, useState } from 'react';\nimport type { ReactNode } from 'react';\n\ntype LocaleSlugs = Record<string, string>;\n\nconst RouteContext = createContext<{\n slugs: LocaleSlugs;\n setSlugs: (slugs: LocaleSlugs) => void;\n}>({ slugs: {}, setSlugs: () => {} });\n\nexport function RouteProvider({ children }: { children: ReactNode }) {\n const [slugs, setSlugs] = useState<LocaleSlugs>({});\n return (\n <RouteContext.Provider value={{ slugs, setSlugs }}>\n {children}\n </RouteContext.Provider>\n );\n}\n\nexport const useRoute = () => useContext(RouteContext);\n","'use client';\n\nimport { useEffect } from 'react';\nimport { useRoute } from './RouteContext.js';\n\nexport function RouteSetter({ slugs }: { slugs: Record<string, string> }) {\n const { setSlugs } = useRoute();\n\n useEffect(() => {\n const leafSlugs = Object.fromEntries(\n Object.entries(slugs).map(([locale, slug]) => [locale, slug.split('/').pop() ?? slug]),\n );\n setSlugs(leafSlugs);\n return () => setSlugs({});\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [JSON.stringify(slugs)]);\n\n return null;\n}\n","export function JsonLd({ schema }: { schema: object }) {\n return (\n <script\n type=\"application/ld+json\"\n dangerouslySetInnerHTML={{ __html: JSON.stringify(schema) }}\n />\n );\n}\n","'use client';\n\nimport { useEffect } from 'react';\n\ninterface GtmPageProps {\n slug: string | null;\n lang: string | null;\n name: string | null;\n template: string | null;\n}\n\ninterface GtmFormProps {\n data: object | null;\n name: string | null;\n}\n\ninterface GtmClickProps {\n category: string | null;\n action: string | null;\n label: string | null;\n}\n\ndeclare global {\n interface Window {\n dataLayer: any[];\n }\n}\n\nexport function GtmPage({ slug, lang, name, template }: GtmPageProps) {\n useEffect(() => {\n if (slug) {\n gtmPageView({\n page_name: name,\n page_category: (template as any)?.name,\n page_language: lang,\n path_clean: slug,\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [slug]);\n\n return <></>;\n}\n\nexport function gtmPageView(props: Record<string, any>) {\n return window.dataLayer?.push({ event: 'page_view', url: window.location.href, ...props });\n}\n\nexport function gtmFormSent({ data, name }: GtmFormProps) {\n return window.dataLayer?.push({ ...data, event: 'form_sent', form: name });\n}\n\nexport function gtmClick({ category, action, label }: GtmClickProps) {\n const cleanLabel = label?.split('/') ?? [];\n return window.dataLayer?.push({\n event: 'click',\n category,\n action,\n label: cleanLabel[cleanLabel.length - 1],\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,mBAAoD;AAahD;AARJ,IAAM,mBAAe,4BAGlB,EAAE,OAAO,CAAC,GAAG,UAAU,MAAM;AAAC,EAAE,CAAC;AAE7B,SAAS,cAAc,EAAE,SAAS,GAA4B;AACnE,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAsB,CAAC,CAAC;AAClD,SACE,4CAAC,aAAa,UAAb,EAAsB,OAAO,EAAE,OAAO,SAAS,GAC7C,UACH;AAEJ;AAEO,IAAM,WAAW,UAAM,yBAAW,YAAY;;;ACnBrD,IAAAA,gBAA0B;AAGnB,SAAS,YAAY,EAAE,MAAM,GAAsC;AACxE,QAAM,EAAE,SAAS,IAAI,SAAS;AAE9B,+BAAU,MAAM;AACd,UAAM,YAAY,OAAO;AAAA,MACvB,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,KAAK,MAAM,GAAG,EAAE,IAAI,KAAK,IAAI,CAAC;AAAA,IACvF;AACA,aAAS,SAAS;AAClB,WAAO,MAAM,SAAS,CAAC,CAAC;AAAA,EAE1B,GAAG,CAAC,KAAK,UAAU,KAAK,CAAC,CAAC;AAE1B,SAAO;AACT;;;AChBI,IAAAC,sBAAA;AAFG,SAAS,OAAO,EAAE,OAAO,GAAuB;AACrD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,yBAAyB,EAAE,QAAQ,KAAK,UAAU,MAAM,EAAE;AAAA;AAAA,EAC5D;AAEJ;;;ACLA,IAAAC,gBAA0B;AAuCjB,IAAAC,sBAAA;AAbF,SAAS,QAAQ,EAAE,MAAM,MAAM,MAAM,SAAS,GAAiB;AACpE,+BAAU,MAAM;AACd,QAAI,MAAM;AACR,kBAAY;AAAA,QACV,WAAW;AAAA,QACX,eAAgB,UAAkB;AAAA,QAClC,eAAe;AAAA,QACf,YAAY;AAAA,MACd,CAAC;AAAA,IACH;AAAA,EAEF,GAAG,CAAC,IAAI,CAAC;AAET,SAAO,6EAAE;AACX;AAEO,SAAS,YAAY,OAA4B;AACtD,SAAO,OAAO,WAAW,KAAK,EAAE,OAAO,aAAa,KAAK,OAAO,SAAS,MAAM,GAAG,MAAM,CAAC;AAC3F;AAEO,SAAS,YAAY,EAAE,MAAM,KAAK,GAAiB;AACxD,SAAO,OAAO,WAAW,KAAK,EAAE,GAAG,MAAM,OAAO,aAAa,MAAM,KAAK,CAAC;AAC3E;AAEO,SAAS,SAAS,EAAE,UAAU,QAAQ,MAAM,GAAkB;AACnE,QAAM,aAAa,OAAO,MAAM,GAAG,KAAK,CAAC;AACzC,SAAO,OAAO,WAAW,KAAK;AAAA,IAC5B,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,OAAO,WAAW,WAAW,SAAS,CAAC;AAAA,EACzC,CAAC;AACH;","names":["import_react","import_jsx_runtime","import_react","import_jsx_runtime"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
type LocaleSlugs = Record<string, string>;
|
|
5
|
+
declare function RouteProvider({ children }: {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}): react_jsx_runtime.JSX.Element;
|
|
8
|
+
declare const useRoute: () => {
|
|
9
|
+
slugs: LocaleSlugs;
|
|
10
|
+
setSlugs: (slugs: LocaleSlugs) => void;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
declare function RouteSetter({ slugs }: {
|
|
14
|
+
slugs: Record<string, string>;
|
|
15
|
+
}): null;
|
|
16
|
+
|
|
17
|
+
declare function JsonLd({ schema }: {
|
|
18
|
+
schema: object;
|
|
19
|
+
}): react_jsx_runtime.JSX.Element;
|
|
20
|
+
|
|
21
|
+
interface GtmPageProps {
|
|
22
|
+
slug: string | null;
|
|
23
|
+
lang: string | null;
|
|
24
|
+
name: string | null;
|
|
25
|
+
template: string | null;
|
|
26
|
+
}
|
|
27
|
+
interface GtmFormProps {
|
|
28
|
+
data: object | null;
|
|
29
|
+
name: string | null;
|
|
30
|
+
}
|
|
31
|
+
interface GtmClickProps {
|
|
32
|
+
category: string | null;
|
|
33
|
+
action: string | null;
|
|
34
|
+
label: string | null;
|
|
35
|
+
}
|
|
36
|
+
declare global {
|
|
37
|
+
interface Window {
|
|
38
|
+
dataLayer: any[];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
declare function GtmPage({ slug, lang, name, template }: GtmPageProps): react_jsx_runtime.JSX.Element;
|
|
42
|
+
declare function gtmPageView(props: Record<string, any>): number;
|
|
43
|
+
declare function gtmFormSent({ data, name }: GtmFormProps): number;
|
|
44
|
+
declare function gtmClick({ category, action, label }: GtmClickProps): number;
|
|
45
|
+
|
|
46
|
+
export { GtmPage, JsonLd, RouteProvider, RouteSetter, gtmClick, gtmFormSent, gtmPageView, useRoute };
|