Skip to content

Commit

Permalink
Fix RemarkRehype types (#9147)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored Nov 22, 2023
1 parent 0fe3a7e commit addb57c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/khaki-fans-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/markdown-remark': patch
---

Fixes `RemarkRehype` type's `handler` and `handlers` properties
1 change: 0 additions & 1 deletion packages/markdown/remark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"github-slugger": "^2.0.0",
"import-meta-resolve": "^4.0.0",
"mdast-util-definitions": "^6.0.0",
"mdast-util-to-hast": "13.0.2",
"rehype-raw": "^7.0.0",
"rehype-stringify": "^10.0.0",
"remark-gfm": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/markdown/remark/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export async function createMarkdownProcessor(
}

// Remark -> Rehype
parser.use(remarkRehype as any, {
parser.use(remarkRehype, {
allowDangerousHtml: true,
passThrough: [],
...remarkRehypeOptions,
Expand Down
9 changes: 1 addition & 8 deletions packages/markdown/remark/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type * as hast from 'hast';
import type * as mdast from 'mdast';
import type { Options as RemarkRehypeOptions } from 'remark-rehype';
import type { State } from 'mdast-util-to-hast';
import type {
BuiltinTheme,
LanguageRegistration,
Expand All @@ -11,9 +10,6 @@ import type {
import type * as unified from 'unified';
import type { VFile } from 'vfile';

type Handler = State['one'];
type Handlers = State['all'];

export type { Node } from 'unist';

export type MarkdownAstroData = {
Expand All @@ -34,10 +30,7 @@ export type RehypePlugin<PluginParameters extends any[] = any[]> = unified.Plugi

export type RehypePlugins = (string | [string, any] | RehypePlugin | [RehypePlugin, any])[];

export type RemarkRehype = Omit<RemarkRehypeOptions, 'handlers' | 'unknownHandler'> & {
handlers?: Handlers;
handler?: Handler;
};
export type RemarkRehype = RemarkRehypeOptions;

export interface ShikiConfig {
langs?: LanguageRegistration[];
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

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

0 comments on commit addb57c

Please sign in to comment.