Skip to content

Commit 64c61ea

Browse files
committed
externalize markdown nodes to types
Move Markdown node definitions to types, as we will be reusing them in another file in the next commit.
1 parent 235034c commit 64c61ea

File tree

2 files changed

+63
-59
lines changed

2 files changed

+63
-59
lines changed

src/updateChangelog.ts

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -3,65 +3,7 @@ import markdown from "remark-parse";
33
import stringify from "remark-stringify";
44
import { VFile } from "vfile";
55
import { Node, Position } from "unist";
6-
7-
type MarkdownRootNode = {
8-
type: "root";
9-
children: MarkdownNode[];
10-
};
11-
12-
interface HeadingNode {
13-
type: "heading";
14-
depth: number;
15-
children: MarkdownNode[];
16-
position: Position;
17-
}
18-
19-
interface DefinitionNode {
20-
type: "definition";
21-
identifier: string;
22-
label: string;
23-
url: string;
24-
position?: Position;
25-
}
26-
27-
interface ListNode {
28-
type: "list";
29-
ordered: boolean;
30-
start: any;
31-
spread: boolean;
32-
url: string;
33-
children: object[];
34-
position: Position;
35-
}
36-
37-
interface ParagraphNode {
38-
type: "paragraph";
39-
children: object[];
40-
position: Position;
41-
}
42-
43-
interface LinkReferenceNode {
44-
type: "linkReference";
45-
identifier: string;
46-
label: string;
47-
referenceType: string;
48-
children: TextNode[];
49-
position?: Position;
50-
}
51-
52-
interface TextNode {
53-
type: "text";
54-
value: string;
55-
position?: Position;
56-
}
57-
58-
type MarkdownNode =
59-
| HeadingNode
60-
| DefinitionNode
61-
| ListNode
62-
| ParagraphNode
63-
| LinkReferenceNode
64-
| TextNode;
6+
import { MarkdownRootNode, HeadingNode, DefinitionNode, LinkReferenceNode, TextNode } from "markdown-nodes";
657

668
interface Options {
679
tag: string;

types/markdown-nodes/index.d.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
declare module "markdown-nodes" {
2+
import { Position } from "unist";
3+
4+
type MarkdownRootNode = {
5+
type: "root";
6+
children: MarkdownNode[];
7+
};
8+
9+
interface HeadingNode {
10+
type: "heading";
11+
depth: number;
12+
children: MarkdownNode[];
13+
position: Position;
14+
}
15+
16+
interface DefinitionNode {
17+
type: "definition";
18+
identifier: string;
19+
label: string;
20+
url: string;
21+
position?: Position;
22+
}
23+
24+
interface ListNode {
25+
type: "list";
26+
ordered: boolean;
27+
start: any;
28+
spread: boolean;
29+
url: string;
30+
children: object[];
31+
position: Position;
32+
}
33+
34+
interface ParagraphNode {
35+
type: "paragraph";
36+
children: object[];
37+
position: Position;
38+
}
39+
40+
interface LinkReferenceNode {
41+
type: "linkReference";
42+
identifier: string;
43+
label: string;
44+
referenceType: string;
45+
children: TextNode[];
46+
position?: Position;
47+
}
48+
49+
interface TextNode {
50+
type: "text";
51+
value: string;
52+
position?: Position;
53+
}
54+
55+
type MarkdownNode =
56+
| HeadingNode
57+
| DefinitionNode
58+
| ListNode
59+
| ParagraphNode
60+
| LinkReferenceNode
61+
| TextNode;
62+
}

0 commit comments

Comments
 (0)