Skip to content

Commit

Permalink
feat: map assets to AssetLink
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewLeedham committed Mar 18, 2021
1 parent 9f834ed commit f9130a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/cf-definitions-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ export default class CFDefinitionsBuilder {
});
}

if (type.includes('AssetLink')) {
file.addImportDeclaration({
moduleSpecifier: '@src/types/contentful/static',
namedImports: ['AssetLink'],
});
}

file.addImportDeclaration({
moduleSpecifier: '@contentful/rich-text-types',
namespaceImport: 'CFRichTextTypes',
Expand Down
10 changes: 7 additions & 3 deletions src/renderer/cf-render-prop-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ const linkContentType = (field: Pick<Field, 'validations'>): string => {
};

export const renderPropLink = (field: Pick<Field, 'validations' | 'linkType'>) => {
return field.linkType === 'Entry'
? linkContentType(field)
: 'Contentful.' + field.linkType!;
if (field.linkType === 'Entry') {
return linkContentType(field);
}
if (field.linkType === 'Asset') {
return 'AssetLink';
}
return 'Contentful.' + field.linkType!;
};

0 comments on commit f9130a0

Please sign in to comment.