mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
Core: Remove Next.js usage from search server
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-core': patch
|
||||
---
|
||||
|
||||
Remove Next.js usage from search server
|
||||
@@ -9,13 +9,14 @@ export function createEndpoint(server: SearchServer): SearchAPI {
|
||||
return Response.json(await server.export());
|
||||
},
|
||||
async GET(request) {
|
||||
const query = request.nextUrl.searchParams.get('query');
|
||||
const url = new URL(request.url);
|
||||
const query = url.searchParams.get('query');
|
||||
if (!query) return Response.json([]);
|
||||
|
||||
return Response.json(
|
||||
await search(query, {
|
||||
tag: request.nextUrl.searchParams.get('tag') ?? undefined,
|
||||
locale: request.nextUrl.searchParams.get('locale') ?? undefined,
|
||||
tag: url.searchParams.get('tag') ?? undefined,
|
||||
locale: url.searchParams.get('locale') ?? undefined,
|
||||
}),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
create,
|
||||
type RawData,
|
||||
} from '@orama/orama';
|
||||
import { type NextRequest } from 'next/server';
|
||||
import type { StructuredData } from '@/mdx-plugins/remark-structure';
|
||||
import type { SortedResult } from '@/server/types';
|
||||
import { createEndpoint } from '@/search/orama/create-endpoint';
|
||||
@@ -44,7 +43,7 @@ export interface SearchServer {
|
||||
}
|
||||
|
||||
export interface SearchAPI extends SearchServer {
|
||||
GET: (request: NextRequest) => Promise<Response>;
|
||||
GET: (request: Request) => Promise<Response>;
|
||||
|
||||
/**
|
||||
* `GET` route handler that exports search indexes for static search.
|
||||
|
||||
Reference in New Issue
Block a user