rework/lightweight #12
@ -63,7 +63,7 @@ function PageLink(props: PageLinkProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function PrevNextLinks() {
|
export function PrevNextLinks() {
|
||||||
const { urlPathname } = usePageContext();
|
const pageContext = usePageContext();
|
||||||
|
|
||||||
const allLinks = navigation
|
const allLinks = navigation
|
||||||
.flatMap((section) => section.links)
|
.flatMap((section) => section.links)
|
||||||
@ -72,13 +72,15 @@ export function PrevNextLinks() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const getNeighboringLinks = () => {
|
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];
|
if (linkIndex === -1) return [null, null];
|
||||||
|
|
||||||
const previousPage = allLinks[linkIndex - 1] || null;
|
const previousPage = allLinks[linkIndex - 1] || null;
|
||||||
let nextPage = allLinks[linkIndex + 1] || null;
|
let nextPage = allLinks[linkIndex + 1] || null;
|
||||||
|
|
||||||
if (nextPage?.href === urlPathname) {
|
if (nextPage?.href === pageContext.urlPathname) {
|
||||||
nextPage = allLinks[linkIndex + 2] || null;
|
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 (
|
return (
|
||||||
<Highlighter
|
<Highlighter
|
||||||
highlightClass="group-aria-selected:underline bg-transparent text-violet-600"
|
highlightClass="group-aria-selected:underline bg-transparent text-violet-600"
|
||||||
searchWords={[query]}
|
searchWords={[props.query]}
|
||||||
autoEscape={true}
|
autoEscape={true}
|
||||||
textToHighlight={text}
|
textToHighlight={props.text}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user