File tree Expand file tree Collapse file tree 2 files changed +27
-6
lines changed Expand file tree Collapse file tree 2 files changed +27
-6
lines changed Original file line number Diff line number Diff line change 99*/
1010import AppStore from 'docc-render/stores/AppStore' ;
1111
12+ const TopicReferenceTypes = new Set ( [
13+ 'section' ,
14+ 'topic' ,
15+ ] ) ;
16+
1217export default {
1318 // inject the `store`
1419 inject : {
@@ -32,14 +37,18 @@ export default {
3237 state : { references : originalRefs = { } } ,
3338 } ,
3439 } = this ;
35- // strip the `url` key from refs if their identifier comes from an
36- // archive that hasn't been included by DocC
40+ // strip the `url` key from "topic"/"section" refs if their identifier
41+ // comes from an archive that hasn't been included by DocC
3742 return Object . keys ( originalRefs ) . reduce ( ( newRefs , id ) => {
38- const { url, ...refWithoutUrl } = originalRefs [ id ] ;
39- return {
43+ const originalRef = originalRefs [ id ] ;
44+ const { url, ...refWithoutUrl } = originalRef ;
45+ return TopicReferenceTypes . has ( originalRef . type ) ? ( {
4046 ...newRefs ,
4147 [ id ] : isFromIncludedArchive ( id ) ? originalRefs [ id ] : refWithoutUrl ,
42- } ;
48+ } ) : ( {
49+ ...newRefs ,
50+ [ id ] : originalRef ,
51+ } ) ;
4352 } , { } ) ;
4453 } ,
4554 } ,
Original file line number Diff line number Diff line change @@ -34,28 +34,39 @@ const aa = {
3434 identifier : 'doc://A/documentation/A/a' ,
3535 url : '/documentation/A/a' ,
3636 title : 'A.A' ,
37+ type : 'topic' ,
3738} ;
3839const ab = {
3940 identifier : 'doc://A/documentation/A/b' ,
4041 url : '/documentation/A/b' ,
4142 title : 'A.B' ,
43+ type : 'topic' ,
4244} ;
4345const bb = {
4446 identifier : 'doc://B/documentation/B/b' ,
4547 url : '/documentation/B/b' ,
4648 title : 'B.B' ,
49+ type : 'topic' ,
4750} ;
4851const bbb = {
4952 identifier : 'doc://BB/documentation/BB/b' ,
50- url : '/documentation/BB/b' ,
53+ url : '/documentation/BB/b#b ' ,
5154 title : 'BB.B' ,
55+ type : 'section' ,
56+ } ;
57+ const c = {
58+ identifier : 'https://abc.dev' ,
59+ url : 'https://abc.dev' ,
60+ title : 'C' ,
61+ type : 'link' ,
5262} ;
5363
5464const references = {
5565 [ aa . identifier ] : aa ,
5666 [ ab . identifier ] : ab ,
5767 [ bb . identifier ] : bb ,
5868 [ bbb . identifier ] : bbb ,
69+ [ c . identifier ] : c ,
5970} ;
6071
6172const provide = {
@@ -117,5 +128,6 @@ describe('referencesProvider', () => {
117128 expect ( refs3 [ bb . identifier ] . url ) . toBe ( bb . url ) ; // bb still has `url`
118129 expect ( refs3 [ bbb . identifier ] . title ) . toBe ( bbb . title ) ;
119130 expect ( refs3 [ bbb . identifier ] . url ) . toBeFalsy ( ) ; // bbb `url` is gone now
131+ expect ( refs3 [ c . identifier ] . url ) . toBe ( c . url ) ; // external link untouched
120132 } ) ;
121133} ) ;
You can’t perform that action at this time.
0 commit comments