Skip to content
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

Docusaurus: edit EditThisPage component #5835

Merged
merged 3 commits into from
Apr 9, 2024
Merged
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
22 changes: 22 additions & 0 deletions src/theme/EditThisPage/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import Translate from '@docusaurus/Translate';
import { ThemeClassNames } from '@docusaurus/theme-common';
import Link from '@docusaurus/Link';
import type { Props } from '@theme/EditThisPage';
import styles from './styles.module.scss'
import clsx from 'clsx';

export default function EditThisPage({ editUrl }: Props): JSX.Element {
return (
<Link to={editUrl} className={clsx(ThemeClassNames.common.editThisPage, 'edit-git', styles.editLink)}>
<Translate
id="theme.common.editThisPage"
description="The link label to edit the current page">
Edit this page on GitHub
</Translate>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 12 12" style={{paddingLeft: `3px`}}>
<path fill="currentColor" d="M6 1h5v5L8.86 3.85 4.7 8 4 7.3l4.15-4.16zM2 3h2v1H2v6h6V8h1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1"/>
</svg>
</Link>
);
}
18 changes: 18 additions & 0 deletions src/theme/EditThisPage/styles.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.editLink {
font-size: 0.875rem;
display: flex;
align-items: center;
color: var(--gray-600) !important;
text-decoration: underline;
&:hover {
text-decoration: underline;
color: var(--gray-800) !important;
}
}
:root[data-theme='dark'] {
.editLink {
&:hover {
color: var(--gray-400) !important;
}
}
}