@@ -606,9 +606,87 @@ test("internal link inside codeblock ignored", async () => {
606
606
) ;
607
607
} ) ;
608
608
609
+ test ( "multiple internal links in a paragraph" , async ( ) => {
610
+ const targetPageAId = "123" ;
611
+ const targetPageA : NotionPage = makeSamplePageObject ( {
612
+ slug : undefined ,
613
+ name : "Hello World A" ,
614
+ id : targetPageAId ,
615
+ } ) ;
616
+ const targetPageBId = "456" ;
617
+ const targetPageB : NotionPage = makeSamplePageObject ( {
618
+ slug : undefined ,
619
+ name : "Hello World B" ,
620
+ id : targetPageBId ,
621
+ } ) ;
622
+
623
+ const results = await getMarkdown (
624
+ {
625
+ type : "paragraph" ,
626
+ paragraph : {
627
+ rich_text : [
628
+ {
629
+ type : "text" ,
630
+ text : {
631
+ content : "A" ,
632
+ link : { url : `/${ targetPageAId } ` } ,
633
+ } ,
634
+ annotations : {
635
+ bold : false ,
636
+ italic : false ,
637
+ strikethrough : false ,
638
+ underline : false ,
639
+ code : false ,
640
+ color : "default" ,
641
+ } ,
642
+ plain_text : "A" ,
643
+ href : `/${ targetPageAId } ` ,
644
+ } ,
645
+ {
646
+ type : "text" ,
647
+ text : { content : " " , link : null } ,
648
+ annotations : {
649
+ bold : false ,
650
+ italic : false ,
651
+ strikethrough : false ,
652
+ underline : false ,
653
+ code : false ,
654
+ color : "default" ,
655
+ } ,
656
+ plain_text : " " ,
657
+ href : null ,
658
+ } ,
659
+ {
660
+ type : "text" ,
661
+ text : {
662
+ content : "B" ,
663
+ link : { url : `/${ targetPageBId } ` } ,
664
+ } ,
665
+ annotations : {
666
+ bold : false ,
667
+ italic : false ,
668
+ strikethrough : false ,
669
+ underline : false ,
670
+ code : false ,
671
+ color : "default" ,
672
+ } ,
673
+ plain_text : "B" ,
674
+ href : `/${ targetPageBId } ` ,
675
+ } ,
676
+ ] ,
677
+ color : "default" ,
678
+ } ,
679
+ } ,
680
+ targetPageA ,
681
+ targetPageB
682
+ ) ;
683
+ expect ( results . trim ( ) ) . toBe ( `[A](/${ targetPageAId } ) [B](/${ targetPageBId } )` ) ;
684
+ } ) ;
685
+
609
686
async function getMarkdown (
610
687
block : Record < string , unknown > ,
611
- targetPage ?: NotionPage
688
+ targetPage ?: NotionPage ,
689
+ targetPage2 ?: NotionPage
612
690
) {
613
691
const config = {
614
692
plugins : [
@@ -617,5 +695,5 @@ async function getMarkdown(
617
695
standardExternalLinkConversion ,
618
696
] ,
619
697
} ;
620
- return await oneBlockToMarkdown ( config , block , targetPage ) ;
698
+ return await oneBlockToMarkdown ( config , block , targetPage , targetPage2 ) ;
621
699
}
0 commit comments