Skip to content

feat(beta): add edit on Github for docs #5622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
26 changes: 26 additions & 0 deletions beta/src/components/Layout/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ import sidebarLearn from '../../sidebarLearn.json';
import sidebarReference from '../../sidebarReference.json';
import type {TocItem} from 'components/MDX/TocContext';
import type {RouteItem} from 'components/Layout/getRouteMeta';
import {ExternalLink} from 'components/ExternalLink';
import {siteConfig} from 'siteConfig';

import(/* webpackPrefetch: true */ '../MDX/CodeBlock/CodeBlock');

function getGithubEditUrl(path: string): string {
return `${siteConfig.editUrl}/../content${path}.md`;
}

interface PageProps {
children: React.ReactNode;
toc: Array<TocItem>;
Expand Down Expand Up @@ -76,6 +82,26 @@ export function Page({children, toc, routeTree, meta, section}: PageProps) {
nextRoute={nextRoute}
prevRoute={prevRoute}
/>
<div className="flex justify-center lg:justify-start px-4 md:px-5">
<ExternalLink
href={getGithubEditUrl(cleanedPath)}
className="flex flex-row border-b border-transparent hover:border-gray-10">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
className="w-6 h-6 mr-2">
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10"
/>
</svg>
Edit on Github
</ExternalLink>
</div>
</div>
</div>
</article>
Expand Down
2 changes: 1 addition & 1 deletion beta/src/siteConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

export const siteConfig = {
editUrl: 'https://github.com/reactjs/reactjs.org/edit/beta/src/pages',
editUrl: 'https://github.com/reactjs/reactjs.org/edit/main/beta/src/pages',
copyright: `Copyright © ${new Date().getFullYear()} Facebook Inc. All Rights Reserved.`,
repoUrl: 'https://github.com/facebook/react',
twitterUrl: 'https://twitter.com/reactjs',
Expand Down