diff --git a/app/platform-redirect/page.tsx b/app/platform-redirect/page.tsx
index 3cfd54088e637..88e23b44e1084 100644
--- a/app/platform-redirect/page.tsx
+++ b/app/platform-redirect/page.tsx
@@ -39,12 +39,33 @@ export default async function Page(props: {
// get rid of irrelevant platforms for the `next` path
const platformList = extractPlatforms(rootNode).filter(platform_ => {
- const node = nodeForPath(rootNode, [
+ // First check the main platform path
+ let node = nodeForPath(rootNode, [
'platforms',
platform_.key,
...pathname.split('/').filter(Boolean),
]);
+ // If not found, check if it's a guide (like dart/guides/flutter)
+ if (!node && platform_.guides) {
+ for (const guide of platform_.guides) {
+ node = nodeForPath(rootNode, [
+ 'platforms',
+ platform_.key,
+ 'guides',
+ guide.name,
+ ...pathname.split('/').filter(Boolean),
+ ]);
+ if (node) {
+ // Create a copy of the platform with the guide URL to avoid mutating the original
+ const platformCopy = {...platform_, url: guide.url};
+ // Update the platform reference to use the copy
+ Object.assign(platform_, platformCopy);
+ break;
+ }
+ }
+ }
+
// extract title and description for displaying it on page
if (node && title === defaultTitle && pathname.length > 0) {
title = node.frontmatter.title ?? title;
@@ -54,18 +75,78 @@ export default async function Page(props: {
return !!node;
});
- if (platformList.length === 0) {
+ // For JavaScript platforms, also include individual frameworks that support the content
+ const expandedPlatformList = [...platformList];
+
+ // Find JavaScript platform and add its supported frameworks
+ // Only use JavaScript platform if it's already in the filtered list (has relevant content)
+ const javascriptPlatform = platformList.find(p => p.key === 'javascript');
+
+ if (
+ javascriptPlatform &&
+ (pathname.startsWith('/session-replay/') ||
+ pathname.startsWith('/tracing/') ||
+ pathname.startsWith('/profiling/') ||
+ pathname.startsWith('/logs/'))
+ ) {
+ // Get the JavaScript page to check which frameworks are supported
+ const jsPageNode = nodeForPath(rootNode, [
+ 'platforms',
+ 'javascript',
+ ...pathname.split('/').filter(Boolean),
+ ]);
+
+ if (jsPageNode && jsPageNode.frontmatter.notSupported) {
+ const notSupported = jsPageNode.frontmatter.notSupported;
+
+ // Remove JavaScript from the main list temporarily
+ const otherPlatforms = expandedPlatformList.filter(p => p.key !== 'javascript');
+
+ // Add supported JavaScript frameworks as separate entries
+ const jsFrameworks: typeof platformList = [];
+ javascriptPlatform.guides?.forEach(guide => {
+ const guideKey = `javascript.${guide.name}`;
+ if (!notSupported.includes(guideKey)) {
+ jsFrameworks.push({
+ key: guideKey,
+ name: guide.name,
+ type: 'platform' as const,
+ url: javascriptPlatform.url,
+ title: guide.title,
+ caseStyle: guide.caseStyle,
+ sdk: guide.sdk,
+ fallbackPlatform: guide.fallbackPlatform,
+ language: guide.language,
+ categories: guide.categories,
+ keywords: guide.keywords,
+ guides: [],
+ integrations: [],
+ icon: `javascript-${guide.name}`,
+ });
+ }
+ });
+
+ // Rebuild the list with JavaScript and its frameworks at the end
+ expandedPlatformList.length = 0; // Clear the array
+ expandedPlatformList.push(...otherPlatforms); // Add other platforms first
+ expandedPlatformList.push(javascriptPlatform); // Add JavaScript platform
+ expandedPlatformList.push(...jsFrameworks); // Add JavaScript frameworks last
+ }
+ }
+
+ if (expandedPlatformList.length === 0) {
// try to redirect the user to the page directly, might result in 404
return redirect(next);
}
const requestedPlatform = Array.isArray(platform) ? platform[0] : platform;
if (requestedPlatform) {
- const isValidPlatform = platformList.some(
+ const validPlatform = expandedPlatformList.find(
p => p.key === requestedPlatform?.toLowerCase()
);
- if (isValidPlatform) {
- return redirect(`/platforms/${requestedPlatform}${pathname}`);
+ if (validPlatform) {
+ // Use the platform's URL (which may have been updated to point to a guide)
+ return redirect(`${validPlatform.url}${pathname}`);
}
}
@@ -82,19 +163,24 @@ export default async function Page(props: {