diff --git a/website/docs/how-to-guides/intermediate-semantic-analysis.md b/website/docs/how-to-guides/intermediate-semantic-analysis.md index 26f31306..1bbe30d0 100644 --- a/website/docs/how-to-guides/intermediate-semantic-analysis.md +++ b/website/docs/how-to-guides/intermediate-semantic-analysis.md @@ -8,11 +8,9 @@ Query parameters are represented as the type `Record`, so using a codec that doesn't decode from a `string | string[] | undefined` will produce a type error. - - Consider this `httpRoute` that compiles successfully. -```typescript spec.ts +```typescript import * as t from 'io-ts'; import { httpRoute, httpRequest } from '@api-ts/io-ts-http'; @@ -30,9 +28,10 @@ const GetHello = httpRoute({ }); ``` ---- +If you add an expected `number` value to the `httpRoute`'s query parameters, you'll see +the following compilation error: -```typescript spec.ts focus=14:16 +```typescript import * as t from 'io-ts'; import { httpRoute, httpRequest } from '@api-ts/io-ts-http'; @@ -72,8 +71,6 @@ number. We need a codec that decodes a `string` into a `number` and converts the string-representation of a number into the `number` type. ---- - This is a fairly common requirement, so this codec already exists: [io-ts-types] offers the [NumberFromString] codec that decodes a `string` value into a `number`. Use `NumberFromString` to fix your compilation error. @@ -82,7 +79,7 @@ the [NumberFromString] codec that decodes a `string` value into a `number`. Use [numberfromstring]: https://gcanti.github.io/io-ts-types/modules/NumberFromString.ts.html -```typescript spec.ts focus=2,15:17 +```typescript import * as t from 'io-ts'; import { NumberFromString } from 'io-ts-types'; import { httpRoute, httpRequest } from '@api-ts/io-ts-http'; @@ -104,7 +101,5 @@ const GetHello = httpRoute({ }); ``` - - In general, the solution to decoding a query parameter into a non-string type is to use a codec that decodes and encodes from a `string` into your desired type. diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 1bbdcab7..f4b30f2a 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -6,7 +6,7 @@ const darkCodeTheme = require('prism-react-renderer/themes/dracula'); // Remove the shiki theme import that's causing the error // const theme = require('shiki/themes/nord.json'); -const { remarkCodeHike } = require('@code-hike/mdx'); +const { remarkCodeHike, recmaCodeHike } = require('codehike/mdx'); /** @type {import('@docusaurus/types').Config} */ const config = { @@ -39,6 +39,7 @@ const config = { docs: { // Update to use a default theme instead of the missing nord theme beforeDefaultRemarkPlugins: [[remarkCodeHike, { theme: 'github-dark' }]], + recmaPlugins: [[recmaCodeHike, { theme: 'github-dark' }]], sidebarPath: require.resolve('./sidebars.js'), // Remove this to remove the "edit this page" links. editUrl: 'https://github.com/BitGo/api-ts/tree/master/website/', @@ -49,10 +50,7 @@ const config = { editUrl: 'https://github.com/BitGo/api-ts/tree/master/website', }, theme: { - customCss: [ - require.resolve('@code-hike/mdx/styles.css'), - require.resolve('./src/css/custom.css'), - ], + customCss: [require.resolve('./src/css/custom.css')], }, }), ], diff --git a/website/package-lock.json b/website/package-lock.json index c5ff0a5e..f5cc616c 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -8,11 +8,11 @@ "name": "website", "version": "0.0.0", "dependencies": { - "@code-hike/mdx": "^0.9.0", "@docusaurus/core": "3.7.0", "@docusaurus/preset-classic": "3.7.0", "@mdx-js/react": "^3.0.0", "clsx": "^1.2.1", + "codehike": "^1.0.5", "docusaurus-theme-mdx-v2": "^0.1.2", "prism-react-renderer": "^1.3.5", "react": "^18.0.0", @@ -1958,32 +1958,6 @@ "node": ">=6.9.0" } }, - "node_modules/@code-hike/lighter": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@code-hike/lighter/-/lighter-0.7.0.tgz", - "integrity": "sha512-64O07rIORKQLB+5T/GKAmKcD9sC0N9yHFJXa0Hs+0Aee1G+I4bSXxTccuDFP6c/G/3h5Pk7yv7PoX9/SpzaeiQ==", - "license": "MIT", - "funding": { - "url": "https://github.com/code-hike/lighter?sponsor=1" - } - }, - "node_modules/@code-hike/mdx": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/@code-hike/mdx/-/mdx-0.9.0.tgz", - "integrity": "sha512-0wg68ZCjVWAkWT4gBUZJ8Mwktjen/XeWyqBQCrhA2IZSbZZnMYsEI6JJEFb/nZoNI3comB3JdxPLykZRq3qT2A==", - "license": "MIT", - "dependencies": { - "@code-hike/lighter": "0.7.0", - "node-fetch": "^2.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/code-hike" - }, - "peerDependencies": { - "react": "^16.8.3 || ^17 || ^18" - } - }, "node_modules/@colors/colors": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", @@ -5257,6 +5231,12 @@ "node": ">=8" } }, + "node_modules/ansi-sequence-parser": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ansi-sequence-parser/-/ansi-sequence-parser-1.1.1.tgz", + "integrity": "sha512-vJXt3yiaUL4UU546s3rPXlsry/RnM730G1+HkpKE012AN0sx1eOrxSu95oKDIonskeLTijMgqWZ3uDEe3NFvyg==", + "license": "MIT" + }, "node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -6037,6 +6017,35 @@ "node": ">=6" } }, + "node_modules/codehike": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/codehike/-/codehike-1.0.5.tgz", + "integrity": "sha512-y3lL/3nPcvT7GNuEKw687AIip1Mg864lA/knWcCGn7Yp2FBQovsPqPTCpf/aodzWZ12HjWGfli+oxaSeuSyFXg==", + "license": "MIT", + "dependencies": { + "@code-hike/lighter": "1.0.1", + "diff": "^5.1.0", + "estree-util-visit": "^2.0.0", + "mdast-util-mdx-jsx": "^3.0.0", + "unist-util-visit": "^5.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/code-hike" + } + }, + "node_modules/codehike/node_modules/@code-hike/lighter": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@code-hike/lighter/-/lighter-1.0.1.tgz", + "integrity": "sha512-mccvcsk5UTScRrE02oBz1/qzckyhD8YE3VQlQv++2bSVVZgNuCUX8MpokSCi5OmfRAAxbj6kmNiqq1Um8eXPrw==", + "license": "MIT", + "dependencies": { + "ansi-sequence-parser": "1.1.1" + }, + "funding": { + "url": "https://github.com/sponsors/code-hike" + } + }, "node_modules/collapse-white-space": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-2.1.0.tgz", @@ -15188,26 +15197,6 @@ "node": ">=18" } }, - "node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "license": "MIT", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, "node_modules/node-forge": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", @@ -19828,12 +19817,6 @@ "node": ">=6" } }, - "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "license": "MIT" - }, "node_modules/trim-lines": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz", @@ -20554,12 +20537,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "license": "BSD-2-Clause" - }, "node_modules/webpack": { "version": "5.98.0", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.98.0.tgz", @@ -20913,16 +20890,6 @@ "node": ">=0.8.0" } }, - "node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "license": "MIT", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/website/package.json b/website/package.json index 696c9fb2..8b97f5f2 100644 --- a/website/package.json +++ b/website/package.json @@ -14,11 +14,11 @@ "write-heading-ids": "docusaurus write-heading-ids" }, "dependencies": { - "@code-hike/mdx": "^0.9.0", "@docusaurus/core": "3.7.0", "@docusaurus/preset-classic": "3.7.0", "@mdx-js/react": "^3.0.0", "clsx": "^1.2.1", + "codehike": "^1.0.5", "docusaurus-theme-mdx-v2": "^0.1.2", "prism-react-renderer": "^1.3.5", "react": "^18.0.0",