= (props) => {
+ const { results } = props;
+
+ if (results.length === 0) {
+ return (
+
+ No results found
+
+ );
+ }
+
+ return (
+ <>
+ Found {results.length} results
+
+ {results.map((result, resultIndex) => {
+ const { id: chapterUrl } = result;
+ const { id, subId } = getChapterIdsByUrl(chapterUrl);
+ return (
+
+
+
+ );
+ })}
+
+ >
+ );
+};
diff --git a/src/pages/Search/index.tsx b/src/pages/Search/index.tsx
index b7ac20a..db5ec44 100644
--- a/src/pages/Search/index.tsx
+++ b/src/pages/Search/index.tsx
@@ -5,14 +5,14 @@ import {
IonHeader,
IonMenuButton,
IonPage,
- IonRouterLink,
IonSearchbar,
IonTitle,
IonToolbar,
} from '@ionic/react';
import { useTranslation } from 'react-i18next';
+import { SearchPopover } from '../../components/SearchPopover';
+import { SearchResults } from '../../components/SearchResults';
import { useLunr } from '../../utils/lunr';
-import { Chapter, getChapterIdsByUrl } from '../../components/Chapters';
interface ContainerProps {}
@@ -25,39 +25,23 @@ export const SearchPage: React.FC = (props) => {
return (
-
+
{t('SEARCH.TITLE')}
+
+
+
-
-
-
- {t('SEARCH.TITLE')}
-
-
+
setSearchValue(event.detail.value!)}
>
-
- {results.map((result, resultIndex) => {
- const chapterUrl = result.id;
- const { id, subId } = getChapterIdsByUrl(chapterUrl);
- return (
-
-
-
- );
- })}
-
+
);
diff --git a/src/utils/lunr.tsx b/src/utils/lunr.tsx
index d604b2c..58fa148 100644
--- a/src/utils/lunr.tsx
+++ b/src/utils/lunr.tsx
@@ -12,6 +12,12 @@ type LunrDocs = {
};
};
+export type LunrResult = {
+ id: string;
+ title: string;
+ body: string;
+};
+
const createLunrDocs = () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const { t } = useTranslation();