Skip to content

Commit

Permalink
ipfs compat
Browse files Browse the repository at this point in the history
  • Loading branch information
onnovisser committed Apr 26, 2024
1 parent 39f9ad0 commit 49d3a1b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion centrifuge-app/src/components/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { QueryClient, QueryClientProvider } from 'react-query'
import { LinkProps, Redirect, Route, RouteProps, BrowserRouter as Router, Switch, matchPath } from 'react-router-dom'
import { config, evmChains } from '../config'
import PoolsPage from '../pages/Pools'
import { getBasename } from '../utils/ipfs'
import { pinToApi } from '../utils/pinToApi'
import { DebugFlags, initialFlagsState } from './DebugFlags'
import { DemoBanner } from './DemoBanner'
Expand Down Expand Up @@ -55,6 +56,9 @@ const centConfig: UserProvidedConfig = {
}),
}

const path = window?.location?.pathname ?? '/'
const basename = getBasename(path)

export function Root() {
const [debugState, setDebugState] = React.useState(initialFlagsState)
const isThemeToggled = debugState.alternativeTheme
Expand All @@ -77,7 +81,7 @@ export function Root() {
<GlobalStyle />
<FabricGlobalStyle />
<CentrifugeProvider config={centConfig}>
<Router>
<Router basename={basename}>
<DemoBanner />

<WalletProvider
Expand Down
14 changes: 14 additions & 0 deletions centrifuge-app/src/utils/ipfs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export function getBasename(path: string) {
const parts = path.split('/')
const [, second, third] = parts

if (second === 'ipfs') {
return `/ipfs/${third}/`
}

if (second === 'ipns') {
return `/ipns/${third}/`
}

return '/'
}
1 change: 1 addition & 0 deletions centrifuge-app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { nodePolyfills } from 'vite-plugin-node-polyfills'
// https://vitejs.dev/config/
// when making changes to this file start vite with --force flag
export default defineConfig({
base: './',
server: {
watch: {
// configuration to allow HMR in other modules in yarn
Expand Down

0 comments on commit 49d3a1b

Please sign in to comment.