diff --git a/dapp/src/components/ProjectInfo.astro b/dapp/src/components/ProjectInfo.astro index 47cf66a..8927ca7 100644 --- a/dapp/src/components/ProjectInfo.astro +++ b/dapp/src/components/ProjectInfo.astro @@ -146,6 +146,7 @@ import ModalInput from "./utils/ModalInput.astro"; import { initializeProjectState, loadConfigData, loadProjectInfo, setProject } from "../service/StateService"; import type { ConfigData } from "../types/projectConfig"; import { projectInfoLoaded } from "../utils/store"; + import { convertGitHubLink } from "../utils/editLinkFunctions"; document.addEventListener("astro:page-load", () => { initializeProjectState(); @@ -350,7 +351,7 @@ import ModalInput from "./utils/ModalInput.astro"; if (modalProjectName) modalProjectName.textContent = projectInfo.name; if (projectLogo) { if (configData.logoImageLink) { - projectLogo.src = configData.logoImageLink; + projectLogo.src = convertGitHubLink(configData.logoImageLink); projectLogo.style.display = 'block'; } else { projectLogo.style.display = 'none'; diff --git a/dapp/src/utils/editLinkFunctions.ts b/dapp/src/utils/editLinkFunctions.ts new file mode 100644 index 0000000..ce5a93e --- /dev/null +++ b/dapp/src/utils/editLinkFunctions.ts @@ -0,0 +1,12 @@ +export function convertGitHubLink(link: string): string { + const githubFileRegex = /^https:\/\/github\.com\/([^/]+)\/([^/]+)\/blob\/(.+)$/; + + const match = link.match(githubFileRegex); + + if (match) { + const [, owner, repo, path] = match; + return `https://raw.githubusercontent.com/${owner}/${repo}/${path}`; + } else { + return link; + } +}