Skip to content

Commit c4728a7

Browse files
author
Magne Cedric
committed
feat(m-login): fixing link unfurling
1 parent c0aac44 commit c4728a7

File tree

2 files changed

+46
-47
lines changed

2 files changed

+46
-47
lines changed

src/theme/Layout/index.tsx

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React, { useState, useEffect, useMemo } from "react";
22
import { usePluginData } from "@docusaurus/useGlobalData";
3+
import BrowserOnly from "@docusaurus/BrowserOnly";
34
import ldClient from "launchdarkly";
5+
import { MetaMaskProvider } from "@metamask/sdk-react";
46
import { useLocation } from "@docusaurus/router";
57
import Layout from "@theme-original/Layout";
68
import ParserOpenRPC from "@site/src/components/ParserOpenRPC";
@@ -15,6 +17,32 @@ const EXEPT_METHODS = [
1517
"eth_signTypedData_v4",
1618
];
1719

20+
const MetaMaskWrapper = ({ children }) => {
21+
return (
22+
<BrowserOnly>
23+
{() => (
24+
<MetaMaskProvider
25+
debug={false}
26+
sdkOptions={{
27+
checkInstallationOnAllCalls: true,
28+
extensionOnly: true,
29+
preferDesktop: true,
30+
logging: {
31+
sdk: false,
32+
},
33+
dappMetadata: {
34+
name: "Reference pages",
35+
url: window.location.href,
36+
},
37+
}}
38+
>
39+
{children}
40+
</MetaMaskProvider>
41+
)}
42+
</BrowserOnly>
43+
);
44+
};
45+
1846
export default function LayoutWrapper({ children }) {
1947
const location = useLocation();
2048
const { netData } = usePluginData("plugin-json-rpc") as {
@@ -58,20 +86,21 @@ export default function LayoutWrapper({ children }) {
5886

5987
if (!referencePageName) {
6088
return (
61-
<Layout>{children}</Layout>
62-
)
89+
<MetaMaskWrapper>
90+
<Layout>{children}</Layout>
91+
</MetaMaskWrapper>
92+
);
6393
}
6494

6595
return (
6696
<>
67-
{
68-
!ldReady ? null : (
69-
<>
70-
{
71-
newReferenceEnabled ? (
72-
<Layout>
73-
<div className={styles.pageWrapper}>
74-
{children?.props?.children[0]?.type === "aside" && (
97+
{!ldReady ? null : (
98+
<>
99+
{newReferenceEnabled ? (
100+
<MetaMaskWrapper>
101+
<Layout>
102+
<div className={styles.pageWrapper}>
103+
{children?.props?.children[0]?.type === "aside" && (
75104
<>{children.props.children[0]}</>
76105
)}
77106
<div className={styles.mainContainer}>
@@ -84,13 +113,12 @@ export default function LayoutWrapper({ children }) {
84113
</div>
85114
</div>
86115
</Layout>
87-
) : (
88-
<Layout>{children}</Layout>
89-
)
90-
}
91-
</>
92-
)
93-
}
116+
</MetaMaskWrapper>
117+
) : (
118+
<Layout>{children}</Layout>
119+
)}
120+
</>
121+
)}
94122
</>
95-
)
123+
);
96124
}

src/theme/Root.tsx

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)