Skip to content

Commit 4bb8e28

Browse files
committed
feat: Add platforms.json API
1 parent fcd73e9 commit 4bb8e28

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {extractPlatforms, getDocsRootNode} from 'sentry-docs/docTree';
2+
3+
export const GET = async (_request: Request) => {
4+
const rootNode = await getDocsRootNode();
5+
// this regex deals with names like .NET that would otherwise be sorted at the top
6+
const leadingNonAlphaRegex = /^[^\w]/;
7+
// sort the platforms alphabetically
8+
const sortedPlatforms = extractPlatforms(rootNode).sort((a, b) =>
9+
(a.title ?? a.name)
10+
.replace(leadingNonAlphaRegex, '')
11+
.localeCompare((b.title ?? b.name).replace(leadingNonAlphaRegex, ''))
12+
);
13+
14+
return new Response(JSON.stringify(sortedPlatforms), {
15+
headers: {'content-type': 'application/json'},
16+
});
17+
};

0 commit comments

Comments
 (0)