Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/json-api/platforms.json/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {extractPlatforms, getDocsRootNode} from 'sentry-docs/docTree';

export const GET = async (_request: Request) => {
const rootNode = await getDocsRootNode();
// this regex deals with names like .NET that would otherwise be sorted at the top
const leadingNonAlphaRegex = /^[^\w]/;
// sort the platforms alphabetically
const sortedPlatforms = extractPlatforms(rootNode).sort((a, b) =>
(a.title ?? a.name)
.replace(leadingNonAlphaRegex, '')
.localeCompare((b.title ?? b.name).replace(leadingNonAlphaRegex, ''))
);

return new Response(JSON.stringify(sortedPlatforms), {
headers: {'content-type': 'application/json'},
});
};
Loading