Skip to content

Commit

Permalink
Fix url in result list
Browse files Browse the repository at this point in the history
  • Loading branch information
ksuess committed Dec 26, 2020
1 parent 8c42bc4 commit 1fd69ba
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/components/Views/FacetedSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { settings } from '~/config';
import { NoSSR } from '../helpers';

import { useDispatch, useSelector } from 'react-redux';
import { flattenToAppURL } from '@plone/volto/helpers';
import { flattenESUrlToPath } from '../helpers';

const OnResults = withState(Results);

Expand Down Expand Up @@ -97,11 +99,13 @@ const IGIBResultsListItem = ({ result, index }) => {
return (
<Item key={index}>
<Item.Content>
<Item.Header
as={Link}
to={result['@id'].replace(settings.devProxyToApiPath, '')}
>
<Item.Header as={Link} to={flattenESUrlToPath(result['@id'])}>
{result.title}
{/* <p>result['@id']: {result['@id']}</p>
<p>
flattenESUrlToPath(result['@id']):{' '}
{flattenESUrlToPath(result['@id'])}
</p> */}
</Item.Header>
<Item.Description>
{_truncate(result.description, { length: 200 })}
Expand Down
14 changes: 13 additions & 1 deletion src/components/helpers.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { flattenToAppURL } from '@plone/volto/helpers';

class NoSSR extends React.Component {
state = {
Expand All @@ -14,4 +15,15 @@ class NoSSR extends React.Component {
}
}

export { NoSSR };
// TODO replace ugly flattenESUrlToPath hack. Problem Elastic responds with backend Plone Zeo client url.
function flattenESUrlToPath(url) {
var pathArray = url.split('/');
var newPathname = '';
for (let i = 4; i < pathArray.length; i++) {
newPathname += '/';
newPathname += pathArray[i];
}
return newPathname;
}

export { NoSSR, flattenESUrlToPath };

0 comments on commit 1fd69ba

Please sign in to comment.