Merge pull request #10981 from kuangp/feat/search/highlight

feat(search): highlight search result terms
This commit is contained in:
Fredrik Adelöw
2022-05-09 18:27:07 +02:00
committed by GitHub
42 changed files with 947 additions and 69 deletions
@@ -180,7 +180,7 @@ export const SearchModal = ({ toggleModal }: { toggleModal: () => void }) => {
<SearchResult>
{({ results }) => (
<List>
{results.map(({ type, document }) => {
{results.map(({ type, document, highlight }) => {
let resultItem;
switch (type) {
case 'software-catalog':
@@ -188,6 +188,7 @@ export const SearchModal = ({ toggleModal }: { toggleModal: () => void }) => {
<CatalogSearchResultListItem
key={document.location}
result={document}
highlight={highlight}
/>
);
break;
@@ -196,6 +197,7 @@ export const SearchModal = ({ toggleModal }: { toggleModal: () => void }) => {
<TechDocsSearchResultListItem
key={document.location}
result={document}
highlight={highlight}
/>
);
break;
@@ -204,6 +206,7 @@ export const SearchModal = ({ toggleModal }: { toggleModal: () => void }) => {
<DefaultResultListItem
key={document.location}
result={document}
highlight={highlight}
/>
);
}
@@ -132,13 +132,14 @@ const SearchPage = () => {
<SearchResult>
{({ results }) => (
<List>
{results.map(({ type, document }) => {
{results.map(({ type, document, highlight }) => {
switch (type) {
case 'software-catalog':
return (
<CatalogSearchResultListItem
key={document.location}
result={document}
highlight={highlight}
/>
);
case 'techdocs':
@@ -146,6 +147,7 @@ const SearchPage = () => {
<TechDocsSearchResultListItem
key={document.location}
result={document}
highlight={highlight}
/>
);
default:
@@ -153,6 +155,7 @@ const SearchPage = () => {
<DefaultResultListItem
key={document.location}
result={document}
highlight={highlight}
/>
);
}
@@ -112,13 +112,14 @@ const SearchPage = () => {
<SearchResult>
{({ results }) => (
<List>
{results.map(({ type, document }) => {
{results.map(({ type, document, highlight }) => {
switch (type) {
case 'software-catalog':
return (
<CatalogSearchResultListItem
key={document.location}
result={document}
highlight={highlight}
/>
);
case 'techdocs':
@@ -126,6 +127,7 @@ const SearchPage = () => {
<TechDocsSearchResultListItem
key={document.location}
result={document}
highlight={highlight}
/>
);
default:
@@ -133,6 +135,7 @@ const SearchPage = () => {
<DefaultResultListItem
key={document.location}
result={document}
highlight={highlight}
/>
);
}