Skip to content

Commit

Permalink
Merge pull request #279 from anthonyshew/dev
Browse files Browse the repository at this point in the history
Remove default export from next/server.
  • Loading branch information
fuma-nama authored Mar 6, 2024
2 parents ae2cdaa + 036663a commit 8ca5aef
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/core/src/search/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Document } from 'flexsearch';
import nextLib, { type NextRequest, type NextResponse } from 'next/server';
import { NextRequest, NextResponse } from 'next/server';
import { type NextRequest as NextRequestType, type NextResponse as NextResponseType } from 'next/server';
import type { StructuredData } from '@/mdx-plugins/remark-structure';
import type { SortedResult } from './shared';

Expand Down Expand Up @@ -68,7 +69,7 @@ export function createI18nSearchAPI<T extends 'simple' | 'advanced'>(
if (handler) return handler.GET(request);
}

return nextLib.NextResponse.json([]);
return NextResponse.json([]);
},
};
}
Expand Down Expand Up @@ -126,14 +127,14 @@ export function initSearchAPI({ indexes, language }: SimpleOptions): SearchAPI {
const { searchParams } = request.nextUrl;
const query = searchParams.get('query');

if (!query) return nextLib.NextResponse.json([]);
if (!query) return NextResponse.json([]);

const results = index.search(query, 5, {
enrich: true,
suggest: true,
});

if (results.length === 0) return nextLib.NextResponse.json([]);
if (results.length === 0) return NextResponse.json([]);

const pages = results[0].result.map<SortedResult>((page) => ({
type: 'page',
Expand All @@ -142,7 +143,7 @@ export function initSearchAPI({ indexes, language }: SimpleOptions): SearchAPI {
url: page.doc.url,
}));

return nextLib.NextResponse.json(pages);
return NextResponse.json(pages);
},
};
}
Expand Down Expand Up @@ -235,7 +236,7 @@ export function initSearchAPIAdvanced({
const query = request.nextUrl.searchParams.get('query');
const paramTag = request.nextUrl.searchParams.get('tag');

if (!query) return nextLib.NextResponse.json([]);
if (!query) return NextResponse.json([]);

const results = index.search(query, 5, {
enrich: true,
Expand Down Expand Up @@ -287,7 +288,7 @@ export function initSearchAPIAdvanced({
sortedResult.push(...items);
}

return nextLib.NextResponse.json(sortedResult);
return NextResponse.json(sortedResult);
},
};
}

0 comments on commit 8ca5aef

Please sign in to comment.