Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support repeatable links #66

Merged
merged 14 commits into from
Dec 5, 2024
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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.

### [0.1.23-alpha.0](https://github.com/prismicio/prismic-ts-codegen/compare/v0.1.22...v0.1.23-alpha.0) (2024-11-11)

### [0.1.22](https://github.com/prismicio/prismic-ts-codegen/compare/v0.1.21...v0.1.22) (2024-09-24)


Expand Down
33 changes: 17 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prismic-ts-codegen",
"version": "0.1.22",
"version": "0.1.23-alpha.0",
"description": "An experimental Prismic model-to-TypeScript-type generator",
"keywords": [
"typescript",
Expand Down Expand Up @@ -60,8 +60,8 @@
"quick-lru": "^6.1.1"
},
"devDependencies": {
"@prismicio/client": "^7.10.1",
"@prismicio/mock": "^0.3.7",
"@prismicio/client": "7.12.0-alpha.0",
"@prismicio/mock": "0.5.0-alpha.0",
"@size-limit/preset-small-lib": "^8.2.6",
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@types/common-tags": "^1.8.1",
Expand Down Expand Up @@ -99,5 +99,8 @@
},
"publishConfig": {
"access": "public"
},
"overrides": {
"@prismicio/client": "7.12.0-alpha.0"
}
}
11 changes: 9 additions & 2 deletions src/lib/buildFieldProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ function buildFieldProperty(
}

case "Link": {
const repeatableSuffix = args.field.config?.repeat ? "[]" : "";
switch (args.field.config?.select) {
case "document": {
if (
Expand All @@ -164,13 +165,19 @@ function buildFieldProperty(
}

case "media": {
code = addLine(`${name}: prismic.LinkToMediaField;`, code);
code = addLine(
`${name}: prismic.LinkToMediaField${repeatableSuffix};`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Are we supporting this?

code,
);

break;
}

default: {
code = addLine(`${name}: prismic.LinkField;`, code);
code = addLine(
`${name}: prismic.LinkField${repeatableSuffix};`,
code,
);
}
}

Expand Down
Loading
Loading