From ab618e62ad965c9e0a04c3ddd132adc60cbb064d Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2026 22:09:54 -0400 Subject: [PATCH] fix: point source links for locally authored hive pages at this repo Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- src/__tests__/DocsSourceActions.test.tsx | 18 ++++++++++++++++++ src/app/docs/[...slug]/page.tsx | 5 ++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/__tests__/DocsSourceActions.test.tsx b/src/__tests__/DocsSourceActions.test.tsx index b93b1f5c..3b66c525 100644 --- a/src/__tests__/DocsSourceActions.test.tsx +++ b/src/__tests__/DocsSourceActions.test.tsx @@ -91,6 +91,24 @@ describe("DocsSourceActions — edit URL resolution", () => { expect(html).not.toContain("hivecommons/pluk/edit"); }); + it("points a locally authored hive page (no upstream twin) at this repo", () => { + const local = + "https://github.com/hivecommons/docs/blob/main/docs/content/hive/governor.md"; + const html = render({ + projectId: "hive", + filePath: "governor.md", + sourceUrl: local, + }); + const links = hrefs(html); + + expect(links[0]).toBe( + "https://github.com/hivecommons/docs/edit/main/docs/content/hive/governor.md?fork=true" + ); + expect(links[1]).toBe(local); + expect(links[2]).toContain(encodeURIComponent(`Source file:\n${local}`)); + expect(html).not.toContain("hivecommons/hive/"); + }); + it("falls back to the project edit base when sourceUrl is not a GitHub blob URL", () => { const html = render({ sourceUrl: "https://gitlab.com/hivecommons/docs/blob/main/README.md", diff --git a/src/app/docs/[...slug]/page.tsx b/src/app/docs/[...slug]/page.tsx index bedff92a..f3110dca 100644 --- a/src/app/docs/[...slug]/page.tsx +++ b/src/app/docs/[...slug]/page.tsx @@ -317,7 +317,10 @@ export default async function DocPage({ params }: Props) { // General-section files live in this repo, not in any synced project. const sourceUrl = isGeneralSectionFile(filePath) ? `https://github.com/hivecommons/docs/blob/main/docs/content/${filePath}` - : page.sourceUrl + : (page.sourceUrl ?? + // No "Synced from" banner: the page is authored in this repo, so the + // project's upstream path would 404. + `https://github.com/hivecommons/docs/blob/main/docs/content/${projectId ?? 'hive'}/${filePath}`) // Extract the layout wrapper (DocsLayout: prose typography, table of // contents, edit-page actions) so it can be rendered explicitly around the