Skip to content

Commit

Permalink
fix: twoslash rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Jan 15, 2024
1 parent 832a79a commit f7540e4
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/sour-comics-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vocs": patch
---

Fixed twoslash rendering.
29 changes: 29 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 3 additions & 13 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@radix-ui/react-navigation-menu": "^1.1.4",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-tabs": "^1.0.4",
"@typescript/twoslash": "3.2.4",
"@vanilla-extract/css": "^1.14.0",
"@vanilla-extract/dynamic": "^2.1.0",
"@vitejs/plugin-react": "4.2.0",
Expand Down Expand Up @@ -88,23 +89,12 @@
"license": "MIT",
"homepage": "https://vocs.dev",
"repository": "wevm/vocs",
"authors": [
"awkweb.eth",
"jxom.eth"
],
"authors": ["awkweb.eth", "jxom.eth"],
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/wevm"
}
],
"keywords": [
"react",
"static",
"docs",
"generator",
"vite",
"documentation",
"mdx"
]
"keywords": ["react", "static", "docs", "generator", "vite", "documentation", "mdx"]
}
2 changes: 2 additions & 0 deletions src/vite/plugins/mdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export const getRehypePlugins = ({ markdown, twoslash = {} }: RehypePluginsParam
transformerTwoSlash({
explicitTrigger: true,
renderer: twoslashRenderer(),
// TODO: switch back to `twoslash`
// @ts-expect-error
twoslasher,
twoslashOptions: {
...twoslash,
Expand Down
8 changes: 5 additions & 3 deletions src/vite/plugins/shikiji/twoslasher.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { createTwoSlasher } from 'twoslash'
// TODO: switch back to `twoslash`
// import { createTwoSlasher } from 'twoslash'
import { twoslasher as twoslasher_ } from '@typescript/twoslash'
import * as cache from '../../utils/cache.js'
import { hash } from '../../utils/hash.js'

const twoslasher_ = createTwoSlasher()
// const twoslasher = createTwoSlasher()

export function twoslasher(
...parameters: Parameters<typeof twoslasher_>
Expand All @@ -19,6 +21,7 @@ export function twoslasher(
const line = lines.length - 1
return {
code: parameters[0],
// @ts-expect-error
nodes: [
{
filename: '',
Expand All @@ -33,7 +36,6 @@ export function twoslasher(
id: '',
},
],
// @ts-expect-error
meta: {},
queries: [],
completions: [],
Expand Down

0 comments on commit f7540e4

Please sign in to comment.