-
Notifications
You must be signed in to change notification settings - Fork 15
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
[SEO 16.] Add nofollow to docusaurus external links #227
Conversation
|
||
export default function EditThisPage({editUrl}: Props): JSX.Element { | ||
return ( | ||
<Link to={editUrl} className={ThemeClassNames.common.editThisPage} rel="nofollow noopener noreferrer"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion
I see that the current link on our docs has also target=_blank
. Will it stay the same? Does Link
take care of that internally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that the current link on our docs has also target=_blank. Will it stay the same?
Yes.
Does Link take care of that internally?
Yes.
<> | ||
<A | ||
{...props} | ||
rel={isExternal ? 'nofollow noopener noreferrer' : undefined} | ||
target={isExternal ? '_blank' : undefined} | ||
/> | ||
</> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion
You don't need the wrapping element:
<> | |
<A | |
{...props} | |
rel={isExternal ? 'nofollow noopener noreferrer' : undefined} | |
target={isExternal ? '_blank' : undefined} | |
/> | |
</> | |
<A | |
{...props} | |
rel={isExternal ? 'nofollow noopener noreferrer' : undefined} | |
target={isExternal ? '_blank' : undefined} | |
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was generated this way by:
➜ docusaurus git:(main) npm run swizzle
> [email protected] swizzle
> docusaurus swizzle
------------------------------------------------------------------------------------------------------------------------------------------------
Update available 3.6.3 → 3.7.0
To upgrade Docusaurus packages with the latest version, run the following command:
`npm i @docusaurus/core@latest @docusaurus/plugin-client-redirects@latest @docusaurus/preset-classic@latest @docusaurus/tsconfig@latest
@docusaurus/module-type-aliases@latest`
------------------------------------------------------------------------------------------------------------------------------------------------
✔ Select a theme to swizzle: › @docusaurus/theme-classic
✔ Which language do you want to use? › TypeScript
✔
Select or type the component to swizzle.
* = not safe for all swizzle actions
› MDXComponents/A (Safe)
✔ Which swizzle action do you want to do? › Wrap (Safe)
[SUCCESS]
The original code generated:
import React from 'react';
import A from '@theme-original/MDXComponents/A';
import type AType from '@theme/MDXComponents/A';
import type {WrapperProps} from '@docusaurus/types';
type Props = WrapperProps<typeof AType>;
export default function AWrapper(props: Props): JSX.Element {
return (
<>
<A {...props} />
</>
);
}
I'd keep it as is just to be on the safe side.
Co-authored-by: Riccardo <[email protected]>
Use swizzling to replace original Docusaurus components:
https://docusaurus.io/docs/swizzling/
MDXComponents/A
component to add nofollow (it's safe)EditThisPage
component to override it (it's unsafe if there is a breaking change then we would have to update it). We added rel nofollow.