Skip to content

Commit 08f01e9

Browse files
fix(website): migrate from @codehike/mdx to codehike 1.0.5
This commit updates our documentation site to use the official `codehike` package (v1.0.5) instead of the deprecated `@codehike/mdx`. The CodeHike project has consolidated all functionality into the main `codehike` package, discontinuing support for the separate `@codehike/mdx` package. Changes include: - Updated package.json dependencies to use `codehike@^1.0.5` - Removed the deprecated `@codehike/mdx` dependency - Updated import statements in docusaurus.config.js to use the new module path: `const { remarkCodeHike, recmaCodeHike } = require('codehike/mdx')` - Replaced the incompatible shiki/nord.json theme with 'github-dark' - Updated MDX configuration to align with the new CodeHike API - Adjusted code block syntax in documentation files to work with the new version This migration ensures our documentation site continues to have proper syntax highlighting and code examples while staying current with the CodeHike ecosystem. The github-dark theme provides excellent readability and maintains visual consistency. chore: nix fix
1 parent bcda594 commit 08f01e9

File tree

4 files changed

+45
-85
lines changed

4 files changed

+45
-85
lines changed

website/docs/how-to-guides/intermediate-semantic-analysis.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ Query parameters are represented as the type
88
`Record<string, string | string[] | undefined>`, so using a codec that doesn't decode
99
from a `string | string[] | undefined` will produce a type error.
1010

11-
<CH.Spotlight>
12-
1311
Consider this `httpRoute` that compiles successfully.
1412

15-
```typescript spec.ts
13+
```typescript
1614
import * as t from 'io-ts';
1715
import { httpRoute, httpRequest } from '@api-ts/io-ts-http';
1816

@@ -30,9 +28,10 @@ const GetHello = httpRoute({
3028
});
3129
```
3230

33-
---
31+
If you add an expected `number` value to the `httpRoute`'s query parameters, you'll see
32+
the following compilation error:
3433

35-
```typescript spec.ts focus=14:16
34+
```typescript
3635
import * as t from 'io-ts';
3736
import { httpRoute, httpRequest } from '@api-ts/io-ts-http';
3837

@@ -72,8 +71,6 @@ number.
7271
We need a codec that decodes a `string` into a `number` and converts the
7372
string-representation of a number into the `number` type.
7473

75-
---
76-
7774
This is a fairly common requirement, so this codec already exists: [io-ts-types] offers
7875
the [NumberFromString] codec that decodes a `string` value into a `number`. Use
7976
`NumberFromString` to fix your compilation error.
@@ -82,7 +79,7 @@ the [NumberFromString] codec that decodes a `string` value into a `number`. Use
8279
[numberfromstring]:
8380
https://gcanti.github.io/io-ts-types/modules/NumberFromString.ts.html
8481

85-
```typescript spec.ts focus=2,15:17
82+
```typescript
8683
import * as t from 'io-ts';
8784
import { NumberFromString } from 'io-ts-types';
8885
import { httpRoute, httpRequest } from '@api-ts/io-ts-http';
@@ -104,7 +101,5 @@ const GetHello = httpRoute({
104101
});
105102
```
106103

107-
</CH.Spotlight>
108-
109104
In general, the solution to decoding a query parameter into a non-string type is to use
110105
a codec that decodes and encodes from a `string` into your desired type.

website/docusaurus.config.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const darkCodeTheme = require('prism-react-renderer/themes/dracula');
66

77
// Remove the shiki theme import that's causing the error
88
// const theme = require('shiki/themes/nord.json');
9-
const { remarkCodeHike } = require('@code-hike/mdx');
9+
const { remarkCodeHike, recmaCodeHike } = require('codehike/mdx');
1010

1111
/** @type {import('@docusaurus/types').Config} */
1212
const config = {
@@ -39,6 +39,7 @@ const config = {
3939
docs: {
4040
// Update to use a default theme instead of the missing nord theme
4141
beforeDefaultRemarkPlugins: [[remarkCodeHike, { theme: 'github-dark' }]],
42+
recmaPlugins: [[recmaCodeHike, { theme: 'github-dark' }]],
4243
sidebarPath: require.resolve('./sidebars.js'),
4344
// Remove this to remove the "edit this page" links.
4445
editUrl: 'https://github.com/BitGo/api-ts/tree/master/website/',
@@ -49,10 +50,7 @@ const config = {
4950
editUrl: 'https://github.com/BitGo/api-ts/tree/master/website',
5051
},
5152
theme: {
52-
customCss: [
53-
require.resolve('@code-hike/mdx/styles.css'),
54-
require.resolve('./src/css/custom.css'),
55-
],
53+
customCss: [require.resolve('./src/css/custom.css')],
5654
},
5755
}),
5856
],

website/package-lock.json

Lines changed: 36 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
"write-heading-ids": "docusaurus write-heading-ids"
1515
},
1616
"dependencies": {
17-
"@code-hike/mdx": "^0.9.0",
1817
"@docusaurus/core": "3.7.0",
1918
"@docusaurus/preset-classic": "3.7.0",
2019
"@mdx-js/react": "^3.0.0",
2120
"clsx": "^1.2.1",
21+
"codehike": "^1.0.5",
2222
"docusaurus-theme-mdx-v2": "^0.1.2",
2323
"prism-react-renderer": "^1.3.5",
2424
"react": "^18.0.0",

0 commit comments

Comments
 (0)