Hexta AIHexta AI

Package Install

Generate code blocks for installing packages

Deprecated

For Hexta MDX, it is now enabled by default.

You can use the remarkNpm plugin instead.

Usage

npm install hexta-docgen

Add the remark plugin.

source.config.ts
import { remarkInstall } from 'hexta-docgen';
import { defineConfig } from 'hexta-mdx/config';

export default defineConfig({
  mdxOptions: {
    remarkPlugins: [remarkInstall],
  },
});

Define the required components.

components/mdx.tsx (Hexta Docs)
import { Tab, Tabs } from 'hexta-ui/components/tabs';
import defaultComponents from 'hexta-ui/mdx';
import type { MDXComponents } from 'mdx/types';

export function getMDXComponents(components?: MDXComponents) {
  return {
    ...defaultComponents,
    Tab,
    Tabs,
    ...components,
  } satisfies MDXComponents;
}
Component
TabsAccepts an array of item (items)
TabAccepts the name of item (value)

Create code blocks with package-install as language.

```package-install
my-package
```

```package-install
npm i my-package -D
```

Output

The following structure should be generated by the plugin.

<Tabs items={['npm', 'pnpm', 'yarn', 'bun']}>
  <Tab value="npm">...</Tab>
  <Tab value="pnpm">...</Tab>
  <Tab value="yarn">...</Tab>
  <Tab value="bun">...</Tab>
</Tabs>
npm install my-package

Options

Persistent

When using with Hexta Docs, you can enable persistence with the persist option.

source.config.ts
import { remarkInstall } from 'hexta-docgen';
import { defineConfig } from 'hexta-mdx/config';

const remarkInstallOptions = {
  persist: {
    id: 'some-id',
  },
};

export default defineConfig({
  mdxOptions: {
    remarkPlugins: [[remarkInstall, remarkInstallOptions]],
  },
});

This will instead generate:

<Tabs groupId="some-id" persist items={[...]}>
  ...
</Tabs>

How is this guide?