feat: configable ipfs gateway
This commit is contained in:
parent
d7d85e06df
commit
227605e03f
|
|
@ -9,5 +9,6 @@ NEXT_PUBLIC_DISCORD_LINK="https://discord.gg/9XscSqJEq4"
|
|||
NEXT_PUBLIC_GITHUB_LINK="https://github.com/Crossbell-Box/xlog"
|
||||
NEXT_PUBLIC_CSB_IO=
|
||||
NEXT_PUBLIC_CSB_SCAN="https://scan.crossbell.io"
|
||||
NEXT_PUBLIC_IPFS_GATEWAY="https://cf-ipfs.com/ipfs/"
|
||||
|
||||
REDIS_URL=
|
||||
|
|
@ -6,4 +6,5 @@ NEXT_PUBLIC_DISCORD_LINK=APP_NEXT_PUBLIC_DISCORD_LINK
|
|||
NEXT_PUBLIC_GITHUB_LINK=APP_NEXT_PUBLIC_GITHUB_LINK
|
||||
NEXT_PUBLIC_CSB_IO=APP_NEXT_PUBLIC_CSB_IO
|
||||
NEXT_PUBLIC_CSB_SCAN=APP_NEXT_PUBLIC_CSB_SCAN
|
||||
NEXT_PUBLIC_IPFS_GATEWAY=APP_NEXT_PUBLIC_IPFS_GATEWAY
|
||||
REDIS_URL=APP_NEXT_REDIS_URL
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ stringData:
|
|||
NEXT_PUBLIC_GITHUB_LINK: "https://github.com/Crossbell-Box/xlog"
|
||||
NEXT_PUBLIC_CSB_IO: ""
|
||||
NEXT_PUBLIC_CSB_SCAN: "https://scan.crossbell.io"
|
||||
NEXT_PUBLIC_IPFS_GATEWAY: "https://cf-ipfs.com/ipfs/"
|
||||
REDIS_URL: ${REDIS_URL}
|
||||
kind: Secret
|
||||
metadata:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { CSB_SCAN } from "~/lib/env"
|
||||
import { CSB_SCAN, IPFS_GATEWAY } from "~/lib/env"
|
||||
import { UniLink } from "../ui/UniLink"
|
||||
import { Profile, Note } from "~/lib/types"
|
||||
import { Disclosure } from "@headlessui/react"
|
||||
|
|
@ -87,9 +87,7 @@ export const BlockchainInfo: React.FC<{
|
|||
<div>
|
||||
{page
|
||||
? page.related_urls
|
||||
?.filter((url) =>
|
||||
url.startsWith("https://gateway.ipfs.io/ipfs/"),
|
||||
)
|
||||
?.filter((url) => url.startsWith(IPFS_GATEWAY))
|
||||
.map((url) => {
|
||||
return (
|
||||
<a
|
||||
|
|
@ -99,10 +97,7 @@ export const BlockchainInfo: React.FC<{
|
|||
href={url}
|
||||
key={url}
|
||||
>
|
||||
{url.replace(
|
||||
"https://gateway.ipfs.io/ipfs/",
|
||||
"ipfs://",
|
||||
)}
|
||||
{url.replace(IPFS_GATEWAY, "ipfs://")}
|
||||
</a>
|
||||
)
|
||||
})
|
||||
|
|
@ -113,7 +108,7 @@ export const BlockchainInfo: React.FC<{
|
|||
className="inline-block mr-4 break-all"
|
||||
href={site?.metadata?.uri.replace(
|
||||
"ipfs://",
|
||||
"https://gateway.ipfs.io/ipfs/",
|
||||
IPFS_GATEWAY,
|
||||
)}
|
||||
key={site?.metadata?.uri}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import clsx from "clsx"
|
||||
import React, { useMemo } from "react"
|
||||
import { IPFS_GATEWAY } from "~/lib/env"
|
||||
|
||||
export const Avatar: React.FC<
|
||||
{
|
||||
|
|
@ -22,7 +23,9 @@ export const Avatar: React.FC<
|
|||
const image = useMemo(() => {
|
||||
for (const image of images) {
|
||||
if (image)
|
||||
return image.replace("ipfs://", "https://gateway.ipfs.io/ipfs/")
|
||||
return image
|
||||
.replace("ipfs://", IPFS_GATEWAY)
|
||||
.replace("https://gateway.ipfs.io/ipfs/", IPFS_GATEWAY)
|
||||
}
|
||||
}, [images])
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { useCallback } from "react"
|
||||
import { Web3Storage } from "web3.storage"
|
||||
import { IPFS_GATEWAY } from "../lib/env"
|
||||
|
||||
export const useUploadFile = () => {
|
||||
const uploadFile = useCallback<UploadFile>(async (blob, filename) => {
|
||||
|
|
@ -14,7 +15,7 @@ export const useUploadFile = () => {
|
|||
wrapWithDirectory: false,
|
||||
})
|
||||
return {
|
||||
key: `https://gateway.ipfs.io/ipfs/${cid}`,
|
||||
key: `${IPFS_GATEWAY}${cid}`,
|
||||
}
|
||||
}, [])
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
import { Contract, Indexer } from "crossbell.js"
|
||||
import { Contract, Indexer, Network } from "crossbell.js"
|
||||
import { IPFS_GATEWAY } from "../lib/env"
|
||||
|
||||
Network.setIpfsGateway(IPFS_GATEWAY)
|
||||
|
||||
const indexer = new Indexer()
|
||||
|
||||
|
|
|
|||
|
|
@ -9,4 +9,7 @@ export const APP_DESCRIPTION = process.env.APP_DESCRIPTION
|
|||
export const DISCORD_LINK = process.env.NEXT_PUBLIC_DISCORD_LINK
|
||||
export const GITHUB_LINK = process.env.NEXT_PUBLIC_GITHUB_LINK
|
||||
export const CSB_IO = process.env.NEXT_PUBLIC_CSB_IO
|
||||
export const CSB_SCAN = process.env.NEXT_PUBLIC_CSB_SCAN
|
||||
export const CSB_SCAN =
|
||||
process.env.NEXT_PUBLIC_CSB_SCAN || "https://scan.crossbell.io"
|
||||
export const IPFS_GATEWAY =
|
||||
process.env.NEXT_PUBLIC_IPFS_GATEWAY || "https://cf-ipfs.com/ipfs/"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import Unidata from "unidata.js"
|
||||
import { IPFS_GATEWAY } from "../lib/env"
|
||||
|
||||
let unidata = new Unidata()
|
||||
let unidata = new Unidata({
|
||||
ipfsGateway: IPFS_GATEWAY,
|
||||
})
|
||||
|
||||
export default unidata
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import { ReactQueryDevtools } from "@tanstack/react-query-devtools"
|
|||
import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client"
|
||||
import { createIDBPersister } from "~/lib/persister.client"
|
||||
import { connectorsForWallets, wallet } from "@rainbow-me/rainbowkit"
|
||||
import { CSB_SCAN } from "~/lib/env"
|
||||
import { CSB_SCAN, IPFS_GATEWAY } from "~/lib/env"
|
||||
|
||||
import "@rainbow-me/rainbowkit/styles.css"
|
||||
|
||||
|
|
@ -27,8 +27,7 @@ const { chains, provider } = configureChains(
|
|||
rpcUrls: {
|
||||
default: "https://rpc.crossbell.io",
|
||||
},
|
||||
iconUrl:
|
||||
"https://gateway.ipfs.io/ipfs/QmS8zEetTb6pwdNpVjv5bz55BXiSMGP9BjTJmNcjcUT91t",
|
||||
iconUrl: `${IPFS_GATEWAY}QmS8zEetTb6pwdNpVjv5bz55BXiSMGP9BjTJmNcjcUT91t`,
|
||||
nativeCurrency: {
|
||||
decimals: 18,
|
||||
name: "Crossbell Token",
|
||||
|
|
|
|||
Loading…
Reference in New Issue