zapishis-client/apps/web/mdx-components.tsx
vchikalkin 8765c1d74d feat: implement public offer document and layout
- Added a new layout component for the public offer document.
- Created the public offer page in MDX format, detailing terms and conditions for service usage.
- Removed the old offer page in TSX format.
- Updated links for offer and support to a new shared component for better maintainability.
- Integrated Tailwind CSS typography plugin for improved text styling.
2025-10-14 15:31:53 +03:00

40 lines
1.4 KiB
TypeScript

import { type MDXComponents } from 'mdx/types';
import Link from 'next/link';
/**
* Этот объект определяет, какие React-компоненты
* будут использоваться для рендеринга MDX-тегов (<a>, <h1>, <p> и т.д.)
* и какие кастомные компоненты будут доступны прямо в MDX.
*/
const components: MDXComponents = {
// 🔗 Заменяем стандартные <a> на <Link> Next.js
a: ({ children, href = '', ...props }) => {
// внутренние ссылки → через <Link>
if (href.startsWith('/')) {
return (
<Link href={href} {...props}>
{children}
</Link>
);
}
// внешние ссылки → target="_blank"
return (
<a href={href} rel="noopener noreferrer" target="_blank" {...props}>
{children}
</a>
);
},
};
/**
* Эта функция вызывается автоматически при рендере MDX.
* Через неё Next.js App Router объединяет глобальные и локальные MDX-компоненты.
*/
export function useMDXComponents(componentsArgument: MDXComponents): MDXComponents {
return {
...components,
...componentsArgument, // позволяет переопределять внутри MDX
};
}