diff --git a/docs/1. intro.mdx b/docs/1. intro.mdx
index 2854f32..4a31792 100644
--- a/docs/1. intro.mdx
+++ b/docs/1. intro.mdx
@@ -4,9 +4,12 @@ title: Sourcify Docs
---
import EmbedReadme from "./EmbedReadme";
-const URL = "https://raw.githubusercontent.com/ethereum/sourcify/master/README.md";
-const displayURL = URL.replace("https://raw.githubusercontent.com/", "");
-export const ReadmeLink = () => ({displayURL});
+const repo = "ethereum/sourcify";
+const branch = "master";
+const readmePath = "/README.md";
+const rawBaseUrl = "https://raw.githubusercontent.com";
+const pageBaseUrl = "https://github.com";
+export const ReadmeLink = () => ({repo + readmePath});
*Content from *
-
+
diff --git a/docs/2. Running Sourcify/1-Server.mdx b/docs/2. Running Sourcify/1-Server.mdx
index d819f3d..7999e06 100644
--- a/docs/2. Running Sourcify/1-Server.mdx
+++ b/docs/2. Running Sourcify/1-Server.mdx
@@ -4,9 +4,12 @@ slug: /running-server
---
import EmbedReadme from "../EmbedReadme";
-const URL = "https://raw.githubusercontent.com/ethereum/sourcify/master/services/server/README.md";
-const displayURL = URL.replace("https://raw.githubusercontent.com/", "");
-export const ReadmeLink = () => ({displayURL});
+const repo = "ethereum/sourcify";
+const branch = "master"
+const readmePath = "/services/server/README.md";
+const rawBaseUrl = "https://raw.githubusercontent.com";
+const pageBaseUrl = "https://github.com";
+export const ReadmeLink = () => ({repo + readmePath});
*Content from *
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/docs/2. Running Sourcify/2-UI.mdx b/docs/2. Running Sourcify/2-UI.mdx
index de515dd..2877ec8 100644
--- a/docs/2. Running Sourcify/2-UI.mdx
+++ b/docs/2. Running Sourcify/2-UI.mdx
@@ -4,9 +4,12 @@ slug: /running-ui
---
import EmbedReadme from "../EmbedReadme";
-const URL = "https://raw.githubusercontent.com/sourcifyeth/ui/master/README.md";
-const displayURL = URL.replace("https://raw.githubusercontent.com/", "");
-export const ReadmeLink = () => ({displayURL});
+const repo = "sourcifyeth/ui";
+const branch = "master";
+const readmePath = "/README.md";
+const rawBaseUrl = "https://raw.githubusercontent.com";
+const pageBaseUrl = "https://github.com";
+export const ReadmeLink = () => ({repo + readmePath});
*Content from *
-
+
diff --git a/docs/2. Running Sourcify/3-Monitor.mdx b/docs/2. Running Sourcify/3-Monitor.mdx
index 07703a1..48c8f68 100644
--- a/docs/2. Running Sourcify/3-Monitor.mdx
+++ b/docs/2. Running Sourcify/3-Monitor.mdx
@@ -4,9 +4,12 @@ slug: /running-monitor
---
import EmbedReadme from "../EmbedReadme";
-const URL = "https://raw.githubusercontent.com/ethereum/sourcify/master/services/monitor/README.md";
-const displayURL = URL.replace("https://raw.githubusercontent.com/", "");
-export const ReadmeLink = () => ({displayURL});
+const repo = "ethereum/sourcify";
+const branch = "master";
+const readmePath = "/services/monitor/README.md";
+const rawBaseUrl = "https://raw.githubusercontent.com";
+const pageBaseUrl = "https://github.com";
+export const ReadmeLink = () => ({repo + readmePath});
*Content from *
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/docs/EmbedReadme.js b/docs/EmbedReadme.js
index f04461f..eedd08d 100644
--- a/docs/EmbedReadme.js
+++ b/docs/EmbedReadme.js
@@ -1,15 +1,42 @@
import React, { useEffect, useState } from "react";
import { parse } from "marked";
-export default function EmbedReadme({ url }) {
+export default function EmbedReadme({ repo, branch, readmePath, rawBaseUrl, pageBaseUrl }) {
const [content, setContent] = useState();
useEffect(() => {
- fetch(url)
+ fetch(rawBaseUrl + "/" + repo + "/" + branch + readmePath)
.then((response) => response.text())
- .then((text) => setContent(parse(text)));
+ .then((text) => {
+ // Replace relative markdown links with absolute ones
+ // Matches markdown links that don't start with "http"
+ const processedText = text.replace(/\[([^\]]+)\]\((?!http)([^)]+)\)/g, (match, title, path) => {
+ // Handle anchor links
+ if (path.startsWith("#")) {
+ return `[${title}](${pageBaseUrl}/${repo}/tree/${branch}${readmePath}${path})`;
+ }
+
+ // Resolve relative paths (including ../)
+ const currentPath = readmePath.split("/").slice(0, -1);
+ const pathParts = path.split("/");
+
+ let resolvedPath = [...currentPath];
+ for (const part of pathParts) {
+ if (part === "..") {
+ resolvedPath.pop();
+ } else {
+ resolvedPath.push(part);
+ }
+ }
+
+ return `[${title}](${pageBaseUrl}/${repo}/tree/${branch}/${resolvedPath.join("/")})`;
+ });
+ setContent(parse(processedText));
+ });
}, []);
- if (!content) return "Loading from " + url + "...";
+ console.log(rawBaseUrl);
+
+ if (!content) return "Loading from " + rawBaseUrl + readmePath + "...";
return ;
}