refactor: Update function parameters in HighlightQuery
This commit is contained in:
parent
88b75eb701
commit
08c5ecfb6a
@ -63,7 +63,7 @@ function PageLink(props: PageLinkProps) {
|
||||
}
|
||||
|
||||
export function PrevNextLinks() {
|
||||
const { urlPathname } = usePageContext();
|
||||
const pageContext = usePageContext();
|
||||
|
||||
const allLinks = navigation
|
||||
.flatMap((section) => section.links)
|
||||
@ -72,13 +72,15 @@ export function PrevNextLinks() {
|
||||
});
|
||||
|
||||
const getNeighboringLinks = () => {
|
||||
const linkIndex = allLinks.findIndex((link) => link.href === urlPathname);
|
||||
const linkIndex = allLinks.findIndex(
|
||||
(link) => link.href === pageContext.urlPathname,
|
||||
);
|
||||
if (linkIndex === -1) return [null, null];
|
||||
|
||||
const previousPage = allLinks[linkIndex - 1] || null;
|
||||
let nextPage = allLinks[linkIndex + 1] || null;
|
||||
|
||||
if (nextPage?.href === urlPathname) {
|
||||
if (nextPage?.href === pageContext.urlPathname) {
|
||||
nextPage = allLinks[linkIndex + 2] || null;
|
||||
}
|
||||
|
||||
|
||||
@ -114,13 +114,13 @@ function SearchInput() {
|
||||
);
|
||||
}
|
||||
|
||||
function HighlightQuery({ text, query }: { text: string; query: string }) {
|
||||
function HighlightQuery(props: { text: string; query: string }) {
|
||||
return (
|
||||
<Highlighter
|
||||
highlightClass="group-aria-selected:underline bg-transparent text-violet-600"
|
||||
searchWords={[query]}
|
||||
searchWords={[props.query]}
|
||||
autoEscape={true}
|
||||
textToHighlight={text}
|
||||
textToHighlight={props.text}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user