@@ -6,18 +6,21 @@ export interface InlineReference {
66 type : 'LinkedPage' ,
77 pageId : string
88 title ?: string
9- params : { mode : 'doc' | 'edgeless' }
9+ params ? : { mode : 'doc' | 'edgeless' }
1010}
1111
1212export interface ConverterOptions {
13- convertInlineReferenceLink ?: ( reference : InlineReference ) => string
13+ convertInlineReferenceLink ?: ( reference : InlineReference ) => { title : string , link : string }
1414}
1515
1616const defaultConvertInlineReferenceLink = ( reference : InlineReference ) => {
17- return `[${ reference . title || '' } ](${ [ reference . type , reference . pageId , reference . params . mode ] . filter ( Boolean ) . join ( ":" ) } )` ;
17+ return {
18+ title : reference . title || '' ,
19+ link : [ reference . type , reference . pageId , reference . params ?. mode ] . filter ( Boolean ) . join ( ":" ) ,
20+ }
1821}
1922
20- export function getConverters ( opts : ConverterOptions ) {
23+ export function getConverters ( opts : ConverterOptions = { } ) {
2124 const { convertInlineReferenceLink = defaultConvertInlineReferenceLink } = opts ;
2225
2326 return {
@@ -44,7 +47,8 @@ export function getConverters(opts: ConverterOptions) {
4447 return [ "[" , "](" + url + ")" ] ;
4548 } ,
4649 reference : function ( reference : InlineReference ) {
47- return [ convertInlineReferenceLink ( reference ) , '' ] ;
50+ const { title, link } = convertInlineReferenceLink ( reference ) ;
51+ return [ "[" , `${ title } ](${ link } )` ] ;
4852 } ,
4953 strike : function ( ) {
5054 return [ "~~" , "~~" ] ;
0 commit comments