Merge pull request #14615 from jsundquist/master

fix(search): update to only link title in search results
This commit is contained in:
Patrik Oldsberg
2022-11-28 15:10:38 +01:00
committed by GitHub
6 changed files with 81 additions and 61 deletions
@@ -81,6 +81,15 @@ export const TechDocsSearchResultListItem = (
});
};
const LinkWrapper = ({ children }: PropsWithChildren<{}>) =>
asLink ? (
<Link noTrack to={result.location} onClick={handleClick}>
{children}
</Link>
) : (
<>{children}</>
);
const TextItem = () => {
const resultTitle = highlight?.fields.title ? (
<HighlightedSearchResultText
@@ -117,13 +126,15 @@ export const TechDocsSearchResultListItem = (
className={classes.itemText}
primaryTypographyProps={{ variant: 'h6' }}
primary={
title ? (
title
) : (
<>
{resultTitle} | {entityTitle ?? resultName} docs
</>
)
<LinkWrapper>
{title ? (
title
) : (
<>
{resultTitle} | {entityTitle ?? resultName} docs
</>
)}
</LinkWrapper>
}
secondary={
<span
@@ -149,15 +160,6 @@ export const TechDocsSearchResultListItem = (
);
};
const LinkWrapper = ({ children }: PropsWithChildren<{}>) =>
asLink ? (
<Link noTrack to={result.location} onClick={handleClick}>
{children}
</Link>
) : (
<>{children}</>
);
const ListItemWrapper = ({ children }: PropsWithChildren<{}>) =>
asListItem ? (
<>
@@ -172,10 +174,8 @@ export const TechDocsSearchResultListItem = (
);
return (
<LinkWrapper>
<ListItemWrapper>
<TextItem />
</ListItemWrapper>
</LinkWrapper>
<ListItemWrapper>
<TextItem />
</ListItemWrapper>
);
};