mirror of
https://github.com/hsjobeki/noogle.git
synced 2024-10-04 00:17:26 +03:00
Website: improve search ranking parameters
This commit is contained in:
parent
0532cdd73f
commit
c71805f626
@ -108,8 +108,6 @@ async function getManualSrc(item: Doc): Promise<string | null> {
|
|||||||
}
|
}
|
||||||
const manPath = path.join(process.cwd(), "src/models/data", extern.file);
|
const manPath = path.join(process.cwd(), "src/models/data", extern.file);
|
||||||
const source = fs.readFileSync(manPath, { encoding: "utf-8" });
|
const source = fs.readFileSync(manPath, { encoding: "utf-8" });
|
||||||
// const src = extern.file;
|
|
||||||
// console.log({ source, manPath });
|
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,6 +206,10 @@ export default async function Page(props: { params: { path: string[] } }) {
|
|||||||
<meta key={idx} data-pagefind-meta={`category:${attr}`} />
|
<meta key={idx} data-pagefind-meta={`category:${attr}`} />
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
<meta
|
||||||
|
data-pagefind-sort="weight[data-weight]"
|
||||||
|
data-weight={meta?.path?.at(0) === "builtins" ? "10" : "1"}
|
||||||
|
/>
|
||||||
<Box>
|
<Box>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@ -226,6 +228,7 @@ export default async function Page(props: { params: { path: string[] } }) {
|
|||||||
id={item?.meta.title}
|
id={item?.meta.title}
|
||||||
variant="h2"
|
variant="h2"
|
||||||
component={"h1"}
|
component={"h1"}
|
||||||
|
data-pagefind-weight="15"
|
||||||
sx={{
|
sx={{
|
||||||
marginRight: "auto",
|
marginRight: "auto",
|
||||||
}}
|
}}
|
||||||
|
@ -31,6 +31,9 @@ type PagefindHooks = {
|
|||||||
term: string | null,
|
term: string | null,
|
||||||
options?: {
|
options?: {
|
||||||
filters?: Filters;
|
filters?: Filters;
|
||||||
|
sort?: {
|
||||||
|
[name: string]: "asc" | "desc";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
) =>
|
) =>
|
||||||
| Promise<{
|
| Promise<{
|
||||||
@ -56,6 +59,19 @@ export const usePagefindSearch = (): PagefindHooks => {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
/* webpackIgnore: true */ "/pagefind/pagefind.js"
|
/* 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
|
// @ts-ignore
|
||||||
window.pagefind = pagefind;
|
window.pagefind = pagefind;
|
||||||
|
|
||||||
|
@ -66,7 +66,10 @@ export function PagefindResults() {
|
|||||||
const init = async () => {
|
const init = async () => {
|
||||||
console.log({ search, term, filters: { from, to } });
|
console.log({ search, term, filters: { from, to } });
|
||||||
if (search) {
|
if (search) {
|
||||||
let raw = await search(term, { filters: { from, to } });
|
let raw = await search(term, {
|
||||||
|
filters: { from, to },
|
||||||
|
sort: { weight: "desc" },
|
||||||
|
});
|
||||||
setSearchResults(raw?.results || []);
|
setSearchResults(raw?.results || []);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user