Skip to content

Commit

Permalink
other: update getFieldURL
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed May 26, 2023
1 parent 63eab51 commit 0e6d945
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Tags/Tags.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import cx from 'classnames';
import { Icon } from 'semantic-ui-react';
import { UniversalLink } from '@plone/volto/components';
import { getFieldURL } from '@eeacms/volto-tags-block/helpers';
import { Icon } from 'semantic-ui-react';

function TagList({ children, position }) {
return <div className={cx('eea tags', position)}>{children}</div>;
Expand Down
3 changes: 1 addition & 2 deletions src/TagsBlock/View.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import TagList from '@eeacms/volto-tags-block/Tags/Tags';
import { getFieldURL } from '@eeacms/volto-tags-block/helpers';

const View = ({ data, mode }) => {
const { items = [], title, position, showTagIcon } = data;
Expand All @@ -16,7 +15,7 @@ const View = ({ data, mode }) => {
<TagList.Tag
className={item.class}
color={item.color || 'teal'}
href={getFieldURL(item.href) || '#'}
href={item.href || '#'}
openLinkInNewTab={!!item.openLinkInNewTab}
showTagIcon={showTagIcon}
key={item.category}
Expand Down
4 changes: 2 additions & 2 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export const getFieldURL = (data) => {
let url = data;
const _isObject = data && isObject(data) && !isArray(data);
if (_isObject && data['@type'] === 'URL') {
url = data['value'] || data['url'] || data['href'] || data;
url = data['value'] ?? data['url'] ?? data['href'] ?? data;
} else if (_isObject) {
url = data['@id'] || data['url'] || data['href'] || data;
url = data['@id'] ?? data['url'] ?? data['href'] ?? data;
}
if (isArray(data)) {
url = data.map((item) => getFieldURL(item));
Expand Down

0 comments on commit 0e6d945

Please sign in to comment.