Skip to content

Commit 3220df6

Browse files
committed
Add edit page link
1 parent 626d70f commit 3220df6

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

docusaurus.config.js

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,33 @@ const copyright = `
1313
</div>
1414
`;
1515

16+
// Map of external repositories to their GitHub repository names, paths, and organizations
17+
const externalRepos = {
18+
'c2pa-c': { repo: 'c2pa-c', path: '', org: 'contentauth' },
19+
'c2pa-min': { repo: 'c2pa-min', path: '', org: 'contentauth' },
20+
'c2pa-node': { repo: 'c2pa-node', path: '', org: 'contentauth' },
21+
'c2pa-node-example': {
22+
repo: 'c2pa-node-example',
23+
path: '',
24+
org: 'contentauth',
25+
},
26+
'c2pa-python': { repo: 'c2pa-python', path: '', org: 'contentauth' },
27+
'c2pa-python-example': {
28+
repo: 'c2pa-python-example',
29+
path: '',
30+
org: 'contentauth',
31+
},
32+
'c2pa-service-example': {
33+
repo: 'c2pa-service-example',
34+
path: '',
35+
org: 'contentauth',
36+
},
37+
c2patool: { repo: 'c2pa-rs', path: 'cli/', org: 'contentauth' },
38+
'js-sdk': { repo: 'c2pa-js', path: '', org: 'contentauth' },
39+
'rust-sdk': { repo: 'c2pa-rs', path: '', org: 'contentauth' },
40+
trustmark: { repo: 'trustmark', path: '', org: 'adobe' },
41+
};
42+
1643
/** @type {import('@docusaurus/types').Config} */
1744
const config = {
1845
title: 'Open-source tools for content authenticity and provenance',
@@ -49,6 +76,33 @@ const config = {
4976
({
5077
docs: {
5178
sidebarPath: require.resolve('./sidebars.js'),
79+
editUrl: ({ docPath }) => {
80+
// Special case for supported-formats.md files
81+
if (docPath.endsWith('supported-formats.md')) {
82+
return 'https://github.com/contentauth/c2pa-rs/edit/main/docs/supported-formats.md';
83+
}
84+
85+
// Check if the doc is from an external repository
86+
const externalRepo = Object.keys(externalRepos).find((repo) =>
87+
docPath.startsWith(`${repo}/`),
88+
);
89+
90+
if (externalRepo) {
91+
// Get the GitHub repository info for this external repo
92+
const repoInfo = externalRepos[externalRepo];
93+
// Remove the repo prefix from the path to get the relative path in the repo
94+
let repoPath = docPath.replace(`${externalRepo}/`, '');
95+
// Convert readme.md to README.md in the path
96+
repoPath = repoPath.replace(/readme\.md$/i, 'README.md');
97+
return `https://github.com/${repoInfo.org}/${repoInfo.repo}/edit/main/${repoInfo.path}${repoPath}`;
98+
}
99+
100+
// Add edit link for main docs
101+
let mainPath = docPath;
102+
// Convert readme.md to README.md in the path
103+
mainPath = mainPath.replace(/readme\.md$/i, 'README.md');
104+
return `https://github.com/contentauth/opensource.contentauth.org/edit/main/docs/${mainPath}`;
105+
},
52106
},
53107
theme: {
54108
customCss: require.resolve('./src/css/custom.css'),
@@ -92,7 +146,6 @@ const config = {
92146
content: 'Open-source tools for content authenticity and provenance',
93147
},
94148
],
95-
96149
// Relative to your site's 'static' directory.
97150
// Cannot be SVGs. Can be external URLs too.
98151
colorMode: {

0 commit comments

Comments
 (0)