Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/__tests__/DocsSourceActions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion src/app/docs/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading