import React from 'react';
import Link from '@docusaurus/Link';
// eslint-disable-next-line import/no-extraneous-dependencies
import { useDocsVersion } from '@docusaurus/theme-common/internal';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';

// const pkg = require('../../../packages/crawlee/package.json');
//
// const [v1, v2] = pkg.version.split('.');
// const stable = [v1, v2].join('.');

const ApiLink = ({ to, children }) => {
    return (
        <Link to={`/api/${to}`}>{children}</Link>
    );

    // const version = useDocsVersion();
    // const { siteConfig } = useDocusaurusContext();
    //
    // // if (siteConfig.presets[0][1].docs.disableVersioning || version.version === stable) {
    // if (siteConfig.presets[0][1].docs.disableVersioning) {
    //     return (
    //         <Link to={`/api/${to}`}>{children}</Link>
    //     );
    // }
    //
    // return (
    //     <Link to={`/api/${version.version === 'current' ? 'next' : version.version}/${to}`}>{children}</Link>
    // );
};

export default ApiLink;
