@nextjs-cms-plugins/google-analytics 1.0.2 → 1.0.4
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.
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
type GoogleAnalyticsPageProps = {
|
|
2
|
+
title?: string;
|
|
3
|
+
};
|
|
4
|
+
export declare const GoogleAnalyticsPage: ({ title }: GoogleAnalyticsPageProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
5
|
export default GoogleAnalyticsPage;
|
|
3
6
|
//# sourceMappingURL=AnalyticsPage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsPage.d.ts","sourceRoot":"","sources":["../../src/client/AnalyticsPage.tsx"],"names":[],"mappings":"AAkBA,eAAO,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"AnalyticsPage.d.ts","sourceRoot":"","sources":["../../src/client/AnalyticsPage.tsx"],"names":[],"mappings":"AAkBA,KAAK,wBAAwB,GAAG;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,WAAW,wBAAwB,4CA4BtE,CAAA;AAED,eAAe,mBAAmB,CAAA"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { trpc as trpcClient } from 'nextjs-cms/api/trpc/client';
|
|
4
4
|
import { useI18n } from 'nextjs-cms/translations/client';
|
|
5
|
-
export const GoogleAnalyticsPage = () => {
|
|
5
|
+
export const GoogleAnalyticsPage = ({ title }) => {
|
|
6
6
|
const t = useI18n();
|
|
7
7
|
const trpc = trpcClient;
|
|
8
8
|
const query = trpc?.googleAnalytics?.test.useQuery;
|
|
@@ -10,6 +10,6 @@ export const GoogleAnalyticsPage = () => {
|
|
|
10
10
|
if (!query) {
|
|
11
11
|
return (_jsx("div", { className: 'p-6 text-sm text-red-500', children: "Google Analytics plugin misconfigured: missing trpc client." }));
|
|
12
12
|
}
|
|
13
|
-
return (_jsxs("div", { className: 'w-full', children: [_jsx("div", { className: 'text-foreground bg-linear-to-r from-sky-200 via-emerald-300 to-blue-600 p-8 font-extrabold dark:from-blue-800 dark:via-amber-700 dark:to-rose-900', children: _jsx("h1", { className: 'text-3xl', children: t('analytics') }) }), _jsxs("div", { className: 'p-4', children: [isLoading && _jsx("div", { className: 'text-muted-foreground', children: "Loading analytics\u2026" }), isError && !isLoading && (_jsx("div", { className: 'border-destructive/50 bg-destructive/10 text-destructive rounded border p-3 text-sm', children: error instanceof Error ? error.message : 'Unable to load analytics data' })), data ? _jsx("div", { className: 'text-muted-foreground text-sm', children: "Google Analytics connection OK." }) : null] })] }));
|
|
13
|
+
return (_jsxs("div", { className: 'w-full', children: [_jsx("div", { className: 'text-foreground bg-linear-to-r from-sky-200 via-emerald-300 to-blue-600 p-8 font-extrabold dark:from-blue-800 dark:via-amber-700 dark:to-rose-900', children: _jsx("h1", { className: 'text-3xl', children: title || t('analytics') }) }), _jsxs("div", { className: 'p-4', children: [isLoading && _jsx("div", { className: 'text-muted-foreground', children: "Loading analytics\u2026" }), isError && !isLoading && (_jsx("div", { className: 'border-destructive/50 bg-destructive/10 text-destructive rounded border p-3 text-sm', children: error instanceof Error ? error.message : 'Unable to load analytics data' })), data ? _jsx("div", { className: 'text-muted-foreground text-sm', children: "Google Analytics connection OK." }) : null] })] }));
|
|
14
14
|
};
|
|
15
15
|
export default GoogleAnalyticsPage;
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.tsx"],"names":[],"mappings":"AAOA,wBAA8B,qBAAqB,qDA6BlD"}
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { api, HydrateClient } from 'nextjs-cms/api/trpc/server';
|
|
3
3
|
import { GoogleAnalyticsPage } from './client/AnalyticsPage.js';
|
|
4
|
+
import { findPluginRouteByPath } from 'nextjs-cms/plugins/server';
|
|
5
|
+
import { resolveLocalizedString, resolveLocale } from 'nextjs-cms/translations';
|
|
6
|
+
import { getCMSConfig } from 'nextjs-cms/core';
|
|
7
|
+
import auth from 'nextjs-cms/auth';
|
|
4
8
|
export default async function GoogleAnalyticsServer() {
|
|
5
9
|
const helpers = api;
|
|
6
10
|
const prefetch = helpers.googleAnalytics?.test?.prefetch;
|
|
@@ -8,5 +12,14 @@ export default async function GoogleAnalyticsServer() {
|
|
|
8
12
|
throw new Error('[google-analytics] Missing googleAnalytics.test prefetch helper.');
|
|
9
13
|
}
|
|
10
14
|
await prefetch();
|
|
11
|
-
|
|
15
|
+
// Resolve the plugin route title
|
|
16
|
+
const [route, session, config] = await Promise.all([
|
|
17
|
+
findPluginRouteByPath('/google-analytics'),
|
|
18
|
+
auth(),
|
|
19
|
+
getCMSConfig(),
|
|
20
|
+
]);
|
|
21
|
+
const { supportedLanguages, fallbackLanguage } = config.i18n;
|
|
22
|
+
const locale = resolveLocale(session?.user?.locale, supportedLanguages, fallbackLanguage);
|
|
23
|
+
const resolvedTitle = route ? resolveLocalizedString(route.title, locale, fallbackLanguage) : '';
|
|
24
|
+
return (_jsx(HydrateClient, { children: _jsx(GoogleAnalyticsPage, { title: resolvedTitle }) }));
|
|
12
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextjs-cms-plugins/google-analytics",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": "19.2.3",
|
|
27
27
|
"react-dom": "19.2.3",
|
|
28
|
-
"nextjs-cms": "0.6.
|
|
28
|
+
"nextjs-cms": "0.6.4"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/react": "^19.2.7",
|