UNPKG

@alauda/doom

Version:

Doctor Doom making docs.

36 lines (35 loc) 1.27 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { withBase } from '@rspress/core/runtime'; import { getCustomMDXComponent } from '@rspress/core/theme-original'; import { isExternalUrl, parseUrl } from '@rspress/shared'; import { clsx } from 'clsx'; const X_ = getCustomMDXComponent(); const DOWNLOAD_EXTENSIONS = [ '.ipynb', '.zip', '.tgz', '.tar.gz', '.sh', '.py', '.sql', ]; export const X = { ...X_, a: (props) => { const { className, href, // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment download, // type-coverage:ignore-line ...rest } = props; if (href) { const { url } = parseUrl(href); const pathname = url.split('/').at(-1).toLowerCase(); if (download !== false && // type-coverage:ignore-line DOWNLOAD_EXTENSIONS.some((ext) => pathname.endsWith(ext))) { return (_jsx("a", { className: clsx('rp-link', className), href: isExternalUrl(href) ? href : withBase(href), // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment download: download ?? true, ...rest })); } } return _jsx(X_.a, { ...props }); }, };