File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 1+ import { useRouter } from 'next/router' ;
2+ import { ExternalLink } from './ExternalLink' ;
3+ import { IconGitHub } from './Icon/IconGitHub' ;
4+
5+ const githubBranch = 'main' ;
6+ const baseGithubLink = `https://github.com/reactjs/react.dev/edit/${ githubBranch } /` ;
7+
8+ export const EditThis = ( ) => {
9+ const { asPath} = useRouter ( ) ;
10+ const cleanedPath = asPath . split ( / [ \? \# ] / ) [ 0 ] ;
11+ return (
12+ < div className = "flex text-link dark:text-link-dark group justify-start align-middle" >
13+ < IconGitHub />
14+ < ExternalLink href = { `${ baseGithubLink } src/content/${ cleanedPath } .md` } >
15+ < span className = "text-lg group-hover:underline" >
16+ Edit this page on Github
17+ </ span >
18+ </ ExternalLink >
19+ </ div >
20+ ) ;
21+ } ;
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import {HomeContent} from './HomeContent';
2121import { TopNav } from './TopNav' ;
2222import cn from 'classnames' ;
2323import Head from 'next/head' ;
24+ import { EditThis } from 'components/EditThis' ;
2425
2526import ( /* webpackPrefetch: true */ '../MDX/CodeBlock/CodeBlock' ) ;
2627
@@ -88,6 +89,7 @@ export function Page({
8889 </ LanguagesContext . Provider >
8990 </ TocContext . Provider >
9091 </ div >
92+ { ! isBlogIndex && < EditThis /> }
9193 { ! isBlogIndex && (
9294 < DocsPageFooter
9395 route = { route }
You can’t perform that action at this time.
0 commit comments