@@ -14,12 +14,6 @@ import remarkRemoveComments from '../plugins/remark-remove-comments'
14
14
15
15
import type { PluggableList } from 'unified'
16
16
17
- interface MarkdownBody {
18
- plain : string
19
- excerpt : string
20
- html : string
21
- }
22
-
23
17
interface MarkdownOptions {
24
18
gfm ?: boolean
25
19
removeComments ?: boolean
@@ -30,7 +24,7 @@ interface MarkdownOptions {
30
24
}
31
25
32
26
export const markdown = ( { gfm = true , removeComments = true , flattenImage = true , flattenListItem = true , remarkPlugins, rehypePlugins } : MarkdownOptions = { } ) =>
33
- z . string ( ) . transform ( async ( value , ctx ) : Promise < MarkdownBody > => {
27
+ z . string ( ) . transform ( async ( value , ctx ) => {
34
28
const file = unified ( ) . use ( remarkParse ) // parse markdown content to a syntax tree
35
29
if ( gfm ) file . use ( remarkGfm ) // support gfm (autolink literals, footnotes, strikethrough, tables, tasklists).
36
30
if ( removeComments ) file . use ( remarkRemoveComments ) // remove html comments
@@ -45,21 +39,9 @@ export const markdown = ({ gfm = true, removeComments = true, flattenImage = tru
45
39
file . use ( rehypeStringify ) // serialize html syntax tree
46
40
try {
47
41
const html = await file . process ( { value, path : ctx . path [ 0 ] as string } )
48
- // const replaces = file.data.replaces as Map<string, string>
49
- // // replace links
50
- // if (replaces != null) {
51
- // for (const [url, publicUrl] of replaces.entries()) {
52
- // value = value.replaceAll(url, publicUrl)
53
- // }
54
- // }
55
- return {
56
- // raw: value,
57
- excerpt : html . data . excerpt as string ,
58
- plain : html . data . plain as string ,
59
- html : html . toString ( )
60
- }
42
+ return html . toString ( )
61
43
} catch ( err : any ) {
62
44
ctx . addIssue ( { code : 'custom' , message : err . message } )
63
- return { } as MarkdownBody
45
+ return value
64
46
}
65
47
} )
0 commit comments