Skip to content

Commit

Permalink
Drop versioning logic from search
Browse files Browse the repository at this point in the history
  • Loading branch information
kearfy committed Mar 15, 2024
1 parent d6d8aff commit e94485f
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/theme/SearchBar/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ export async function search(keywords: string): Promise<Doc[]> {
const sql = templatedQuery(keywords);
const docs = await query(sql);
const hostname = getHostname();
const version = getVersion(location.pathname);
// const version = getVersion(location.pathname);
const processed = docs
.filter((match) => {
return match.offsets && match.hostname == hostname && validateUrl(match.url, version)
return match.offsets
&& match.hostname == hostname
// && validateUrl(match.url, version)
})
.map(processResult);
return processed;
Expand All @@ -43,16 +45,16 @@ function getHostname() {
return mapped[location.hostname] || location.hostname;
}

function getVersion(pathname: string) {
pathname = pathname.startsWith('/') ? pathname : `/${pathname}`;
const part = pathname.split('/')[2];
if (part === 'nightly' || part.match(/\d.\d.\d/i)) return part;
return undefined;
}
// function getVersion(pathname: string) {
// pathname = pathname.startsWith('/') ? pathname : `/${pathname}`;
// const part = pathname.split('/')[2];
// if (part === 'nightly' || part.match(/\d.\d.\d/i)) return part;
// return undefined;
// }

function validateUrl(url: string, version?: string) {
return getVersion(url) == version
}
// function validateUrl(url: string, version?: string) {
// return getVersion(url) == version
// }

const templatedQuery = (keywords: string) => {
const escaped = JSON.stringify(keywords);
Expand Down

0 comments on commit e94485f

Please sign in to comment.