Skip to content

Commit 88566aa

Browse files
committed
docs: expose data attr
1 parent e2b8a03 commit 88566aa

File tree

1 file changed

+20
-0
lines changed
  • website/src/app/api/data-attr/[component]

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { type DataAttrDocKey, getDataAttrDoc } from '@zag-js/docs'
2+
import type { NextRequest } from 'next/server'
3+
4+
type Params = Promise<{ component: string }>
5+
6+
export const GET = async (_: NextRequest, segmentData: { params: Params }) => {
7+
const { component } = await segmentData.params
8+
9+
if (!component) {
10+
return Response.json({ error: 'Component parameter is required' }, { status: 400 })
11+
}
12+
13+
const dataAttrDoc = getDataAttrDoc(component as DataAttrDocKey)
14+
15+
if (!dataAttrDoc) {
16+
return Response.json({ error: 'Component not found in documentation' }, { status: 404 })
17+
}
18+
19+
return Response.json(dataAttrDoc)
20+
}

0 commit comments

Comments
 (0)