Add BrowserOnly component to avoid SSG errors

Signed-off-by: Marcos Lilljedahl <marcosnils@gmail.com>
This commit is contained in:
Marcos Lilljedahl 2022-03-24 15:55:24 -03:00
parent b401cdafd9
commit 70c49495aa
2 changed files with 12 additions and 1 deletions

View File

@ -31,8 +31,11 @@ You can use a local socket in an action:
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import BrowserOnly from '@docusaurus/BrowserOnly';
<Tabs defaultValue={window.navigator.userAgent.indexOf('Win') != -1 ? 'windows': 'unix'} groupId="client-env">
<BrowserOnly>
{() =>
<Tabs defaultValue={ window.navigator.userAgent.indexOf('Win') != -1 ? 'windows': 'unix'} groupId="client-env">
<TabItem value="unix" label="Linux/macOS">
@ -48,6 +51,8 @@ import TabItem from '@theme/TabItem';
</TabItem>
</Tabs>
}
</BrowserOnly>
## Environment variables

View File

@ -11,7 +11,10 @@ This guide shows you the Dagger way.
Within 5 minutes, you will have a local CI/CD loop and run your first test & build pipeline.
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
import BrowserOnly from '@docusaurus/BrowserOnly';
<BrowserOnly>
{() =>
<Tabs defaultValue={
window.navigator.userAgent.indexOf('Linux') != -1 ? 'linux':
window.navigator.userAgent.indexOf('Win') != -1 ? 'windows':
@ -275,6 +278,9 @@ It becomes even more obvious when the change is not as straightforward as knowin
</TabItem>
</Tabs>
}
</BrowserOnly>
:::tip
Now that we are comfortable with our local CI/CD loop, let us configure a remote CI environment in the second part.