Skip to content
Open
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
16 changes: 6 additions & 10 deletions src/theme/MDXComponents/A/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import Link from '@docusaurus/Link';
import { useAnchorTargetClassName } from '@docusaurus/theme-common';
import type { Props } from '@theme/MDXComponents/A';
import clsx from 'clsx';
import type { WrapperProps } from '@docusaurus/types';
import A from '@theme-original/MDXComponents/A';
import type AType from '@theme/MDXComponents/A';
import React, { type ReactNode } from 'react';

export default function MDXA(props: Props): ReactNode {
// MDX Footnotes have ids such as <a id="user-content-fn-1-953011" ...>
const anchorTargetClassName = useAnchorTargetClassName(props.id);
type Props = WrapperProps<typeof AType>;

export default function AWrapper(props: Props): ReactNode {
// Customize rel attribute for *.defined.net links
let customRel = props.rel;

Check failure on line 10 in src/theme/MDXComponents/A/index.tsx

View workflow job for this annotation

GitHub Actions / Typecheck

Property 'rel' does not exist on type '{}'.
let customTarget = props.target;

Check failure on line 11 in src/theme/MDXComponents/A/index.tsx

View workflow job for this annotation

GitHub Actions / Typecheck

Property 'target' does not exist on type '{}'.
if (props.href && typeof props.href === 'string') {

Check failure on line 12 in src/theme/MDXComponents/A/index.tsx

View workflow job for this annotation

GitHub Actions / Typecheck

Property 'href' does not exist on type '{}'.

Check failure on line 12 in src/theme/MDXComponents/A/index.tsx

View workflow job for this annotation

GitHub Actions / Typecheck

Property 'href' does not exist on type '{}'.
try {
const url = new URL(props.href, window.location.href);

Check failure on line 14 in src/theme/MDXComponents/A/index.tsx

View workflow job for this annotation

GitHub Actions / Typecheck

Property 'href' does not exist on type '{}'.
// Check if it's an external link to *.defined.net
if (url.hostname.endsWith('.defined.net') || url.hostname === 'defined.net') {
// Override to only use 'noopener' (exclude 'noreferrer')
Expand All @@ -25,7 +23,5 @@
}
}

return (
<Link {...props} rel={customRel} target={customTarget} className={clsx(anchorTargetClassName, props.className)} />
);
return <A rel={customRel} target={customTarget} {...props} />;
}
Loading