diff --git a/website/src/app/f/[...path]/page.tsx b/website/src/app/f/[...path]/page.tsx index 56eb609..a805b48 100644 --- a/website/src/app/f/[...path]/page.tsx +++ b/website/src/app/f/[...path]/page.tsx @@ -108,8 +108,6 @@ async function getManualSrc(item: Doc): Promise { } const manPath = path.join(process.cwd(), "src/models/data", extern.file); const source = fs.readFileSync(manPath, { encoding: "utf-8" }); - // const src = extern.file; - // console.log({ source, manPath }); return source; } @@ -208,6 +206,10 @@ export default async function Page(props: { params: { path: string[] } }) { ) )} + | Promise<{ @@ -56,6 +59,19 @@ export const usePagefindSearch = (): PagefindHooks => { // @ts-ignore /* webpackIgnore: true */ "/pagefind/pagefind.js" ); + await pagefind.options({ + ranking: { + // controls how quickly a term “saturates” on a page. + // Once a term has appeared on a page many times, + // further appearances have a reduced impact on the page rank. + // We choose to reduce this to suppress pages that are ranking well due to a high number of search terms existing in their content. + termSaturation: 0.5, // default value 1.4 + // Changes the way ranking compares page lengths with the average page lengths on your site. + pageLength: 0.6, // default value 0.75 + // Increasing the termSimilarity parameter is a good way to suppress pages that are ranking well for long extensions of search terms. + termSimilarity: 1.5, // default value 1.0 + }, + }); // @ts-ignore window.pagefind = pagefind; diff --git a/website/src/components/PagefindResults.tsx b/website/src/components/PagefindResults.tsx index 5ebdf88..590137d 100644 --- a/website/src/components/PagefindResults.tsx +++ b/website/src/components/PagefindResults.tsx @@ -66,7 +66,10 @@ export function PagefindResults() { const init = async () => { console.log({ search, term, filters: { from, to } }); if (search) { - let raw = await search(term, { filters: { from, to } }); + let raw = await search(term, { + filters: { from, to }, + sort: { weight: "desc" }, + }); setSearchResults(raw?.results || []); } };