@remkoj/optimizely-cms-nextjs 1.0.4 → 2.0.0-pre1

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,24 +1,23 @@
1
1
  import { GraphQLClient } from "graphql-request";
2
- export type GetContentByPathVariables = {
2
+ export type GetContentByPathVariables<LocaleType = string> = {
3
3
  path: string;
4
- locale?: Array<string | null>[] | string | null;
4
+ locale?: Array<LocaleType | null> | LocaleType | null;
5
5
  siteId?: string | null;
6
6
  };
7
- export type GetContentByPathResponse = {
8
- Content?: {
9
- items?: {
10
- contentType?: Array<string | null> | null;
11
- id?: {
12
- id?: number | null;
13
- workId?: number | null;
14
- guidValue?: string | null;
15
- } | null;
16
- locale?: {
17
- name?: string | null;
18
- } | null;
19
- path?: string | null;
20
- }[];
21
- };
7
+ type MayBe<T> = T extends Array<infer R> ? Array<R | null> | null : T | null;
8
+ export type GetContentByPathResponse<LocaleType = string> = {
9
+ content?: MayBe<{
10
+ items?: MayBe<Array<{
11
+ _metadata?: MayBe<{
12
+ key?: MayBe<string>;
13
+ locale?: MayBe<LocaleType>;
14
+ types?: MayBe<Array<string>>;
15
+ displayName?: MayBe<string>;
16
+ version?: MayBe<string>;
17
+ }>;
18
+ _type?: MayBe<string>;
19
+ }>>;
20
+ }>;
22
21
  };
23
22
  export type GetMetaDataByPathResponse = {
24
23
  getGenericMetaData?: {
@@ -32,8 +31,8 @@ export type GetMetaDataByPathResponse = {
32
31
  } | null>;
33
32
  };
34
33
  };
35
- export type GetContentByPathMethod = (client: GraphQLClient, variables: GetContentByPathVariables) => Promise<GetContentByPathResponse>;
36
- export type GetMetaDataByPathMethod = (client: GraphQLClient, variables: GetContentByPathVariables) => Promise<GetMetaDataByPathResponse>;
34
+ export type GetContentByPathMethod<LocaleType = string> = (client: GraphQLClient, variables: GetContentByPathVariables<LocaleType>) => Promise<GetContentByPathResponse<LocaleType>>;
35
+ export type GetMetaDataByPathMethod<LocaleType = string> = (client: GraphQLClient, variables: GetContentByPathVariables<LocaleType>) => Promise<GetMetaDataByPathResponse>;
37
36
  export declare const getMetaDataByPath: GetMetaDataByPathMethod;
38
37
  export declare const getContentByPath: GetContentByPathMethod;
39
38
  export default getContentByPath;
@@ -6,25 +6,24 @@ export const getContentByPath = (client, variables) => {
6
6
  return client.request(contentQuery, variables);
7
7
  };
8
8
  export default getContentByPath;
9
- const contentQuery = gql `query getContentByPathBase($path: String!, $locale: [Locales], $siteId: String) {
10
- Content(
11
- where: { RelativePath: { eq: $path }, SiteId: { eq: $siteId } }
9
+ const contentQuery = gql `query getContentByPathBase($path: String!, $domain: String, $locale: [Locales]) {
10
+ content: Content(
11
+ where: { _metadata: { url: { hierarchical: { eq: $path }, base: { eq: $domain } } } }
12
12
  locale: $locale
13
13
  ) {
14
+ total
14
15
  items {
15
- contentType: ContentType
16
- id: ContentLink {
17
- id: Id
18
- workId: WorkId
19
- guidValue: GuidValue
20
- }
21
- locale: Language {
22
- name: Name
16
+ _metadata {
17
+ key
18
+ locale
19
+ types
20
+ displayName
21
+ version
23
22
  }
24
- path: RelativePath
23
+ _type: __typename
25
24
  }
26
25
  }
27
- }`;
26
+ }`;
28
27
  const metadataQuery = gql `query getGenericMetaData($path: String!, $locale: [Locales], $siteId: String) {
29
28
  getGenericMetaData: Content (
30
29
  where: { RelativePath: { eq: $path }, SiteId: { eq: $siteId } }
@@ -1 +1 @@
1
- {"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/cms-page/data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAiB,MAAM,iBAAiB,CAAA;AAyCpD,MAAM,CAAC,MAAM,iBAAiB,GAA4B,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE;IAE5E,OAAO,MAAM,CAAC,OAAO,CAAsD,aAAa,EAAE,SAAS,CAAC,CAAA;AACxG,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAA2B,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE;IAE1E,OAAO,MAAM,CAAC,OAAO,CAAqD,YAAY,EAAE,SAAS,CAAC,CAAA;AACtG,CAAC,CAAA;AAED,eAAe,gBAAgB,CAAA;AAE/B,MAAM,YAAY,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;EAkBtB,CAAA;AAEF,MAAM,aAAa,GAAG,GAAG,CAAA;;;;;;;;;;;;;;EAcvB,CAAA"}
1
+ {"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/cms-page/data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAiB,MAAM,iBAAiB,CAAA;AAyCpD,MAAM,CAAC,MAAM,iBAAiB,GAA4B,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE;IAE5E,OAAO,MAAM,CAAC,OAAO,CAAsD,aAAa,EAAE,SAAS,CAAC,CAAA;AACxG,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAA2B,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE;IAE1E,OAAO,MAAM,CAAC,OAAO,CAAqD,YAAY,EAAE,SAAS,CAAC,CAAA;AACtG,CAAC,CAAA;AAED,eAAe,gBAAgB,CAAA;AAE/B,MAAM,YAAY,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;IAiBpB,CAAA;AAEJ,MAAM,aAAa,GAAG,GAAG,CAAA;;;;;;;;;;;;;;EAcvB,CAAA"}
@@ -1,5 +1,5 @@
1
1
  export type { GetContentByPathMethod, GetMetaDataByPathMethod } from './data';
2
- export type { CreatePageOptions, Props as CmsPageProps, Params as CmsPageParams } from './page';
2
+ export type { CreatePageOptions, DefaultCmsPageProps as CmsPageProps, DefaultCmsPageParams as CmsPageParams } from './page';
3
3
  export type { CreateLayoutOptions } from './layout';
4
4
  export { createPage } from './page';
5
5
  export { createLayout } from './layout';
@@ -1,16 +1,17 @@
1
1
  import { type PropsWithChildren, type ReactNode } from "react";
2
2
  import { type Metadata, type ResolvingMetadata } from "next";
3
3
  import type { ChannelDefinition, ClientFactory } from "@remkoj/optimizely-graph-client";
4
- import type { Props } from './page';
4
+ import type { DefaultCmsPageProps } from './page';
5
5
  import { type GetMetaDataByPathMethod } from './data';
6
6
  export type CmsPageLayout = {
7
- generateMetadata: (props: Omit<Props, 'searchParams'>, resolving: ResolvingMetadata) => Promise<Metadata>;
8
- PageLayout: (props: PropsWithChildren<Omit<Props, 'searchParams'>>) => JSX.Element | ReactNode;
7
+ generateMetadata: (props: Omit<DefaultCmsPageProps, 'searchParams'>, resolving: ResolvingMetadata) => Promise<Metadata>;
8
+ PageLayout: (props: PropsWithChildren<Omit<DefaultCmsPageProps, 'searchParams'>>) => JSX.Element | ReactNode;
9
9
  };
10
10
  export type CreateLayoutOptions = {
11
- defaultLocale: string;
11
+ defaultLocale: string | null;
12
12
  getMetaDataByPath: GetMetaDataByPathMethod;
13
13
  client: ClientFactory;
14
+ channel?: ChannelDefinition;
14
15
  };
15
- export declare function createLayout(channel: ChannelDefinition, options?: Partial<CreateLayoutOptions>): CmsPageLayout;
16
+ export declare function createLayout(options?: Partial<CreateLayoutOptions>): CmsPageLayout;
16
17
  export default createLayout;
@@ -1,17 +1,16 @@
1
1
  import { Utils } from "@remkoj/optimizely-cms-react";
2
2
  import { getMetaDataByPath as getMetaDataByPathBase } from './data';
3
- import { slugToLocale, slugToGraphLocale } from "./utils";
4
3
  import { getServerClient } from "../client";
5
4
  import { isDebug } from '@remkoj/optimizely-cms-react/rsc';
6
5
  const defaultCreateLayoutOptions = {
7
- defaultLocale: "en",
6
+ defaultLocale: null,
8
7
  getMetaDataByPath: getMetaDataByPathBase,
9
8
  client: getServerClient
10
9
  };
11
- export function createLayout(channel, options) {
12
- const { defaultLocale, getMetaDataByPath, client: clientFactory } = {
10
+ export function createLayout(options) {
11
+ const { defaultLocale, getMetaDataByPath, client: clientFactory, channel } = {
13
12
  ...defaultCreateLayoutOptions,
14
- ...{ defaultLocale: channel.defaultLocale },
13
+ ...{ defaultLocale: null },
15
14
  ...options
16
15
  };
17
16
  const pageLayoutDefinition = {
@@ -23,13 +22,11 @@ export function createLayout(channel, options) {
23
22
  * @returns The metadata that must be merged into the defaults
24
23
  */
25
24
  generateMetadata: async ({ params }, resolving) => {
26
- const locale = slugToLocale(channel, params?.lang ?? '', defaultLocale);
27
- const relativePath = `/${params.lang}${params.path ? '/' + params.path.join('/') : ''}`;
25
+ const relativePath = `/${params.path ? '/' + params.path.join('/') : ''}`;
28
26
  if (isDebug())
29
27
  console.log(`⚪ [CmsPageLayout] Generating metadata for: ${relativePath}`);
30
28
  const variables = {
31
- path: relativePath,
32
- locale: slugToGraphLocale(channel, params.lang ?? '', defaultLocale)
29
+ path: relativePath
33
30
  };
34
31
  const client = clientFactory();
35
32
  const response = await getMetaDataByPath(client, variables).catch(e => {
@@ -61,7 +58,7 @@ export function createLayout(channel, options) {
61
58
  }
62
59
  };
63
60
  // Add alternative URLs
64
- const alternates = (metadata?.alternatives || []).filter(Utils.isNotNullOrUndefined).filter(x => x.locale != locale);
61
+ const alternates = (metadata?.alternatives || []).filter(Utils.isNotNullOrUndefined);
65
62
  alternates.forEach(alt => {
66
63
  if (pageMetadata.openGraph && Array.isArray(pageMetadata.openGraph.alternateLocale)) {
67
64
  pageMetadata.openGraph.alternateLocale.push(alt.locale);
@@ -1 +1 @@
1
- {"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/cms-page/layout.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAEpD,OAAO,EAAE,iBAAiB,IAAI,qBAAqB,EAAgC,MAAM,QAAQ,CAAA;AACjG,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAA;AAa1D,MAAM,0BAA0B,GAAyB;IACrD,aAAa,EAAE,IAAI;IACnB,iBAAiB,EAAE,qBAAq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CAAC,SAAmB;oBACjC,eAAe,EAAE,EAAE;iBACtB;aACJ,CAAA;YAED,uBAAuB;YACvB,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,YAAY,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAoC,CAAA;YACvH,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBACrB,IAAI,YAAY,CAAC,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC;oBAClF,YAAY,CAAC,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;gBAC3D,CAAC;gBACD,IAAI,YAAY,CAAC,UAAU,IAAI,YAAY,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;oBAC/D,+FAA+F;oBAC/F,YAAY,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,CAAA;gBAC5D,CAAC;YACL,CAAC,CAAC,CAAA;YAEF,OAAO,YAAY,CAAA;QACvB,CAAC;QAED,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ;KACzC,CAAA;IACD,OAAO,oBAAoB,CAAA;AAC/B,CAAC;AAED,eAAe,YAAY,CAAA"}
@@ -1,28 +1,43 @@
1
1
  /// <reference types="react" />
2
2
  import 'server-only';
3
3
  import type { Metadata, ResolvingMetadata } from 'next';
4
- import { type ClientFactory, type ChannelDefinition } from '@remkoj/optimizely-graph-client';
4
+ import { type Route, type ClientFactory, type ChannelDefinition } from '@remkoj/optimizely-graph-client';
5
5
  import { type ComponentFactory } from '@remkoj/optimizely-cms-react/rsc';
6
6
  import { type GetContentByPathMethod } from './data';
7
- export type Params = {
8
- path: string[] | undefined;
9
- lang: string | undefined;
7
+ export type DefaultCmsPageParams = {
8
+ path?: string[];
9
+ lang?: string;
10
10
  };
11
- export type Props = {
12
- params: Params;
13
- searchParams: {};
11
+ export type DefaultCmsPageSearchParams = {};
12
+ export type DefaultCmsPageProps<TParams extends Record<string, string | Array<string> | undefined> = DefaultCmsPageParams, TSearchParams extends Record<string, string | Array<string> | undefined> = DefaultCmsPageSearchParams> = {
13
+ params: TParams;
14
+ searchParams: TSearchParams;
14
15
  };
15
- export type GenerateMetadataProps<TParams extends {} = {}, TSearch extends {} = {}> = {
16
- params: Params;
16
+ export type OptiCmsNextJsPage<TParams extends Record<string, string | Array<string> | undefined> = DefaultCmsPageParams, TSearchParams extends Record<string, string | Array<string> | undefined> = DefaultCmsPageSearchParams> = {
17
+ generateStaticParams: () => Promise<TParams[]>;
18
+ generateMetadata: (props: DefaultCmsPageProps<TParams, TSearchParams>, resolving: ResolvingMetadata) => Promise<Metadata>;
19
+ CmsPage: (props: DefaultCmsPageProps<TParams, TSearchParams>) => Promise<JSX.Element>;
17
20
  };
18
- export type NextJsPage = {
19
- generateStaticParams: () => Promise<Params[]>;
20
- generateMetadata: (props: Props, resolving: ResolvingMetadata) => Promise<Metadata>;
21
- CmsPage: (props: Props) => Promise<JSX.Element>;
22
- };
23
- export type CreatePageOptions = {
24
- defaultLocale: string;
25
- getContentByPath: GetContentByPathMethod;
21
+ export declare enum SystemLocales {
22
+ All = "ALL",
23
+ Neutral = "NEUTRAL"
24
+ }
25
+ export type CreatePageOptions<LocaleEnum = SystemLocales, TParams extends Record<string, string | Array<string> | undefined> = DefaultCmsPageParams, TSearchParams extends Record<string, string | Array<string> | undefined> = DefaultCmsPageSearchParams> = {
26
+ defaultLocale: LocaleEnum | null;
27
+ getContentByPath: GetContentByPathMethod<LocaleEnum>;
26
28
  client: ClientFactory;
29
+ channel?: ChannelDefinition;
30
+ propsToCmsPath: (props: DefaultCmsPageProps<TParams, TSearchParams>) => string | null;
31
+ propsToCmsLocale: (props: DefaultCmsPageProps<TParams, TSearchParams>, locale: LocaleEnum | null) => LocaleEnum | null;
32
+ routeToParams: (route: Route) => TParams;
27
33
  };
28
- export declare function createPage(factory: ComponentFactory, channel: ChannelDefinition, options?: Partial<CreatePageOptions>): NextJsPage;
34
+ /**
35
+ * Generate the React Server Side component and Next.JS functions needed to render an
36
+ * Optimizely CMS page. This component assumes that the routes are either defined as
37
+ * /[lang]/[[...path]] or /[[...path]]
38
+ *
39
+ * @param factory The component factory to use for this page
40
+ * @param options The page component generation options
41
+ * @returns The Optimizely CMS Page
42
+ */
43
+ export declare function createPage<LocaleEnum = SystemLocales, TParams extends Record<string, string | Array<string> | undefined> = DefaultCmsPageParams, TSearchParams extends Record<string, string | Array<string> | undefined> = DefaultCmsPageSearchParams>(factory: ComponentFactory, options?: Partial<CreatePageOptions<LocaleEnum, TParams, TSearchParams>>): OptiCmsNextJsPage;
@@ -3,38 +3,52 @@ import 'server-only';
3
3
  import deepmerge from 'deepmerge';
4
4
  import { notFound } from 'next/navigation';
5
5
  import { RouteResolver } from '@remkoj/optimizely-graph-client';
6
+ import { normalizeContentLinkWithLocale } from '@remkoj/optimizely-graph-client/utils';
6
7
  import { CmsContent, isDebug, getServerContext } from '@remkoj/optimizely-cms-react/rsc';
7
8
  import { Utils } from '@remkoj/optimizely-cms-react';
8
9
  import { MetaDataResolver } from '../metadata';
9
10
  import { urlToPath, localeToGraphLocale } from './utils';
10
11
  import getContentByPathBase from './data';
11
12
  import { getServerClient } from '../client';
13
+ export var SystemLocales;
14
+ (function (SystemLocales) {
15
+ SystemLocales["All"] = "ALL";
16
+ SystemLocales["Neutral"] = "NEUTRAL";
17
+ })(SystemLocales || (SystemLocales = {}));
12
18
  const CreatePageOptionDefaults = {
13
- defaultLocale: "en",
19
+ defaultLocale: null,
14
20
  getContentByPath: getContentByPathBase,
15
- client: getServerClient
21
+ client: getServerClient,
22
+ propsToCmsPath: ({ params }) => buildRequestPath(params),
23
+ propsToCmsLocale: ({ params }, defaultLocale) => params?.lang ?? defaultLocale ?? null,
24
+ routeToParams: (route) => { return { path: urlToPath(route.url, route.locale), lang: route.locale }; }
16
25
  };
17
- export function createPage(factory, channel, options) {
18
- const { defaultLocale, getContentByPath, client: clientFactory } = {
26
+ /**
27
+ * Generate the React Server Side component and Next.JS functions needed to render an
28
+ * Optimizely CMS page. This component assumes that the routes are either defined as
29
+ * /[lang]/[[...path]] or /[[...path]]
30
+ *
31
+ * @param factory The component factory to use for this page
32
+ * @param options The page component generation options
33
+ * @returns The Optimizely CMS Page
34
+ */
35
+ export function createPage(factory, options) {
36
+ const { defaultLocale, getContentByPath, client: clientFactory, channel, propsToCmsLocale, propsToCmsPath, routeToParams } = {
19
37
  ...CreatePageOptionDefaults,
20
- ...{ defaultLocale: channel.defaultLocale },
21
38
  ...options
22
39
  };
23
40
  const pageDefintion = {
24
41
  generateStaticParams: async () => {
25
42
  const client = clientFactory();
26
43
  const resolver = new RouteResolver(client);
27
- return (await resolver.getRoutes()).map(r => {
28
- return {
29
- lang: channel.localeToSlug(r.language),
30
- path: urlToPath(r.url, r.language)
31
- };
32
- });
44
+ return (await resolver.getRoutes()).map(r => routeToParams(r));
33
45
  },
34
- generateMetadata: async ({ params: { lang, path } }, resolving) => {
46
+ generateMetadata: async (props, resolving) => {
35
47
  // Read variables from request
36
48
  const client = clientFactory();
37
- const requestPath = buildRequestPath({ lang, path });
49
+ const requestPath = propsToCmsPath(props);
50
+ if (!requestPath)
51
+ return Promise.resolve({});
38
52
  const routeResolver = new RouteResolver(client);
39
53
  const metaResolver = new MetaDataResolver(client);
40
54
  // Resolve the route to a content link
@@ -42,12 +56,12 @@ export function createPage(factory, channel, options) {
42
56
  if (!route)
43
57
  return Promise.resolve({});
44
58
  // Set context
45
- getServerContext().setLocale(localeToGraphLocale(channel, route.language));
59
+ getServerContext().setLocale(localeToGraphLocale(route.locale, channel));
46
60
  getServerContext().setOptimizelyGraphClient(client);
47
61
  // Prepare metadata fetching
48
62
  const contentLink = routeResolver.routeToContentLink(route);
49
63
  const contentType = route.contentType;
50
- const graphLocale = localeToGraphLocale(channel, route.language);
64
+ const graphLocale = channel ? localeToGraphLocale(route.locale, channel) : null;
51
65
  // Fetch the metadata based upon the actual content type and resolve parent
52
66
  const [pageMetadata, baseMetadata] = await Promise.all([
53
67
  metaResolver.resolve(factory, contentLink, contentType, graphLocale),
@@ -66,21 +80,24 @@ export function createPage(factory, channel, options) {
66
80
  }
67
81
  return pageMetadata;
68
82
  },
69
- CmsPage: async ({ params: { lang, path } }) => {
70
- if (!lang || lang.length == 0)
71
- return notFound();
83
+ CmsPage: async (props) => {
72
84
  // Prepare the context
73
85
  const context = getServerContext();
74
86
  const client = context.client ?? clientFactory();
75
87
  if (!context.client)
76
88
  context.setOptimizelyGraphClient(client);
77
89
  context.setComponentFactory(factory);
90
+ // Analyze the locale
91
+ const currentLocale = propsToCmsLocale(props, defaultLocale);
92
+ const graphLocale = (currentLocale ? localeToGraphLocale(currentLocale, channel) : undefined);
93
+ if (currentLocale)
94
+ context.setLocale(currentLocale);
78
95
  // Resolve the content based upon the route
79
- const requestPath = buildRequestPath({ lang, path });
80
- const graphLocale = channel.slugToGraphLocale(lang);
81
- const response = await getContentByPath(client, { path: requestPath, locale: graphLocale, siteId: channel.id });
82
- const info = (response.Content?.items ?? [])[0];
83
- context.setLocale(graphLocale);
96
+ const requestPath = propsToCmsPath(props);
97
+ if (!requestPath)
98
+ return notFound();
99
+ const response = await getContentByPath(client, { path: requestPath, locale: graphLocale });
100
+ const info = (response?.content?.items ?? [])[0];
84
101
  if (!info) {
85
102
  if (isDebug()) {
86
103
  console.error(`🔴 [CmsPage] Unable to load content for ${requestPath}, data received: `, response);
@@ -88,8 +105,10 @@ export function createPage(factory, channel, options) {
88
105
  return notFound();
89
106
  }
90
107
  // Extract the type & link
91
- const contentType = Utils.normalizeContentType(info.contentType);
92
- const contentLink = Utils.normalizeContentLinkWithLocale({ ...info.id, locale: info.locale?.name });
108
+ const contentType = Utils.normalizeContentType(info._metadata?.types);
109
+ const contentLink = normalizeContentLinkWithLocale(info._metadata);
110
+ if (contentLink?.locale)
111
+ context.setLocale(contentLink?.locale);
93
112
  if (!contentLink) {
94
113
  console.error("🔴 [CmsPage] Unable to infer the contentLink from the retrieved content, this should not have happened!");
95
114
  return notFound();
@@ -100,9 +119,23 @@ export function createPage(factory, channel, options) {
100
119
  };
101
120
  return pageDefintion;
102
121
  }
122
+ /**
123
+ *
124
+ *
125
+ * @param param0 The URL parameters
126
+ * @returns The request path as understood by Graph
127
+ */
103
128
  function buildRequestPath({ lang, path }) {
104
- return (path?.length ?? 0) > 0 ?
105
- `/${lang ?? ""}/${path?.join("/") ?? ""}` :
106
- `/${lang ?? ""}`;
129
+ const slugs = [];
130
+ if (path)
131
+ slugs.push(...path.filter(x => x));
132
+ if (lang)
133
+ slugs.unshift(lang);
134
+ if (slugs.length == 0)
135
+ return '/';
136
+ const fullPath = '/' + slugs.filter(x => x && x.length > 0).join('/');
137
+ if (!slugs[slugs.length - 1].includes('.'))
138
+ return fullPath + '/';
139
+ return fullPath;
107
140
  }
108
141
  //# sourceMappingURL=page.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"page.js","sourceRoot":"","sources":["../../src/cms-page/page.tsx"],"names":[],"mappings":";AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,aAAa,EAA8C,MAAM,iCAAiC,CAAA;AAC3G,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAyB,MAAM,kCAAkC,CAAA;AAC/G,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AACxD,OAAO,oBAAqD,MAAM,QAAQ,CAAA;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AA4B3C,MAAM,wBAAwB,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type { ChannelDefinition } from "@remkoj/optimizely-graph-client";
2
- export declare function urlToPath(baseUrl: URL, language: string): string[];
3
- export declare function localeToGraphLocale(channel: ChannelDefinition, locale: string): string;
2
+ export declare function urlToPath(baseUrl: URL, language?: string): string[];
3
+ /**
4
+ * Transform a locale to an Optimizely Graph locale, defaulting to the lookup
5
+ * table in the Channel definition, falling back to the programmatic approach
6
+ * after.
7
+ *
8
+ * @param locale
9
+ * @param channel
10
+ * @returns
11
+ */
12
+ export declare function localeToGraphLocale(locale: string, channel?: ChannelDefinition): string;
4
13
  export declare function slugToLocale<T extends string | undefined | null>(channel: ChannelDefinition, slug: string, defaultValue: T): string | T;
5
14
  export declare function slugToGraphLocale<T extends string | undefined | null>(channel: ChannelDefinition, slug: string, defaultValue: T): string | T;
@@ -1,12 +1,22 @@
1
+ import { localeToGraphLocale as coreLocaleToGraphLocale } from "@remkoj/optimizely-graph-client/utils";
1
2
  // Extract the path as string array from a given URL
2
3
  export function urlToPath(baseUrl, language) {
3
4
  let slugs = baseUrl.pathname.split('/').filter(s => s);
4
- if (slugs[0] == language)
5
+ if (language && slugs[0] == language)
5
6
  slugs.shift();
6
7
  return slugs;
7
8
  }
8
- export function localeToGraphLocale(channel, locale) {
9
- return channel.localeToGraphLocale(locale) ?? locale.replaceAll("-", "_");
9
+ /**
10
+ * Transform a locale to an Optimizely Graph locale, defaulting to the lookup
11
+ * table in the Channel definition, falling back to the programmatic approach
12
+ * after.
13
+ *
14
+ * @param locale
15
+ * @param channel
16
+ * @returns
17
+ */
18
+ export function localeToGraphLocale(locale, channel) {
19
+ return channel?.localeToGraphLocale(locale) ?? coreLocaleToGraphLocale(locale);
10
20
  }
11
21
  export function slugToLocale(channel, slug, defaultValue) {
12
22
  const route = channel.locales.filter(x => x.slug == slug)[0];
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/cms-page/utils.ts"],"names":[],"mappings":"AAEA,oDAAoD;AACpD,MAAM,UAAU,SAAS,CA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QAAiB;IACrD,IAAI,KAAK,GAAc,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACjE,IAAI,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,QAAQ;QAChC,KAAK,CAAC,KAAK,EAAE,CAAA;IACjB,OAAO,KAAK,CAAA;AAChB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAc,EAAE,OAA2B;IAE3E,OAAO,OAAO,EAAE,mBAAmB,CAAC,MAAM,CAAC,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAA;AAClF,CAAC;AAED,MAAM,UAAU,YAAY,CAAsC,OAA0B,EAAE,IAAY,EAAE,YAAe;IAEvH,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IAC5D,OAAO,KAAK,EAAE,IAAI,IAAI,YAAY,CAAA;AACtC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAsC,OAA0B,EAAE,IAAY,EAAE,YAAe;IAE5H,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IAC5D,OAAO,KAAK,EAAE,WAAW,IAAI,YAAY,EAAE,UAAU,CAAC,GAAG,EAAC,GAAG,CAAM,CAAA;AACvE,CAAC"}
@@ -1,8 +1,6 @@
1
1
  'use client';
2
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
3
2
  import { useState, useEffect } from 'react';
4
3
  import { useRouter } from 'next/navigation';
5
- const DEV = process.env.NODE_ENV == 'development';
6
4
  export const OnPageEdit = ({ mode, children, className, timeout }) => {
7
5
  const router = useRouter();
8
6
  const [optiCmsReady, setOptiCmsReady] = useState(false);
@@ -37,41 +35,52 @@ export const OnPageEdit = ({ mode, children, className, timeout }) => {
37
35
  // Define event handler
38
36
  let maskTimer = false;
39
37
  function onContentSaved(eventData) {
38
+ // If the effect has been undone, disable this handler
39
+ if (!handlerEnabled)
40
+ return;
40
41
  setShowMask(true);
41
42
  if (maskTimer != false)
42
43
  clearTimeout(maskTimer);
43
- console.log(`Delaying refresh with ${timeout}ms to allow Optimizely Graph to update`);
44
+ console.log(`Delaying refresh with ${timeout}ms to allow Optimizely Graph to update`, eventData);
44
45
  maskTimer = setTimeout(() => {
45
46
  const contentId = window.location.pathname.split(',,')[1];
46
- const newContentId = eventData.contentLink;
47
- if (previewUrl == eventData.previewUrl) {
48
- console.log(`Refreshing preview: ${contentId} => ${newContentId}`);
49
- router.refresh();
50
- //setShowMask(false)
51
- }
52
- else {
47
+ const newContentId = eventData?.contentLink;
48
+ // First: Use the updated preview URL if we have it
49
+ if (eventData?.previewUrl && previewUrl != eventData.previewUrl) {
53
50
  const newUrl = new URL(eventData.previewUrl);
54
- console.log(`Navigating to new preview: ${contentId} => ${newContentId}`);
51
+ console.log(`Navigating to provided preview path: ${newUrl.pathname}${newUrl.search}`);
52
+ router.push(newUrl.pathname + newUrl.search);
53
+ // Second: Use the provided Content ID to navigate to the new URL
54
+ }
55
+ else if (newContentId && contentId != newContentId) {
56
+ const newUrl = new URL(window.location.href);
57
+ const pathParts = newUrl.pathname.split(',,');
58
+ pathParts[1] = newContentId;
59
+ newUrl.pathname = pathParts.join(',,');
60
+ console.log(`Navigating to newly constructed URL to reflect ContentID change: ${newUrl.href}`);
55
61
  router.push(newUrl.pathname + newUrl.search);
56
- setShowMask(false);
62
+ // Third: Refresh the page
57
63
  }
64
+ else {
65
+ console.log(`Refreshing preview: ${contentId}`);
66
+ router.refresh();
67
+ }
68
+ setShowMask(false);
58
69
  }, timeout);
59
70
  }
60
71
  // Subscribe to event
61
72
  console.log(`Subscribing to ContentSaved Event`);
62
73
  const opti = tryGetCms();
63
- opti?.subscribe('contentSaved', (eventData) => {
64
- if (!handlerEnabled)
65
- return;
66
- onContentSaved(eventData);
67
- });
74
+ opti?.subscribe('contentSaved', onContentSaved);
68
75
  // Unsubscribe when needed
69
76
  return () => {
70
77
  console.log(`Navigating away, disabling ContentSaved event handler`);
78
+ if (maskTimer != false)
79
+ clearTimeout(maskTimer);
71
80
  handlerEnabled = false;
72
81
  };
73
82
  }, [optiCmsReady, router, timeout]);
74
- return _jsx(_Fragment, { children: showMask && _jsx("div", { className: `loading-mask ${className}`.trimEnd(), children: children }) });
83
+ return showMask ? children : null;
75
84
  };
76
85
  function tryGetCms() {
77
86
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"on-page-edit.js","sourceRoot":"","sources":["../../src/components/on-page-edit.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAc,EAAE,QAAQ,EAAE,SAAS,EAAkD,MAAM,OAAO,CAAA;AAClG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AA2B3C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,CAAA;AAEjD,MAAM,CAAC,MAAM,UAAU,GAAwC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE;IAEtG,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,CAAE,YAAY,EAAE,eAAe,CAAE,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAA;IAClE,MAAM,CAAE,QAAQ,EAAE,WAAW,CAAE,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAA;IAC1D,OAAO,GAAG,OAAO,IAAI,IAAI,CAAA;IAEzB,oCAAoC;IACpC,SAAS,CAAC,GAAG,EAAE;QACX,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA;QACvC,MAAM,KAAK,GAAG,SAAS,E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CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAA;AACrC,CAAC,CAAA;AAED,SAAS,SAAS;IAEd,IAAI,CAAC;QACD,OAAO,MAAM,CAAC,GAAG,CAAA;IACrB,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,SAAS,CAAA;IACpB,CAAC;AACL,CAAC;AAED,eAAe,UAAU,CAAA"}
@@ -13,6 +13,6 @@ export declare class MetaDataResolver {
13
13
  * @param locale The locale to be used, in a ContentGraph locale format
14
14
  * @returns A Promise for the metadata of the given content type & instance
15
15
  */
16
- resolve(factory: ComponentFactory, contentLink: ContentLink, contentType: string[], locale: string): Promise<Metadata>;
16
+ resolve(factory: ComponentFactory, contentLink: ContentLink, contentType: string[], locale?: string | null): Promise<Metadata>;
17
17
  }
18
18
  export default MetaDataResolver;