diff --git a/components/DocsHelp.tsx b/components/DocsHelp.tsx index 2709bd2d3..e7bec3330 100644 --- a/components/DocsHelp.tsx +++ b/components/DocsHelp.tsx @@ -58,6 +58,22 @@ export function DocsHelp({ const [error, setError] = useState(''); const feedbackFormRef = useRef(null); + let gitredirect = ''; + if ( + typeof fileRenderType === 'string' && + fileRenderType.startsWith('https://') + ) { + gitredirect = fileRenderType; + } else if (fileRenderType === 'tsx') { + gitredirect = `https://github.com/json-schema-org/website/blob/main/pages${extractPathWithoutFragment(router.asPath) + '/index.page.tsx'}`; + } else if (fileRenderType === '_indexmd') { + gitredirect = `https://github.com/json-schema-org/website/blob/main/pages${extractPathWithoutFragment(router.asPath) + '/_index.md'}`; + } else if (fileRenderType === 'indexmd') { + gitredirect = `https://github.com/json-schema-org/website/blob/main/pages${extractPathWithoutFragment(router.asPath) + '/index.md'}`; + } else { + gitredirect = `https://github.com/json-schema-org/website/blob/main/pages${extractPathWithoutFragment(router.asPath) + '.md'}`; + } + // Generate GitHub redirect URL const getGitRedirect = () => { if ( @@ -348,6 +364,31 @@ export function DocsHelp({

+ {showEditOption && ( +
+ + + Edit this page on Github + +
+ )} + {showEditOption && (