Skip to content

Commit

Permalink
Added event for dev.near.org to be able to browse with the url (#2095)
Browse files Browse the repository at this point in the history
* feat: the documentation can be navigated with the following links

* feat: the documentation can be navigated with the following links
  • Loading branch information
matiasbenary authored Jul 1, 2024
1 parent 65059e2 commit 2062d3b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion website/src/theme/Root.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// https://docusaurus.io/docs/swizzling#wrapper-your-site-with-root
import '@near-wallet-selector/modal-ui/styles.css';

import React from 'react';
import React, { useEffect } from 'react';
import Gleap from "gleap"; // See https://gleap.io/docs/javascript/ and https://app.gleap.io/projects/62697858a4f6850036ae2e6a/widget
import { withRouter } from 'react-router-dom';
import { useHistory } from '@docusaurus/router';
import useIsBrowser from '@docusaurus/useIsBrowser'; // https://docusaurus.io/docs/advanced/ssg#useisbrowser

import { useInitWallet } from '@theme/scripts/wallet-selector';
Expand All @@ -12,6 +13,25 @@ function Root({ children, location }) {
useInitWallet({ createAccessKeyFor: 'v1.social08.testnet', networkId: 'testnet' });
const isBrowser = useIsBrowser();

const history = useHistory();

useEffect(() => {
const sendMessage = (url) => {
parent.postMessage(
{ type: 'urlChange', url },
'*'
);
};

const unlisten = history.listen(({ pathname }) => {
sendMessage(pathname);
});

return () => {
unlisten();
};
}, [history]);

if (isBrowser) {
const { initRudderAnalytics, recordPageView } = require('./scripts/rudderstack');

Expand Down

0 comments on commit 2062d3b

Please sign in to comment.