diff --git a/CHANGELOG.md b/CHANGELOG.md
index be691fe..8a76aa5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,21 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
+## [1.7.0](https://github.com/prismicio/prismic-next/compare/v1.7.0-alpha.0...v1.7.0) (2024-09-27)
+
+## [1.7.0-alpha.0](https://github.com/prismicio/prismic-next/compare/v1.5.0...v1.7.0-alpha.0) (2024-09-10)
+
+
+### Features
+
+* support link text ([bdc244e](https://github.com/prismicio/prismic-next/commit/bdc244e50a35fffc342968811621fac6720ec461))
+* Support Next 15 & React 19 ([864bfed](https://github.com/prismicio/prismic-next/commit/864bfedb14a31401ae6ce2e8799767d217e2562d))
+
+
+### Chore
+
+* **release:** 1.6.0 ([e97fcca](https://github.com/prismicio/prismic-next/commit/e97fcca55e599131d0945d90dd6bb3f8732092ca))
+
## [1.6.0](https://github.com/prismicio/prismic-next/compare/v1.5.0...v1.6.0) (2024-05-30)
diff --git a/package-lock.json b/package-lock.json
index cf159be..b7b1296 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@prismicio/next",
- "version": "1.6.0",
+ "version": "1.7.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@prismicio/next",
- "version": "1.6.0",
+ "version": "1.7.0",
"license": "Apache-2.0",
"dependencies": {
"@formatjs/intl-localematcher": "^0.5.2",
@@ -14,8 +14,8 @@
"negotiator": "^0.6.3"
},
"devDependencies": {
- "@prismicio/client": "^7.2.0",
- "@prismicio/mock": "^0.3.1",
+ "@prismicio/client": "^7.11.0",
+ "@prismicio/mock": "^0.4.0",
"@size-limit/preset-small-lib": "^9.0.0",
"@types/negotiator": "^0.6.3",
"@types/react-test-renderer": "^18.0.2",
@@ -1219,52 +1219,42 @@
}
},
"node_modules/@prismicio/client": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/@prismicio/client/-/client-7.2.0.tgz",
- "integrity": "sha512-bfbs2ZMLd3ba7Bp1qI4qAz+13FIWE/JDT9+h+3hL/MVpK4iDpjz3vmOlYJs25myhryU9HP8Og7qKoaeE9hPzmA==",
+ "version": "7.11.0",
+ "resolved": "https://registry.npmjs.org/@prismicio/client/-/client-7.11.0.tgz",
+ "integrity": "sha512-b5FtER97eFHH435hP4sRchtPYvrwa8v2Ye5IH3MhMp/6aH6kRSrr9fDA4+wkqF/ZK9aiJwJRkjdddgkwDFu9Vg==",
"dev": true,
+ "license": "Apache-2.0",
"dependencies": {
- "@prismicio/richtext": "^2.1.5",
- "imgix-url-builder": "^0.0.4"
+ "imgix-url-builder": "^0.0.5"
},
"engines": {
"node": ">=14.15.0"
}
},
- "node_modules/@prismicio/mock": {
- "version": "0.3.1",
- "resolved": "https://registry.npmjs.org/@prismicio/mock/-/mock-0.3.1.tgz",
- "integrity": "sha512-xwwnQ6kKfHMypjao2Q0sdUFuQsdDlif8qmgKoqYv8KlmNxKHzurgfGh9Zl1wHF1ldEJ8C3NVpI4AqdaHjyCHSA==",
+ "node_modules/@prismicio/client/node_modules/imgix-url-builder": {
+ "version": "0.0.5",
+ "resolved": "https://registry.npmjs.org/imgix-url-builder/-/imgix-url-builder-0.0.5.tgz",
+ "integrity": "sha512-dCx3UlXghtsjySoqVCcHQHRikqDummwQEfKlxBUK/wrMzd+1ox/XX+zhqVuXKMVuZvCc84pVLEJyntQB0OOi/w==",
"dev": true,
- "dependencies": {
- "change-case": "^4.1.2"
- },
+ "license": "Apache-2.0",
"engines": {
"node": ">=12.7.0"
- },
- "peerDependencies": {
- "@prismicio/client": "^7"
}
},
- "node_modules/@prismicio/richtext": {
- "version": "2.1.5",
- "resolved": "https://registry.npmjs.org/@prismicio/richtext/-/richtext-2.1.5.tgz",
- "integrity": "sha512-Sf6iCsciPmfK3uQeFmeY9RTRSuhrCVzyU39OkiJ1VJn8O0531pKapGoWS+5WGxouJtE5+jGqV8L+L2mKP7NkXQ==",
+ "node_modules/@prismicio/mock": {
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/@prismicio/mock/-/mock-0.4.0.tgz",
+ "integrity": "sha512-CtTEbp/3NOdyP2StC8lGBAE4IwPJOegWEYKSEAQTjp+6BgcGcqUHr1iVBwKd3EFKVoBWA+8tJNP0m0/AFPOuNw==",
"dev": true,
+ "license": "Apache-2.0",
"dependencies": {
- "@prismicio/types": "^0.2.7"
+ "change-case": "^5.4.4"
},
"engines": {
- "node": ">=12.7.0"
- }
- },
- "node_modules/@prismicio/types": {
- "version": "0.2.8",
- "resolved": "https://registry.npmjs.org/@prismicio/types/-/types-0.2.8.tgz",
- "integrity": "sha512-EmuYYil56U+UtEifMD/9TmLzpWliV+X6kypwPq47GNXmIXyFK1JsP3z872fUziXwoBjd2YILj28DNdYXlLOpXg==",
- "dev": true,
- "engines": {
- "node": ">=12.7.0"
+ "node": ">=18"
+ },
+ "peerDependencies": {
+ "@prismicio/client": "^7"
}
},
"node_modules/@rollup/plugin-typescript": {
@@ -2267,16 +2257,6 @@
"node": ">=6"
}
},
- "node_modules/camel-case": {
- "version": "4.1.2",
- "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz",
- "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==",
- "dev": true,
- "dependencies": {
- "pascal-case": "^3.1.2",
- "tslib": "^2.0.3"
- }
- },
"node_modules/camelcase": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
@@ -2323,17 +2303,6 @@
}
]
},
- "node_modules/capital-case": {
- "version": "1.0.4",
- "resolved": "https://registry.npmjs.org/capital-case/-/capital-case-1.0.4.tgz",
- "integrity": "sha512-ds37W8CytHgwnhGGTi88pcPyR15qoNkOpYwmMMfnWqqWgESapLqvDx6huFjQ5vqWSn2Z06173XNA7LtMOeUh1A==",
- "dev": true,
- "dependencies": {
- "no-case": "^3.0.4",
- "tslib": "^2.0.3",
- "upper-case-first": "^2.0.2"
- }
- },
"node_modules/chai": {
"version": "4.3.8",
"resolved": "https://registry.npmjs.org/chai/-/chai-4.3.8.tgz",
@@ -2367,24 +2336,11 @@
}
},
"node_modules/change-case": {
- "version": "4.1.2",
- "resolved": "https://registry.npmjs.org/change-case/-/change-case-4.1.2.tgz",
- "integrity": "sha512-bSxY2ws9OtviILG1EiY5K7NNxkqg/JnRnFxLtKQ96JaviiIxi7djMrSd0ECT9AC+lttClmYwKw53BWpOMblo7A==",
+ "version": "5.4.4",
+ "resolved": "https://registry.npmjs.org/change-case/-/change-case-5.4.4.tgz",
+ "integrity": "sha512-HRQyTk2/YPEkt9TnUPbOpr64Uw3KOicFWPVBb+xiHvd6eBx/qPr9xqfBFDT8P2vWsvvz4jbEkfDe71W3VyNu2w==",
"dev": true,
- "dependencies": {
- "camel-case": "^4.1.2",
- "capital-case": "^1.0.4",
- "constant-case": "^3.0.4",
- "dot-case": "^3.0.4",
- "header-case": "^2.0.4",
- "no-case": "^3.0.4",
- "param-case": "^3.0.4",
- "pascal-case": "^3.1.2",
- "path-case": "^3.0.4",
- "sentence-case": "^3.0.4",
- "snake-case": "^3.0.4",
- "tslib": "^2.0.3"
- }
+ "license": "MIT"
},
"node_modules/character-entities": {
"version": "2.0.2",
@@ -2516,17 +2472,6 @@
"typedarray": "^0.0.6"
}
},
- "node_modules/constant-case": {
- "version": "3.0.4",
- "resolved": "https://registry.npmjs.org/constant-case/-/constant-case-3.0.4.tgz",
- "integrity": "sha512-I2hSBi7Vvs7BEuJDr5dDHfzb/Ruj3FyvFyh7KLilAjNQw3Be+xgqUBA2W6scVEcL0hL1dwPRtIqEPVUCKkSsyQ==",
- "dev": true,
- "dependencies": {
- "no-case": "^3.0.4",
- "tslib": "^2.0.3",
- "upper-case": "^2.0.2"
- }
- },
"node_modules/conventional-changelog": {
"version": "3.1.25",
"resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-3.1.25.tgz",
@@ -3087,16 +3032,6 @@
"node": ">=6.0.0"
}
},
- "node_modules/dot-case": {
- "version": "3.0.4",
- "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz",
- "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==",
- "dev": true,
- "dependencies": {
- "no-case": "^3.0.4",
- "tslib": "^2.0.3"
- }
- },
"node_modules/dot-prop": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz",
@@ -4457,16 +4392,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
- "node_modules/header-case": {
- "version": "2.0.4",
- "resolved": "https://registry.npmjs.org/header-case/-/header-case-2.0.4.tgz",
- "integrity": "sha512-H/vuk5TEEVZwrR0lp2zed9OCo1uAILMlx0JEMgC26rzyJJ3N1v6XkwHHXJQdR2doSjcGPM6OKPYoJgf0plJ11Q==",
- "dev": true,
- "dependencies": {
- "capital-case": "^1.0.4",
- "tslib": "^2.0.3"
- }
- },
"node_modules/hosted-git-info": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz",
@@ -5491,15 +5416,6 @@
"get-func-name": "^2.0.0"
}
},
- "node_modules/lower-case": {
- "version": "2.0.2",
- "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz",
- "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==",
- "dev": true,
- "dependencies": {
- "tslib": "^2.0.3"
- }
- },
"node_modules/lru-cache": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
@@ -6449,16 +6365,6 @@
}
}
},
- "node_modules/no-case": {
- "version": "3.0.4",
- "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz",
- "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==",
- "dev": true,
- "dependencies": {
- "lower-case": "^2.0.2",
- "tslib": "^2.0.3"
- }
- },
"node_modules/node-domexception": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
@@ -6757,16 +6663,6 @@
"node": ">=6"
}
},
- "node_modules/param-case": {
- "version": "3.0.4",
- "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz",
- "integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==",
- "dev": true,
- "dependencies": {
- "dot-case": "^3.0.4",
- "tslib": "^2.0.3"
- }
- },
"node_modules/parent-module": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
@@ -6792,26 +6688,6 @@
"node": ">=4"
}
},
- "node_modules/pascal-case": {
- "version": "3.1.2",
- "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz",
- "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==",
- "dev": true,
- "dependencies": {
- "no-case": "^3.0.4",
- "tslib": "^2.0.3"
- }
- },
- "node_modules/path-case": {
- "version": "3.0.4",
- "resolved": "https://registry.npmjs.org/path-case/-/path-case-3.0.4.tgz",
- "integrity": "sha512-qO4qCFjXqVTrcbPt/hQfhTQ+VhFsqNKOPtytgNKkKxSoEp3XPUQ8ObFuePylOIok5gjn69ry8XiULxCwot3Wfg==",
- "dev": true,
- "dependencies": {
- "dot-case": "^3.0.4",
- "tslib": "^2.0.3"
- }
- },
"node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
@@ -7745,17 +7621,6 @@
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"dev": true
},
- "node_modules/sentence-case": {
- "version": "3.0.4",
- "resolved": "https://registry.npmjs.org/sentence-case/-/sentence-case-3.0.4.tgz",
- "integrity": "sha512-8LS0JInaQMCRoQ7YUytAo/xUu5W2XnQxV2HI/6uM6U7CITS1RqPElr30V6uIqyMKM9lJGRVFy5/4CuzcixNYSg==",
- "dev": true,
- "dependencies": {
- "no-case": "^3.0.4",
- "tslib": "^2.0.3",
- "upper-case-first": "^2.0.2"
- }
- },
"node_modules/set-function-name": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.1.tgz",
@@ -7846,16 +7711,6 @@
"node": ">=8"
}
},
- "node_modules/snake-case": {
- "version": "3.0.4",
- "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz",
- "integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==",
- "dev": true,
- "dependencies": {
- "dot-case": "^3.0.4",
- "tslib": "^2.0.3"
- }
- },
"node_modules/source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
@@ -8561,24 +8416,6 @@
"browserslist": ">= 4.21.0"
}
},
- "node_modules/upper-case": {
- "version": "2.0.2",
- "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-2.0.2.tgz",
- "integrity": "sha512-KgdgDGJt2TpuwBUIjgG6lzw2GWFRCW9Qkfkiv0DxqHHLYJHmtmdUIKcZd8rHgFSjopVTlw6ggzCm1b8MFQwikg==",
- "dev": true,
- "dependencies": {
- "tslib": "^2.0.3"
- }
- },
- "node_modules/upper-case-first": {
- "version": "2.0.2",
- "resolved": "https://registry.npmjs.org/upper-case-first/-/upper-case-first-2.0.2.tgz",
- "integrity": "sha512-514ppYHBaKwfJRK/pNC6c/OxfGa0obSnAl106u97Ed0I625Nin96KAjttZF6ZL3e1XLtphxnqrOi9iWgm+u+bg==",
- "dev": true,
- "dependencies": {
- "tslib": "^2.0.3"
- }
- },
"node_modules/uri-js": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
diff --git a/package.json b/package.json
index 64ee4d0..119c131 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@prismicio/next",
- "version": "1.6.0",
+ "version": "1.7.0",
"description": "Helpers to integrate Prismic into Next.js apps",
"keywords": [
"typescript",
@@ -57,8 +57,8 @@
"negotiator": "^0.6.3"
},
"devDependencies": {
- "@prismicio/client": "^7.2.0",
- "@prismicio/mock": "^0.3.1",
+ "@prismicio/client": "^7.11.0",
+ "@prismicio/mock": "^0.4.0",
"@size-limit/preset-small-lib": "^9.0.0",
"@types/negotiator": "^0.6.3",
"@types/react-test-renderer": "^18.0.2",
diff --git a/src/PrismicNextLink.tsx b/src/PrismicNextLink.tsx
index 9780c1b..fb95733 100644
--- a/src/PrismicNextLink.tsx
+++ b/src/PrismicNextLink.tsx
@@ -31,10 +31,8 @@ export type PrismicNextLinkProps = Omit<
export const PrismicNextLink = React.forwardRef<
HTMLAnchorElement,
PrismicNextLinkProps
->(function PrismicNextLink(
- { field, document, linkResolver, ...restProps },
- ref,
-): JSX.Element | null {
+>(function PrismicNextLink(props, ref): JSX.Element | null {
+ const { field, document, linkResolver, children, ...restProps } = props;
const {
href: computedHref,
rel: computedRel,
@@ -51,5 +49,9 @@ export const PrismicNextLink = React.forwardRef<
rel = restProps.rel;
}
- return ;
+ return (
+
+ {"children" in props ? children : field?.text}
+
+ );
});
diff --git a/test/PrismicNextLink.test.tsx b/test/PrismicNextLink.test.tsx
index 371d88d..890b471 100644
--- a/test/PrismicNextLink.test.tsx
+++ b/test/PrismicNextLink.test.tsx
@@ -237,3 +237,40 @@ it("forwards ref", (ctx) => {
expect(ref).toHaveBeenCalledWith({ tagName: "a" });
});
+
+it("renders a next/link with text", (ctx) => {
+ const model = ctx.mock.model.link({
+ allowText: true,
+ allowTargetBlank: false,
+ });
+ const field = ctx.mock.value.link({ type: "Web", model, withText: true });
+
+ const actual = renderJSON();
+ const expected = renderJSON(
+
+ {field.text}
+ ,
+ );
+
+ expectLinkToEqual(actual, expected);
+});
+
+it("renders a next/link with the given children, overriding the link's text", (ctx) => {
+ const model = ctx.mock.model.link({
+ allowText: true,
+ allowTargetBlank: false,
+ });
+ const field = ctx.mock.value.link({ type: "Web", model, withText: true });
+ const children = ctx.mock.value.keyText();
+
+ const actual = renderJSON(
+ {children},
+ );
+ const expected = renderJSON(
+
+ {children}
+ ,
+ );
+
+ expectLinkToEqual(actual, expected);
+});
diff --git a/test/createLocaleRedirect.test.ts b/test/createLocaleRedirect.test.ts
index 789ac0e..9140ba2 100644
--- a/test/createLocaleRedirect.test.ts
+++ b/test/createLocaleRedirect.test.ts
@@ -49,7 +49,7 @@ it("creates a redirect with the request's preferred locale", async () => {
mockGetRepository({
client,
- languages: [{ id: "fr-fr", name: "French (France)" }],
+ languages: [{ id: "fr-fr", name: "French (France)", is_master: true }],
});
const redirect = await createLocaleRedirect(config);
@@ -74,8 +74,8 @@ it("returns undefined if the request already contains a locale", async () => {
mockGetRepository({
client,
languages: [
- { id: "fr-fr", name: "French (France)" },
- { id: "en-us", name: "English (US)" },
+ { id: "fr-fr", name: "French (France)", is_master: false },
+ { id: "en-us", name: "English (US)", is_master: true },
],
});
@@ -98,8 +98,8 @@ it("uses the default locale if the request's preferred language is unavailable",
mockGetRepository({
client,
languages: [
- { id: "en-us", name: "English (US)" },
- { id: "en-uk", name: "English (UK)" },
+ { id: "en-us", name: "English (US)", is_master: true },
+ { id: "en-uk", name: "English (UK)", is_master: false },
],
});
@@ -127,7 +127,7 @@ it("allows for custom locale codes", async () => {
mockGetRepository({
client,
- languages: [{ id: "fr-fr", name: "French (France)" }],
+ languages: [{ id: "fr-fr", name: "French (France)", is_master: true }],
});
const redirect = await createLocaleRedirect(config);
@@ -150,7 +150,7 @@ it("returns undefined when omitDefaultLocale is true and the preferred locale is
mockGetRepository({
client,
- languages: [{ id: "fr-fr", name: "French (France)" }],
+ languages: [{ id: "fr-fr", name: "French (France)", is_master: true }],
});
const redirect = await createLocaleRedirect(config);
@@ -171,7 +171,7 @@ it("uses the default locale when the accept-language header is not set", async (
mockGetRepository({
client,
- languages: [{ id: "fr-fr", name: "French (France)" }],
+ languages: [{ id: "fr-fr", name: "French (France)", is_master: true }],
});
const redirect = await createLocaleRedirect(config);