Skip to content

Commit

Permalink
fix: rehypePlugins type Err
Browse files Browse the repository at this point in the history
  • Loading branch information
hanihusam committed Nov 19, 2024
1 parent f9d0bb8 commit 244d5e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
19 changes: 6 additions & 13 deletions app/utils/complie-mdx.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import PQueue from 'p-queue'
import readingTime from 'reading-time'
import rehypeAutolinkHeadings from 'rehype-autolink-headings'
import rehypePrettyCode from 'rehype-pretty-code'
import rehypePrism from 'rehype-prism-plus'
import rehypeSlug from 'rehype-slug'
import gfm from 'remark-gfm'
import type * as U from 'unified'

Check warning on line 12 in app/utils/complie-mdx.server.ts

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

'U' is defined but never used. Allowed unused vars must match /^ignored/u
Expand Down Expand Up @@ -65,7 +64,6 @@ const cloudinaryUrlRegex =

function optimizeCloudinaryImages() {
return async function transformer(tree: H.Root) {
// @ts-expect-error ugh
visit(
tree,
'mdxJsxFlowElement',
Expand Down Expand Up @@ -150,12 +148,6 @@ function removePreContainerDivs() {
}
}

const rehypePlugins: U.PluggableList = [
optimizeCloudinaryImages,
trimCodeBlocks,
removePreContainerDivs,
]

async function compileMdx<FrontmatterType>(
slug: string,
githubFiles: Array<GitHubFile>,
Expand Down Expand Up @@ -185,7 +177,6 @@ async function compileMdx<FrontmatterType>(
options.rehypePlugins = [
...(options?.rehypePlugins ?? []),
rehypeSlug,
rehypePrism,
[
rehypeAutolinkHeadings,
{
Expand All @@ -194,14 +185,16 @@ async function compileMdx<FrontmatterType>(
},
},
],
() =>
rehypePrettyCode({
[
rehypePrettyCode,
{
theme: {
light: 'github-light',
dark: 'github-dark',
},
}),
...rehypePlugins,
},
],
...[optimizeCloudinaryImages, trimCodeBlocks, removePreContainerDivs],
]

return options
Expand Down
1 change: 0 additions & 1 deletion app/utils/mdx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ function getMdxComponent(code: string) {
...rest
}: Parameters<typeof Component>['0']) {
return (
// @ts-expect-error the types are wrong here
<Component components={{ ...mdxComponents, ...components }} {...rest} />
)
}
Expand Down

0 comments on commit 244d5e3

Please sign in to comment.