@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,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 };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// src/components/RouteContext.tsx
|
|
2
|
+
import { createContext, useContext, useState } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
var RouteContext = createContext({ slugs: {}, setSlugs: () => {
|
|
5
|
+
} });
|
|
6
|
+
function RouteProvider({ children }) {
|
|
7
|
+
const [slugs, setSlugs] = useState({});
|
|
8
|
+
return /* @__PURE__ */ jsx(RouteContext.Provider, { value: { slugs, setSlugs }, children });
|
|
9
|
+
}
|
|
10
|
+
var useRoute = () => useContext(RouteContext);
|
|
11
|
+
|
|
12
|
+
// src/components/RouteSetter.tsx
|
|
13
|
+
import { useEffect } from "react";
|
|
14
|
+
function RouteSetter({ slugs }) {
|
|
15
|
+
const { setSlugs } = useRoute();
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const leafSlugs = Object.fromEntries(
|
|
18
|
+
Object.entries(slugs).map(([locale, slug]) => [locale, slug.split("/").pop() ?? slug])
|
|
19
|
+
);
|
|
20
|
+
setSlugs(leafSlugs);
|
|
21
|
+
return () => setSlugs({});
|
|
22
|
+
}, [JSON.stringify(slugs)]);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// src/components/JsonLd.tsx
|
|
27
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
28
|
+
function JsonLd({ schema }) {
|
|
29
|
+
return /* @__PURE__ */ jsx2(
|
|
30
|
+
"script",
|
|
31
|
+
{
|
|
32
|
+
type: "application/ld+json",
|
|
33
|
+
dangerouslySetInnerHTML: { __html: JSON.stringify(schema) }
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/components/GtmPage.tsx
|
|
39
|
+
import { useEffect as useEffect2 } from "react";
|
|
40
|
+
import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
|
|
41
|
+
function GtmPage({ slug, lang, name, template }) {
|
|
42
|
+
useEffect2(() => {
|
|
43
|
+
if (slug) {
|
|
44
|
+
gtmPageView({
|
|
45
|
+
page_name: name,
|
|
46
|
+
page_category: template?.name,
|
|
47
|
+
page_language: lang,
|
|
48
|
+
path_clean: slug
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}, [slug]);
|
|
52
|
+
return /* @__PURE__ */ jsx3(Fragment, {});
|
|
53
|
+
}
|
|
54
|
+
function gtmPageView(props) {
|
|
55
|
+
return window.dataLayer?.push({ event: "page_view", url: window.location.href, ...props });
|
|
56
|
+
}
|
|
57
|
+
function gtmFormSent({ data, name }) {
|
|
58
|
+
return window.dataLayer?.push({ ...data, event: "form_sent", form: name });
|
|
59
|
+
}
|
|
60
|
+
function gtmClick({ category, action, label }) {
|
|
61
|
+
const cleanLabel = label?.split("/") ?? [];
|
|
62
|
+
return window.dataLayer?.push({
|
|
63
|
+
event: "click",
|
|
64
|
+
category,
|
|
65
|
+
action,
|
|
66
|
+
label: cleanLabel[cleanLabel.length - 1]
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
GtmPage,
|
|
71
|
+
JsonLd,
|
|
72
|
+
RouteProvider,
|
|
73
|
+
RouteSetter,
|
|
74
|
+
gtmClick,
|
|
75
|
+
gtmFormSent,
|
|
76
|
+
gtmPageView,
|
|
77
|
+
useRoute
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/RouteContext.tsx","../../src/components/RouteSetter.tsx","../../src/components/JsonLd.tsx","../../src/components/GtmPage.tsx"],"sourcesContent":["'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',\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,YAAY;AAAA,MACd,CAAC;AAAA,IACH;AAAA,EAEF,GAAG,CAAC,IAAI,CAAC;AAET,SAAO,gBAAAC,KAAA,YAAE;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":["jsx","useEffect","jsx"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
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/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
GtmPage: () => GtmPage,
|
|
24
|
+
JsonLd: () => JsonLd,
|
|
25
|
+
RouteProvider: () => RouteProvider,
|
|
26
|
+
RouteSetter: () => RouteSetter,
|
|
27
|
+
buildArticle: () => buildArticle,
|
|
28
|
+
buildBreadcrumb: () => buildBreadcrumb,
|
|
29
|
+
buildItemList: () => buildItemList,
|
|
30
|
+
buildWebSite: () => buildWebSite,
|
|
31
|
+
chain: () => chain,
|
|
32
|
+
filter: () => filter,
|
|
33
|
+
getting: () => getting,
|
|
34
|
+
gtmClick: () => gtmClick,
|
|
35
|
+
gtmFormSent: () => gtmFormSent,
|
|
36
|
+
gtmPageView: () => gtmPageView,
|
|
37
|
+
headermiddleware: () => headermiddleware,
|
|
38
|
+
posting: () => posting,
|
|
39
|
+
redirectmiddleware: () => redirectmiddleware,
|
|
40
|
+
setSeoData: () => setSeoData,
|
|
41
|
+
useRoute: () => useRoute
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(src_exports);
|
|
44
|
+
|
|
45
|
+
// src/client/index.ts
|
|
46
|
+
var API_BASE_URL = process.env.NEXT_PUBLIC_API_URL;
|
|
47
|
+
var API_TOKEN = process.env.NEXT_PUBLIC_OLMO_TOKEN;
|
|
48
|
+
var BASE_HEADERS = {
|
|
49
|
+
Accept: "application/json",
|
|
50
|
+
"Content-Type": "application/json",
|
|
51
|
+
"front-token": API_TOKEN
|
|
52
|
+
};
|
|
53
|
+
async function getting(lang, path, model = "") {
|
|
54
|
+
const isPreview = path.includes("?olmopreview");
|
|
55
|
+
try {
|
|
56
|
+
const response = await fetch(`${API_BASE_URL}${path}`, {
|
|
57
|
+
method: "GET",
|
|
58
|
+
headers: BASE_HEADERS,
|
|
59
|
+
cache: isPreview ? "no-cache" : "force-cache",
|
|
60
|
+
next: { tags: ["olmo", lang, path, model] }
|
|
61
|
+
});
|
|
62
|
+
if (!response.ok) {
|
|
63
|
+
console.error(`[olmo:get] ${response.status} ${response.statusText} \u2014 ${path}`);
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
return await response.json();
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error(`[olmo:get] Network error \u2014 ${path}:`, error);
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async function posting(lang = "it", path, body) {
|
|
73
|
+
try {
|
|
74
|
+
const response = await fetch(`${API_BASE_URL}/${lang}/${path}`, {
|
|
75
|
+
method: "POST",
|
|
76
|
+
headers: BASE_HEADERS,
|
|
77
|
+
body: JSON.stringify(body),
|
|
78
|
+
cache: "force-cache",
|
|
79
|
+
next: { tags: ["olmo", `/${lang}/allmodel/${path}`] }
|
|
80
|
+
});
|
|
81
|
+
if (!response.ok) {
|
|
82
|
+
console.error(`[olmo:post] ${response.status} ${response.statusText} \u2014 /${lang}/${path}`);
|
|
83
|
+
throw new Error(`Olmo API error: ${response.status} ${response.statusText}`);
|
|
84
|
+
}
|
|
85
|
+
const data = await response.json();
|
|
86
|
+
if (data.errors) {
|
|
87
|
+
throw new Error(`Olmo API returned errors for /${lang}/${path}: ${JSON.stringify(data.errors)}`);
|
|
88
|
+
}
|
|
89
|
+
return data.response;
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error(`[olmo:post] Error \u2014 /${lang}/${path}:`, error);
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async function filter(lang = "it", path, body) {
|
|
96
|
+
try {
|
|
97
|
+
const response = await fetch(`${API_BASE_URL}/${lang}/filters/${path}`, {
|
|
98
|
+
method: "POST",
|
|
99
|
+
headers: BASE_HEADERS,
|
|
100
|
+
body: JSON.stringify(body)
|
|
101
|
+
});
|
|
102
|
+
if (!response.ok) {
|
|
103
|
+
console.error(`[olmo:filter] ${response.status} ${response.statusText} \u2014 /${lang}/filters/${path}`);
|
|
104
|
+
throw new Error(`Olmo API error: ${response.status} ${response.statusText}`);
|
|
105
|
+
}
|
|
106
|
+
const data = await response.json();
|
|
107
|
+
if (data.errors) {
|
|
108
|
+
console.error(`[olmo:filter] API errors \u2014 /${lang}/filters/${path}:`, data.errors);
|
|
109
|
+
throw new Error(`Olmo API returned errors for /${lang}/filters/${path}: ${JSON.stringify(data.errors)}`);
|
|
110
|
+
}
|
|
111
|
+
return data;
|
|
112
|
+
} catch (error) {
|
|
113
|
+
console.error(`[olmo:filter] Error \u2014 /${lang}/filters/${path}:`, error);
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// src/seo/index.ts
|
|
119
|
+
var setSeoData = ({ seo, route, locales = ["it", "en"] }) => {
|
|
120
|
+
if (!seo) return {};
|
|
121
|
+
const baseUrl = process.env.NEXT_PUBLIC_API_STORAGE_URL;
|
|
122
|
+
const frontUrl = process.env.NEXT_PUBLIC_BASE_URL;
|
|
123
|
+
const ogImg = seo.og_img?.original;
|
|
124
|
+
const ogUrl = ogImg?.compressed ? baseUrl + ogImg.compressed : frontUrl + "/images/og-image.jpg";
|
|
125
|
+
const languagesMap = {};
|
|
126
|
+
for (const loc of locales) {
|
|
127
|
+
if (route.slug?.[loc] !== void 0) {
|
|
128
|
+
languagesMap[loc] = `/${loc}/${route.slug[loc]}`;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const defaultLocale = locales[locales.length - 1];
|
|
132
|
+
if (route.slug?.[defaultLocale] !== void 0) {
|
|
133
|
+
languagesMap["x-default"] = `/${defaultLocale}/${route.slug[defaultLocale]}`;
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
metadataBase: new URL(`${process.env.NEXT_PUBLIC_BASE_URL}`),
|
|
137
|
+
title: seo.meta_title || "",
|
|
138
|
+
description: seo.meta_description || "",
|
|
139
|
+
robots: {
|
|
140
|
+
index: seo.index === "index",
|
|
141
|
+
follow: seo.follow === "follow"
|
|
142
|
+
},
|
|
143
|
+
openGraph: {
|
|
144
|
+
title: seo.og_title || "",
|
|
145
|
+
description: seo.og_description || "",
|
|
146
|
+
url: seo.opengraphUrl || "",
|
|
147
|
+
siteName: seo.opengraphSiteName || "",
|
|
148
|
+
images: [
|
|
149
|
+
{
|
|
150
|
+
url: ogUrl,
|
|
151
|
+
width: ogImg?.width || 1200,
|
|
152
|
+
height: ogImg?.height || 630,
|
|
153
|
+
alt: ogImg?.alt || ""
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
locale: route.locale,
|
|
157
|
+
type: seo.opengraphType || "website"
|
|
158
|
+
},
|
|
159
|
+
alternates: {
|
|
160
|
+
canonical: `${process.env.NEXT_PUBLIC_BASE_URL}/${route.locale}/${route.slug[route.locale]}`,
|
|
161
|
+
languages: languagesMap
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// src/jsonld/index.ts
|
|
167
|
+
var BASE_URL = process.env.NEXT_PUBLIC_BASE_URL;
|
|
168
|
+
var STORAGE_URL = process.env.NEXT_PUBLIC_API_STORAGE_URL;
|
|
169
|
+
var SITE_NAME = process.env.NEXT_PUBLIC_SITE_NAME ?? "Website";
|
|
170
|
+
var buildBreadcrumb = (items) => ({
|
|
171
|
+
"@context": "https://schema.org",
|
|
172
|
+
"@type": "BreadcrumbList",
|
|
173
|
+
itemListElement: items.map((item, index) => ({
|
|
174
|
+
"@type": "ListItem",
|
|
175
|
+
position: index + 1,
|
|
176
|
+
name: item.name,
|
|
177
|
+
item: item.url
|
|
178
|
+
}))
|
|
179
|
+
});
|
|
180
|
+
var buildItemList = (items, sectionUrl) => ({
|
|
181
|
+
"@context": "https://schema.org",
|
|
182
|
+
"@type": "ItemList",
|
|
183
|
+
itemListElement: items.map((item, index) => ({
|
|
184
|
+
"@type": "ListItem",
|
|
185
|
+
position: index + 1,
|
|
186
|
+
name: item.title_txt_content || item.name_txt_general,
|
|
187
|
+
url: `${sectionUrl}${item.slug_txt_general}/`
|
|
188
|
+
}))
|
|
189
|
+
});
|
|
190
|
+
var buildArticle = (page, pathname, articleType = "Article", publisherName) => {
|
|
191
|
+
const name = publisherName ?? SITE_NAME;
|
|
192
|
+
const pageUrl = `${BASE_URL}${pathname.endsWith("/") ? pathname : pathname + "/"}`;
|
|
193
|
+
const imageUrl = (page.primary ?? page.cover)?.original?.compressed ? `${STORAGE_URL}${(page.primary ?? page.cover).original.compressed}` : void 0;
|
|
194
|
+
const description = page.subtitle ? page.subtitle.replace(/<[^>]*>/g, "").trim() : void 0;
|
|
195
|
+
const publisher = {
|
|
196
|
+
"@type": "Organization",
|
|
197
|
+
name,
|
|
198
|
+
url: BASE_URL,
|
|
199
|
+
logo: { "@type": "ImageObject", url: `${BASE_URL}/images/logo/logo.png` }
|
|
200
|
+
};
|
|
201
|
+
return {
|
|
202
|
+
"@context": "https://schema.org",
|
|
203
|
+
"@type": articleType,
|
|
204
|
+
headline: page.title,
|
|
205
|
+
...description && { description },
|
|
206
|
+
...imageUrl && { image: imageUrl },
|
|
207
|
+
url: pageUrl,
|
|
208
|
+
author: publisher,
|
|
209
|
+
publisher,
|
|
210
|
+
...page.lastmod && { datePublished: page.lastmod, dateModified: page.lastmod }
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
var buildWebSite = (locale, siteName) => ({
|
|
214
|
+
"@context": "https://schema.org",
|
|
215
|
+
"@type": "WebSite",
|
|
216
|
+
name: siteName ?? SITE_NAME,
|
|
217
|
+
url: `${BASE_URL}/${locale}/`
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
// src/middleware/chain.ts
|
|
221
|
+
var import_server = require("next/server");
|
|
222
|
+
function chain(functions = [], index = 0) {
|
|
223
|
+
const current = functions[index];
|
|
224
|
+
if (current) {
|
|
225
|
+
const next = chain(functions, index + 1);
|
|
226
|
+
return current(next);
|
|
227
|
+
}
|
|
228
|
+
return () => import_server.NextResponse.next();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// src/middleware/headermiddleware.ts
|
|
232
|
+
var import_server2 = require("next/server");
|
|
233
|
+
var headermiddleware = (next) => {
|
|
234
|
+
return async (request, _next) => {
|
|
235
|
+
const url = new URL(request.url);
|
|
236
|
+
const params = new URLSearchParams(url.search);
|
|
237
|
+
const headers = new Headers(request.headers);
|
|
238
|
+
headers.set("x-current-path", request.nextUrl.pathname);
|
|
239
|
+
headers.set("x-server", "true");
|
|
240
|
+
headers.set("olmo-preview", params.has("olmopreview").toString());
|
|
241
|
+
return next(new import_server2.NextRequest(request.url, { headers }), _next);
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// src/middleware/redirectmiddleware.ts
|
|
246
|
+
var import_server3 = require("next/server");
|
|
247
|
+
var redirectmiddleware = (next) => {
|
|
248
|
+
return async (request, _next) => {
|
|
249
|
+
if (request.headers.has("rsc")) {
|
|
250
|
+
return next(request, _next);
|
|
251
|
+
}
|
|
252
|
+
if (!process.env.NEXT_PUBLIC_OLMO_TOKEN || !process.env.NEXT_PUBLIC_API_URL || !process.env.NEXT_PUBLIC_BASE_URL) {
|
|
253
|
+
return next(request, _next);
|
|
254
|
+
}
|
|
255
|
+
const pathNameWithTrailingSlash = request.nextUrl.pathname;
|
|
256
|
+
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/all/redirect`, {
|
|
257
|
+
method: "GET",
|
|
258
|
+
cache: "force-cache",
|
|
259
|
+
next: { tags: ["olmo", "redirect"] },
|
|
260
|
+
headers: { "front-token": process.env.NEXT_PUBLIC_OLMO_TOKEN }
|
|
261
|
+
});
|
|
262
|
+
const data = await response.json();
|
|
263
|
+
const redirects = data.map((e) => ({
|
|
264
|
+
source: e.source,
|
|
265
|
+
destination: e.destination,
|
|
266
|
+
permanent: e.permanent === "true"
|
|
267
|
+
}));
|
|
268
|
+
if (redirects.length > 0) {
|
|
269
|
+
const redirect = redirects.find((item) => item.source === pathNameWithTrailingSlash);
|
|
270
|
+
if (!redirect) {
|
|
271
|
+
return next(request, _next);
|
|
272
|
+
}
|
|
273
|
+
const newUrl = new URL(redirect.destination, process.env.NEXT_PUBLIC_BASE_URL).toString();
|
|
274
|
+
return import_server3.NextResponse.redirect(newUrl, { status: redirect.permanent ? 308 : 307 });
|
|
275
|
+
}
|
|
276
|
+
return next(request, _next);
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
// src/components/RouteContext.tsx
|
|
281
|
+
var import_react = require("react");
|
|
282
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
283
|
+
var RouteContext = (0, import_react.createContext)({ slugs: {}, setSlugs: () => {
|
|
284
|
+
} });
|
|
285
|
+
function RouteProvider({ children }) {
|
|
286
|
+
const [slugs, setSlugs] = (0, import_react.useState)({});
|
|
287
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RouteContext.Provider, { value: { slugs, setSlugs }, children });
|
|
288
|
+
}
|
|
289
|
+
var useRoute = () => (0, import_react.useContext)(RouteContext);
|
|
290
|
+
|
|
291
|
+
// src/components/RouteSetter.tsx
|
|
292
|
+
var import_react2 = require("react");
|
|
293
|
+
function RouteSetter({ slugs }) {
|
|
294
|
+
const { setSlugs } = useRoute();
|
|
295
|
+
(0, import_react2.useEffect)(() => {
|
|
296
|
+
const leafSlugs = Object.fromEntries(
|
|
297
|
+
Object.entries(slugs).map(([locale, slug]) => [locale, slug.split("/").pop() ?? slug])
|
|
298
|
+
);
|
|
299
|
+
setSlugs(leafSlugs);
|
|
300
|
+
return () => setSlugs({});
|
|
301
|
+
}, [JSON.stringify(slugs)]);
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// src/components/JsonLd.tsx
|
|
306
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
307
|
+
function JsonLd({ schema }) {
|
|
308
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
309
|
+
"script",
|
|
310
|
+
{
|
|
311
|
+
type: "application/ld+json",
|
|
312
|
+
dangerouslySetInnerHTML: { __html: JSON.stringify(schema) }
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// src/components/GtmPage.tsx
|
|
318
|
+
var import_react3 = require("react");
|
|
319
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
320
|
+
function GtmPage({ slug, lang, name, template }) {
|
|
321
|
+
(0, import_react3.useEffect)(() => {
|
|
322
|
+
if (slug) {
|
|
323
|
+
gtmPageView({
|
|
324
|
+
page_name: name,
|
|
325
|
+
page_category: template?.name,
|
|
326
|
+
page_language: lang,
|
|
327
|
+
path_clean: slug
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
}, [slug]);
|
|
331
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {});
|
|
332
|
+
}
|
|
333
|
+
function gtmPageView(props) {
|
|
334
|
+
return window.dataLayer?.push({ event: "page_view", url: window.location.href, ...props });
|
|
335
|
+
}
|
|
336
|
+
function gtmFormSent({ data, name }) {
|
|
337
|
+
return window.dataLayer?.push({ ...data, event: "form_sent", form: name });
|
|
338
|
+
}
|
|
339
|
+
function gtmClick({ category, action, label }) {
|
|
340
|
+
const cleanLabel = label?.split("/") ?? [];
|
|
341
|
+
return window.dataLayer?.push({
|
|
342
|
+
event: "click",
|
|
343
|
+
category,
|
|
344
|
+
action,
|
|
345
|
+
label: cleanLabel[cleanLabel.length - 1]
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
349
|
+
0 && (module.exports = {
|
|
350
|
+
GtmPage,
|
|
351
|
+
JsonLd,
|
|
352
|
+
RouteProvider,
|
|
353
|
+
RouteSetter,
|
|
354
|
+
buildArticle,
|
|
355
|
+
buildBreadcrumb,
|
|
356
|
+
buildItemList,
|
|
357
|
+
buildWebSite,
|
|
358
|
+
chain,
|
|
359
|
+
filter,
|
|
360
|
+
getting,
|
|
361
|
+
gtmClick,
|
|
362
|
+
gtmFormSent,
|
|
363
|
+
gtmPageView,
|
|
364
|
+
headermiddleware,
|
|
365
|
+
posting,
|
|
366
|
+
redirectmiddleware,
|
|
367
|
+
setSeoData,
|
|
368
|
+
useRoute
|
|
369
|
+
});
|
|
370
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client/index.ts","../src/seo/index.ts","../src/jsonld/index.ts","../src/middleware/chain.ts","../src/middleware/headermiddleware.ts","../src/middleware/redirectmiddleware.ts","../src/components/RouteContext.tsx","../src/components/RouteSetter.tsx","../src/components/JsonLd.tsx","../src/components/GtmPage.tsx"],"sourcesContent":["export * from './client/index.js';\nexport * from './seo/index.js';\nexport * from './jsonld/index.js';\nexport * from './middleware/index.js';\nexport * from './components/index.js';\n","// 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","export interface SeoDataOptions {\n seo: any;\n route: any;\n /**\n * Locale codes for hreflang alternates. Last entry becomes x-default.\n * Defaults to ['it', 'en'] when omitted.\n */\n locales?: string[];\n}\n\nexport const setSeoData = ({ seo, route, locales = ['it', 'en'] }: SeoDataOptions) => {\n if (!seo) return {};\n\n const baseUrl = process.env.NEXT_PUBLIC_API_STORAGE_URL;\n const frontUrl = process.env.NEXT_PUBLIC_BASE_URL;\n const ogImg = seo.og_img?.original;\n const ogUrl = ogImg?.compressed\n ? baseUrl + ogImg.compressed\n : frontUrl + '/images/og-image.jpg';\n\n const languagesMap: Record<string, string> = {};\n for (const loc of locales) {\n if (route.slug?.[loc] !== undefined) {\n languagesMap[loc] = `/${loc}/${route.slug[loc]}`;\n }\n }\n const defaultLocale = locales[locales.length - 1];\n if (route.slug?.[defaultLocale] !== undefined) {\n languagesMap['x-default'] = `/${defaultLocale}/${route.slug[defaultLocale]}`;\n }\n\n return {\n metadataBase: new URL(`${process.env.NEXT_PUBLIC_BASE_URL}`),\n title: seo.meta_title || '',\n description: seo.meta_description || '',\n robots: {\n index: seo.index === 'index',\n follow: seo.follow === 'follow',\n },\n openGraph: {\n title: seo.og_title || '',\n description: seo.og_description || '',\n url: seo.opengraphUrl || '',\n siteName: seo.opengraphSiteName || '',\n images: [\n {\n url: ogUrl,\n width: ogImg?.width || 1200,\n height: ogImg?.height || 630,\n alt: ogImg?.alt || '',\n },\n ],\n locale: route.locale,\n type: seo.opengraphType || 'website',\n },\n alternates: {\n canonical: `${process.env.NEXT_PUBLIC_BASE_URL}/${route.locale}/${route.slug[route.locale]}`,\n languages: languagesMap,\n },\n };\n};\n","const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL!;\nconst STORAGE_URL = process.env.NEXT_PUBLIC_API_STORAGE_URL!;\nconst SITE_NAME = process.env.NEXT_PUBLIC_SITE_NAME ?? 'Website';\n\ntype BreadcrumbItem = { name: string; url: string };\n\nexport const buildBreadcrumb = (items: BreadcrumbItem[]) => ({\n '@context': 'https://schema.org',\n '@type': 'BreadcrumbList',\n itemListElement: items.map((item, index) => ({\n '@type': 'ListItem',\n position: index + 1,\n name: item.name,\n item: item.url,\n })),\n});\n\nexport const buildItemList = (items: any[], sectionUrl: string) => ({\n '@context': 'https://schema.org',\n '@type': 'ItemList',\n itemListElement: items.map((item, index) => ({\n '@type': 'ListItem',\n position: index + 1,\n name: item.title_txt_content || item.name_txt_general,\n url: `${sectionUrl}${item.slug_txt_general}/`,\n })),\n});\n\nexport const buildArticle = (\n page: any,\n pathname: string,\n articleType: 'Article' | 'NewsArticle' = 'Article',\n publisherName?: string,\n) => {\n const name = publisherName ?? SITE_NAME;\n const pageUrl = `${BASE_URL}${pathname.endsWith('/') ? pathname : pathname + '/'}`;\n const imageUrl = (page.primary ?? page.cover)?.original?.compressed\n ? `${STORAGE_URL}${(page.primary ?? page.cover).original.compressed}`\n : undefined;\n const description = page.subtitle\n ? page.subtitle.replace(/<[^>]*>/g, '').trim()\n : undefined;\n\n const publisher = {\n '@type': 'Organization',\n name,\n url: BASE_URL,\n logo: { '@type': 'ImageObject', url: `${BASE_URL}/images/logo/logo.png` },\n };\n\n return {\n '@context': 'https://schema.org',\n '@type': articleType,\n headline: page.title,\n ...(description && { description }),\n ...(imageUrl && { image: imageUrl }),\n url: pageUrl,\n author: publisher,\n publisher,\n ...(page.lastmod && { datePublished: page.lastmod, dateModified: page.lastmod }),\n };\n};\n\nexport const buildWebSite = (locale: string, siteName?: string) => ({\n '@context': 'https://schema.org',\n '@type': 'WebSite',\n name: siteName ?? SITE_NAME,\n url: `${BASE_URL}/${locale}/`,\n});\n","import { NextResponse } from 'next/server';\nimport type { NextMiddleware } from 'next/server';\n\nexport type MiddlewareFactory = (middleware: NextMiddleware) => NextMiddleware;\n\nexport function chain(functions: MiddlewareFactory[] = [], index = 0): NextMiddleware {\n const current = functions[index];\n if (current) {\n const next = chain(functions, index + 1);\n return current(next);\n }\n return () => NextResponse.next();\n}\n","import { NextRequest } from 'next/server';\nimport type { NextFetchEvent } from 'next/server';\nimport type { MiddlewareFactory } from './chain.js';\n\nexport const headermiddleware: MiddlewareFactory = (next) => {\n return async (request: NextRequest, _next: NextFetchEvent) => {\n const url = new URL(request.url);\n const params = new URLSearchParams(url.search);\n\n const headers = new Headers(request.headers);\n headers.set('x-current-path', request.nextUrl.pathname);\n headers.set('x-server', 'true');\n headers.set('olmo-preview', params.has('olmopreview').toString());\n\n return next(new NextRequest(request.url, { headers }), _next);\n };\n};\n","import { NextResponse } from 'next/server';\nimport type { NextFetchEvent, NextRequest } from 'next/server';\nimport type { MiddlewareFactory } from './chain.js';\n\ntype NextFetchRequestInit = RequestInit & { next?: { tags?: string[]; revalidate?: number | false } };\n\nexport const redirectmiddleware: MiddlewareFactory = (next) => {\n return async (request: NextRequest, _next: NextFetchEvent) => {\n if (request.headers.has('rsc')) {\n return next(request, _next);\n }\n\n if (!process.env.NEXT_PUBLIC_OLMO_TOKEN || !process.env.NEXT_PUBLIC_API_URL || !process.env.NEXT_PUBLIC_BASE_URL) {\n return next(request, _next);\n }\n\n const pathNameWithTrailingSlash = request.nextUrl.pathname;\n\n const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/all/redirect`, {\n method: 'GET',\n cache: 'force-cache',\n next: { tags: ['olmo', 'redirect'] },\n headers: { 'front-token': process.env.NEXT_PUBLIC_OLMO_TOKEN },\n } as NextFetchRequestInit);\n\n const data = await response.json();\n\n const redirects = data.map((e: any) => ({\n source: e.source,\n destination: e.destination,\n permanent: e.permanent === 'true',\n }));\n\n if (redirects.length > 0) {\n const redirect = redirects.find((item: any) => item.source === pathNameWithTrailingSlash);\n\n if (!redirect) {\n return next(request, _next);\n }\n\n const newUrl = new URL(redirect.destination, process.env.NEXT_PUBLIC_BASE_URL).toString();\n return NextResponse.redirect(newUrl, { status: redirect.permanent ? 308 : 307 });\n }\n\n return next(request, _next);\n };\n};\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;A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M,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_server","import_server","import_react","import_jsx_runtime","import_react","import_jsx_runtime"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export { filter, getting, posting } from './client/index.cjs';
|
|
2
|
+
export { SeoDataOptions, setSeoData } from './seo/index.cjs';
|
|
3
|
+
export { buildArticle, buildBreadcrumb, buildItemList, buildWebSite } from './jsonld/index.cjs';
|
|
4
|
+
export { MiddlewareFactory, chain, headermiddleware, redirectmiddleware } from './middleware/index.cjs';
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
+
import { ReactNode } from 'react';
|
|
7
|
+
import 'next/server';
|
|
8
|
+
|
|
9
|
+
type LocaleSlugs = Record<string, string>;
|
|
10
|
+
declare function RouteProvider({ children }: {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
}): react_jsx_runtime.JSX.Element;
|
|
13
|
+
declare const useRoute: () => {
|
|
14
|
+
slugs: LocaleSlugs;
|
|
15
|
+
setSlugs: (slugs: LocaleSlugs) => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
declare function RouteSetter({ slugs }: {
|
|
19
|
+
slugs: Record<string, string>;
|
|
20
|
+
}): null;
|
|
21
|
+
|
|
22
|
+
declare function JsonLd({ schema }: {
|
|
23
|
+
schema: object;
|
|
24
|
+
}): react_jsx_runtime.JSX.Element;
|
|
25
|
+
|
|
26
|
+
interface GtmPageProps {
|
|
27
|
+
slug: string | null;
|
|
28
|
+
lang: string | null;
|
|
29
|
+
name: string | null;
|
|
30
|
+
template: string | null;
|
|
31
|
+
}
|
|
32
|
+
interface GtmFormProps {
|
|
33
|
+
data: object | null;
|
|
34
|
+
name: string | null;
|
|
35
|
+
}
|
|
36
|
+
interface GtmClickProps {
|
|
37
|
+
category: string | null;
|
|
38
|
+
action: string | null;
|
|
39
|
+
label: string | null;
|
|
40
|
+
}
|
|
41
|
+
declare global {
|
|
42
|
+
interface Window {
|
|
43
|
+
dataLayer: any[];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
declare function GtmPage({ slug, lang, name, template }: GtmPageProps): react_jsx_runtime.JSX.Element;
|
|
47
|
+
declare function gtmPageView(props: Record<string, any>): number;
|
|
48
|
+
declare function gtmFormSent({ data, name }: GtmFormProps): number;
|
|
49
|
+
declare function gtmClick({ category, action, label }: GtmClickProps): number;
|
|
50
|
+
|
|
51
|
+
export { GtmPage, JsonLd, RouteProvider, RouteSetter, gtmClick, gtmFormSent, gtmPageView, useRoute };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export { filter, getting, posting } from './client/index.js';
|
|
2
|
+
export { SeoDataOptions, setSeoData } from './seo/index.js';
|
|
3
|
+
export { buildArticle, buildBreadcrumb, buildItemList, buildWebSite } from './jsonld/index.js';
|
|
4
|
+
export { MiddlewareFactory, chain, headermiddleware, redirectmiddleware } from './middleware/index.js';
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
+
import { ReactNode } from 'react';
|
|
7
|
+
import 'next/server';
|
|
8
|
+
|
|
9
|
+
type LocaleSlugs = Record<string, string>;
|
|
10
|
+
declare function RouteProvider({ children }: {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
}): react_jsx_runtime.JSX.Element;
|
|
13
|
+
declare const useRoute: () => {
|
|
14
|
+
slugs: LocaleSlugs;
|
|
15
|
+
setSlugs: (slugs: LocaleSlugs) => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
declare function RouteSetter({ slugs }: {
|
|
19
|
+
slugs: Record<string, string>;
|
|
20
|
+
}): null;
|
|
21
|
+
|
|
22
|
+
declare function JsonLd({ schema }: {
|
|
23
|
+
schema: object;
|
|
24
|
+
}): react_jsx_runtime.JSX.Element;
|
|
25
|
+
|
|
26
|
+
interface GtmPageProps {
|
|
27
|
+
slug: string | null;
|
|
28
|
+
lang: string | null;
|
|
29
|
+
name: string | null;
|
|
30
|
+
template: string | null;
|
|
31
|
+
}
|
|
32
|
+
interface GtmFormProps {
|
|
33
|
+
data: object | null;
|
|
34
|
+
name: string | null;
|
|
35
|
+
}
|
|
36
|
+
interface GtmClickProps {
|
|
37
|
+
category: string | null;
|
|
38
|
+
action: string | null;
|
|
39
|
+
label: string | null;
|
|
40
|
+
}
|
|
41
|
+
declare global {
|
|
42
|
+
interface Window {
|
|
43
|
+
dataLayer: any[];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
declare function GtmPage({ slug, lang, name, template }: GtmPageProps): react_jsx_runtime.JSX.Element;
|
|
47
|
+
declare function gtmPageView(props: Record<string, any>): number;
|
|
48
|
+
declare function gtmFormSent({ data, name }: GtmFormProps): number;
|
|
49
|
+
declare function gtmClick({ category, action, label }: GtmClickProps): number;
|
|
50
|
+
|
|
51
|
+
export { GtmPage, JsonLd, RouteProvider, RouteSetter, gtmClick, gtmFormSent, gtmPageView, useRoute };
|