Skip to content

Commit cc487f1

Browse files
committed
fix(config): point edit links at the main branch
Signed-off-by: vedchaudhari <vedc2853@gmail.com>
1 parent b65d7c1 commit cc487f1

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎.changeset/edit-url-main.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@doc-kit/core': patch
3+
---
4+
5+
Point "edit this page" links at the `main` branch instead of the git ref. GitHub can't edit files at `HEAD` or a tag, so those links returned a 404.

‎packages/core/src/utils/configuration/templates.mjs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ export const CHANGELOG_URL =
55
// This is the Base URL for viewing a file within GitHub UI
66
export const GITHUB_BLOB_URL = 'https://github.com/{repository}/blob/{ref}/';
77

8-
// This is the API docs base URL for editing a file on GitHub UI
9-
export const GITHUB_EDIT_URL = 'https://github.com/{repository}/edit/{ref}';
8+
// This is the API docs base URL for editing a file on GitHub UI.
9+
// GitHub can only edit files on a branch, so this can't use `{ref}`
10+
// (`HEAD` or a tag would 404).
11+
export const GITHUB_EDIT_URL = 'https://github.com/{repository}/edit/main';
1012

1113
/**
1214
* Populate a template string based on a configuration

‎packages/node/src/config/__tests__/index.test.mjs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ describe('Node.js preset', () => {
1919
assert.ok(preset.html.editURL.includes('/doc/api{path}.md'));
2020
});
2121

22+
it('should link "edit this page" to a branch, not the git ref', () => {
23+
assert.ok(
24+
preset.html.editURL.startsWith(
25+
'https://github.com/{repository}/edit/main/'
26+
)
27+
);
28+
});
29+
2230
it('should ship the Node.js llms.txt template', () => {
2331
assert.ok(existsSync(preset['llms-txt'].templatePath));
2432
});

0 commit comments

Comments
 (0)