From 9425ea9893a837197ea8cc5c369484da4461295e Mon Sep 17 00:00:00 2001 From: Bartosz Kaszubowski Date: Tue, 2 Dec 2025 19:25:33 +0100 Subject: [PATCH] docs: add helper for creating versioned core repo links --- docs/the-new-architecture/pure-cxx-modules.md | 3 ++- website/src/getCoreBranchNameForCurrentVersion.ts | 6 ++++++ .../version-0.77/the-new-architecture/pure-cxx-modules.md | 3 ++- .../version-0.78/the-new-architecture/pure-cxx-modules.md | 3 ++- .../version-0.79/the-new-architecture/pure-cxx-modules.md | 3 ++- .../version-0.80/the-new-architecture/pure-cxx-modules.md | 3 ++- .../version-0.81/the-new-architecture/pure-cxx-modules.md | 3 ++- .../version-0.82/the-new-architecture/pure-cxx-modules.md | 3 ++- 8 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 website/src/getCoreBranchNameForCurrentVersion.ts diff --git a/docs/the-new-architecture/pure-cxx-modules.md b/docs/the-new-architecture/pure-cxx-modules.md index 3fff6355e42..2a259ff04a9 100644 --- a/docs/the-new-architecture/pure-cxx-modules.md +++ b/docs/the-new-architecture/pure-cxx-modules.md @@ -1,3 +1,4 @@ +import {getCoreBranchNameForCurrentVersion} from '@site/src/getCoreBranchNameForCurrentVersion'; import {getCurrentVersion} from '@site/src/getCurrentVersion'; import CodeBlock from '@theme/CodeBlock'; @@ -228,7 +229,7 @@ The final step is to register the new C++ Turbo Native Module in the runtime, so 1. From the folder `SampleApp/android/app/src/main/jni`, run the following command: -{`curl -O https://raw.githubusercontent.com/facebook/react-native/${getCurrentVersion() === 'latest' ? '' : 'v'}${getCurrentVersion()}/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp`} +{`curl -O https://raw.githubusercontent.com/facebook/react-native/${getCoreBranchNameForCurrentVersion()}/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp`} 2. Then, modify this file as follows: diff --git a/website/src/getCoreBranchNameForCurrentVersion.ts b/website/src/getCoreBranchNameForCurrentVersion.ts new file mode 100644 index 00000000000..09d897d6345 --- /dev/null +++ b/website/src/getCoreBranchNameForCurrentVersion.ts @@ -0,0 +1,6 @@ +import {useActiveVersion} from '@docusaurus/plugin-content-docs/client'; + +export function getCoreBranchNameForCurrentVersion() { + const version = useActiveVersion(undefined); + return version.label === 'Next' ? 'main' : `v${version.label}.0`; +} diff --git a/website/versioned_docs/version-0.77/the-new-architecture/pure-cxx-modules.md b/website/versioned_docs/version-0.77/the-new-architecture/pure-cxx-modules.md index 396b5659549..b6d7b2d8310 100644 --- a/website/versioned_docs/version-0.77/the-new-architecture/pure-cxx-modules.md +++ b/website/versioned_docs/version-0.77/the-new-architecture/pure-cxx-modules.md @@ -1,3 +1,4 @@ +import {getCoreBranchNameForCurrentVersion} from '@site/src/getCoreBranchNameForCurrentVersion'; import {getCurrentVersion} from '@site/src/getCurrentVersion'; import CodeBlock from '@theme/CodeBlock'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import constants from '@site/core/TabsConstants'; @@ -227,7 +228,7 @@ The final step is to register the new C++ Turbo Native Module in the runtime, so 1. From the folder `SampleApp/android/app/src/main/jni`, run the following command: -{`curl -O https://raw.githubusercontent.com/facebook/react-native/${getCurrentVersion() === 'latest' ? '' : 'v'}${getCurrentVersion()}/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp`} +{`curl -O https://raw.githubusercontent.com/facebook/react-native/${getCoreBranchNameForCurrentVersion()}/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp`} 2. Then, modify this file as follows: diff --git a/website/versioned_docs/version-0.78/the-new-architecture/pure-cxx-modules.md b/website/versioned_docs/version-0.78/the-new-architecture/pure-cxx-modules.md index 396b5659549..b6d7b2d8310 100644 --- a/website/versioned_docs/version-0.78/the-new-architecture/pure-cxx-modules.md +++ b/website/versioned_docs/version-0.78/the-new-architecture/pure-cxx-modules.md @@ -1,3 +1,4 @@ +import {getCoreBranchNameForCurrentVersion} from '@site/src/getCoreBranchNameForCurrentVersion'; import {getCurrentVersion} from '@site/src/getCurrentVersion'; import CodeBlock from '@theme/CodeBlock'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import constants from '@site/core/TabsConstants'; @@ -227,7 +228,7 @@ The final step is to register the new C++ Turbo Native Module in the runtime, so 1. From the folder `SampleApp/android/app/src/main/jni`, run the following command: -{`curl -O https://raw.githubusercontent.com/facebook/react-native/${getCurrentVersion() === 'latest' ? '' : 'v'}${getCurrentVersion()}/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp`} +{`curl -O https://raw.githubusercontent.com/facebook/react-native/${getCoreBranchNameForCurrentVersion()}/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp`} 2. Then, modify this file as follows: diff --git a/website/versioned_docs/version-0.79/the-new-architecture/pure-cxx-modules.md b/website/versioned_docs/version-0.79/the-new-architecture/pure-cxx-modules.md index d2561737ed3..665a980f010 100644 --- a/website/versioned_docs/version-0.79/the-new-architecture/pure-cxx-modules.md +++ b/website/versioned_docs/version-0.79/the-new-architecture/pure-cxx-modules.md @@ -1,3 +1,4 @@ +import {getCoreBranchNameForCurrentVersion} from '@site/src/getCoreBranchNameForCurrentVersion'; import {getCurrentVersion} from '@site/src/getCurrentVersion'; import CodeBlock from '@theme/CodeBlock'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import constants from '@site/core/TabsConstants'; @@ -227,7 +228,7 @@ The final step is to register the new C++ Turbo Native Module in the runtime, so 1. From the folder `SampleApp/android/app/src/main/jni`, run the following command: -{`curl -O https://raw.githubusercontent.com/facebook/react-native/${getCurrentVersion() === 'latest' ? '' : 'v'}${getCurrentVersion()}/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp`} +{`curl -O https://raw.githubusercontent.com/facebook/react-native/${getCoreBranchNameForCurrentVersion()}/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp`} 2. Then, modify this file as follows: diff --git a/website/versioned_docs/version-0.80/the-new-architecture/pure-cxx-modules.md b/website/versioned_docs/version-0.80/the-new-architecture/pure-cxx-modules.md index d2561737ed3..665a980f010 100644 --- a/website/versioned_docs/version-0.80/the-new-architecture/pure-cxx-modules.md +++ b/website/versioned_docs/version-0.80/the-new-architecture/pure-cxx-modules.md @@ -1,3 +1,4 @@ +import {getCoreBranchNameForCurrentVersion} from '@site/src/getCoreBranchNameForCurrentVersion'; import {getCurrentVersion} from '@site/src/getCurrentVersion'; import CodeBlock from '@theme/CodeBlock'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import constants from '@site/core/TabsConstants'; @@ -227,7 +228,7 @@ The final step is to register the new C++ Turbo Native Module in the runtime, so 1. From the folder `SampleApp/android/app/src/main/jni`, run the following command: -{`curl -O https://raw.githubusercontent.com/facebook/react-native/${getCurrentVersion() === 'latest' ? '' : 'v'}${getCurrentVersion()}/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp`} +{`curl -O https://raw.githubusercontent.com/facebook/react-native/${getCoreBranchNameForCurrentVersion()}/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp`} 2. Then, modify this file as follows: diff --git a/website/versioned_docs/version-0.81/the-new-architecture/pure-cxx-modules.md b/website/versioned_docs/version-0.81/the-new-architecture/pure-cxx-modules.md index d2561737ed3..665a980f010 100644 --- a/website/versioned_docs/version-0.81/the-new-architecture/pure-cxx-modules.md +++ b/website/versioned_docs/version-0.81/the-new-architecture/pure-cxx-modules.md @@ -1,3 +1,4 @@ +import {getCoreBranchNameForCurrentVersion} from '@site/src/getCoreBranchNameForCurrentVersion'; import {getCurrentVersion} from '@site/src/getCurrentVersion'; import CodeBlock from '@theme/CodeBlock'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import constants from '@site/core/TabsConstants'; @@ -227,7 +228,7 @@ The final step is to register the new C++ Turbo Native Module in the runtime, so 1. From the folder `SampleApp/android/app/src/main/jni`, run the following command: -{`curl -O https://raw.githubusercontent.com/facebook/react-native/${getCurrentVersion() === 'latest' ? '' : 'v'}${getCurrentVersion()}/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp`} +{`curl -O https://raw.githubusercontent.com/facebook/react-native/${getCoreBranchNameForCurrentVersion()}/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp`} 2. Then, modify this file as follows: diff --git a/website/versioned_docs/version-0.82/the-new-architecture/pure-cxx-modules.md b/website/versioned_docs/version-0.82/the-new-architecture/pure-cxx-modules.md index d2561737ed3..665a980f010 100644 --- a/website/versioned_docs/version-0.82/the-new-architecture/pure-cxx-modules.md +++ b/website/versioned_docs/version-0.82/the-new-architecture/pure-cxx-modules.md @@ -1,3 +1,4 @@ +import {getCoreBranchNameForCurrentVersion} from '@site/src/getCoreBranchNameForCurrentVersion'; import {getCurrentVersion} from '@site/src/getCurrentVersion'; import CodeBlock from '@theme/CodeBlock'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import constants from '@site/core/TabsConstants'; @@ -227,7 +228,7 @@ The final step is to register the new C++ Turbo Native Module in the runtime, so 1. From the folder `SampleApp/android/app/src/main/jni`, run the following command: -{`curl -O https://raw.githubusercontent.com/facebook/react-native/${getCurrentVersion() === 'latest' ? '' : 'v'}${getCurrentVersion()}/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp`} +{`curl -O https://raw.githubusercontent.com/facebook/react-native/${getCoreBranchNameForCurrentVersion()}/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp`} 2. Then, modify this file as follows: