@sitecore-content-sdk/nextjs 2.0.2-canary.7 → 2.0.2-canary.8

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.
@@ -52,6 +52,7 @@ exports.Link = void 0;
52
52
  const react_1 = __importStar(require("react"));
53
53
  const link_1 = __importDefault(require("next/link"));
54
54
  const react_2 = require("@sitecore-content-sdk/react");
55
+ const router_1 = require("next/compat/router");
55
56
  /**
56
57
  * The list of NextLink props to be supported by the Link component.
57
58
  */
@@ -73,6 +74,7 @@ const FILE_EXTENSION_MATCHER = /^\/.*\.\w+$/;
73
74
  * @public
74
75
  */
75
76
  exports.Link = (0, react_1.forwardRef)((props, ref) => {
77
+ const pageRouter = (0, router_1.useRouter)();
76
78
  const { field, editable = true, children, internalLinkMatcher = /^\//g, showLinkTextWithChildrenPresent } = props, rest = __rest(props, ["field", "editable", "children", "internalLinkMatcher", "showLinkTextWithChildrenPresent"]);
77
79
  if (!field || (!field.value && !field.href && !field.metadata)) {
78
80
  return null;
@@ -87,10 +89,13 @@ exports.Link = (0, react_1.forwardRef)((props, ref) => {
87
89
  const isFileUrl = FILE_EXTENSION_MATCHER.test(href);
88
90
  // determine if a link is a route or not. File extensions are not routes and should not be pre-fetched.
89
91
  if (isMatching && !isFileUrl) {
90
- return (react_1.default.createElement(link_1.default, Object.assign({ href: { pathname: href, query: querystring, hash: anchor }, key: "link", title: value.title, target: value.target, className: value.class }, rest, { locale: false, ref: ref }, (process.env.TEST
92
+ return (react_1.default.createElement(link_1.default, Object.assign({ href: { pathname: href, query: querystring, hash: anchor }, key: "link", title: value.title, target: value.target, className: value.class }, rest, {
93
+ // locale prop is supported only in Pages Router
94
+ locale: pageRouter ? false : undefined, ref: ref }, (process.env.TEST
91
95
  ? {
92
96
  'data-nextjs-link': true,
93
97
  'data-nextjs-prefetch': props.prefetch,
98
+ 'data-nextjs-locale': pageRouter ? false : undefined,
94
99
  }
95
100
  : {})),
96
101
  text,
@@ -13,6 +13,7 @@ var __rest = (this && this.__rest) || function (s, e) {
13
13
  import React, { forwardRef } from 'react';
14
14
  import NextLink from 'next/link';
15
15
  import { Link as ReactLink, } from '@sitecore-content-sdk/react';
16
+ import { useRouter as usePageRouter } from 'next/compat/router';
16
17
  /**
17
18
  * The list of NextLink props to be supported by the Link component.
18
19
  */
@@ -34,6 +35,7 @@ const FILE_EXTENSION_MATCHER = /^\/.*\.\w+$/;
34
35
  * @public
35
36
  */
36
37
  export const Link = forwardRef((props, ref) => {
38
+ const pageRouter = usePageRouter();
37
39
  const { field, editable = true, children, internalLinkMatcher = /^\//g, showLinkTextWithChildrenPresent } = props, rest = __rest(props, ["field", "editable", "children", "internalLinkMatcher", "showLinkTextWithChildrenPresent"]);
38
40
  if (!field || (!field.value && !field.href && !field.metadata)) {
39
41
  return null;
@@ -48,10 +50,13 @@ export const Link = forwardRef((props, ref) => {
48
50
  const isFileUrl = FILE_EXTENSION_MATCHER.test(href);
49
51
  // determine if a link is a route or not. File extensions are not routes and should not be pre-fetched.
50
52
  if (isMatching && !isFileUrl) {
51
- return (React.createElement(NextLink, Object.assign({ href: { pathname: href, query: querystring, hash: anchor }, key: "link", title: value.title, target: value.target, className: value.class }, rest, { locale: false, ref: ref }, (process.env.TEST
53
+ return (React.createElement(NextLink, Object.assign({ href: { pathname: href, query: querystring, hash: anchor }, key: "link", title: value.title, target: value.target, className: value.class }, rest, {
54
+ // locale prop is supported only in Pages Router
55
+ locale: pageRouter ? false : undefined, ref: ref }, (process.env.TEST
52
56
  ? {
53
57
  'data-nextjs-link': true,
54
58
  'data-nextjs-prefetch': props.prefetch,
59
+ 'data-nextjs-locale': pageRouter ? false : undefined,
55
60
  }
56
61
  : {})),
57
62
  text,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-content-sdk/nextjs",
3
- "version": "2.0.2-canary.7",
3
+ "version": "2.0.2-canary.8",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -32,8 +32,8 @@
32
32
  "url": "https://github.com/sitecore/content-sdk/issues"
33
33
  },
34
34
  "devDependencies": {
35
- "@sitecore-content-sdk/analytics-core": "2.0.2-canary.7",
36
- "@sitecore-content-sdk/personalize": "2.0.2-canary.7",
35
+ "@sitecore-content-sdk/analytics-core": "2.0.2-canary.8",
36
+ "@sitecore-content-sdk/personalize": "2.0.2-canary.8",
37
37
  "@stylistic/eslint-plugin": "^5.2.2",
38
38
  "@testing-library/dom": "^10.4.0",
39
39
  "@testing-library/react": "^16.3.0",
@@ -91,10 +91,10 @@
91
91
  },
92
92
  "dependencies": {
93
93
  "@babel/parser": "^7.27.2",
94
- "@sitecore-content-sdk/content": "2.0.2-canary.7",
95
- "@sitecore-content-sdk/core": "2.0.2-canary.7",
96
- "@sitecore-content-sdk/events": "2.0.2-canary.7",
97
- "@sitecore-content-sdk/react": "2.0.2-canary.7",
94
+ "@sitecore-content-sdk/content": "2.0.2-canary.8",
95
+ "@sitecore-content-sdk/core": "2.0.2-canary.8",
96
+ "@sitecore-content-sdk/events": "2.0.2-canary.8",
97
+ "@sitecore-content-sdk/react": "2.0.2-canary.8",
98
98
  "recast": "^0.23.11",
99
99
  "regex-parser": "^2.3.1",
100
100
  "sync-disk-cache": "^2.1.0"
@@ -178,7 +178,7 @@
178
178
  },
179
179
  "description": "",
180
180
  "types": "types/index.d.ts",
181
- "gitHead": "7a4fbfe6ce9f7f4da54e0bb2728e1cf2a91de87f",
181
+ "gitHead": "d3db16d8f759bf358f542cf2bf378c661f605532",
182
182
  "files": [
183
183
  "dist",
184
184
  "types",
@@ -1 +1 @@
1
- {"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/components/Link.tsx"],"names":[],"mappings":"AACA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAC/C,OAAiB,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAIL,SAAS,IAAI,cAAc,EAC5B,MAAM,6BAA6B,CAAC;AAErC;;GAEG;AACH,QAAA,MAAM,sBAAsB,uFAQlB,CAAC;AAEX;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG;IACvC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAOjE;;;GAGG;AACH,eAAO,MAAM,IAAI,kGAiEhB,CAAC"}
1
+ {"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/components/Link.tsx"],"names":[],"mappings":"AACA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAC/C,OAAiB,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAIL,SAAS,IAAI,cAAc,EAC5B,MAAM,6BAA6B,CAAC;AAGrC;;GAEG;AACH,QAAA,MAAM,sBAAsB,uFAQlB,CAAC;AAEX;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG;IACvC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAOjE;;;GAGG;AACH,eAAO,MAAM,IAAI,kGAqEhB,CAAC"}