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 9
9
*/
10
10
import AppStore from 'docc-render/stores/AppStore' ;
11
11
12
+ const TopicReferenceTypes = new Set ( [
13
+ 'section' ,
14
+ 'topic' ,
15
+ ] ) ;
16
+
12
17
export default {
13
18
// inject the `store`
14
19
inject : {
@@ -32,14 +37,18 @@ export default {
32
37
state : { references : originalRefs = { } } ,
33
38
} ,
34
39
} = 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
37
42
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 ) ? ( {
40
46
...newRefs ,
41
47
[ id ] : isFromIncludedArchive ( id ) ? originalRefs [ id ] : refWithoutUrl ,
42
- } ;
48
+ } ) : ( {
49
+ ...newRefs ,
50
+ [ id ] : originalRef ,
51
+ } ) ;
43
52
} , { } ) ;
44
53
} ,
45
54
} ,
Original file line number Diff line number Diff line change @@ -34,28 +34,39 @@ const aa = {
34
34
identifier : 'doc://A/documentation/A/a' ,
35
35
url : '/documentation/A/a' ,
36
36
title : 'A.A' ,
37
+ type : 'topic' ,
37
38
} ;
38
39
const ab = {
39
40
identifier : 'doc://A/documentation/A/b' ,
40
41
url : '/documentation/A/b' ,
41
42
title : 'A.B' ,
43
+ type : 'topic' ,
42
44
} ;
43
45
const bb = {
44
46
identifier : 'doc://B/documentation/B/b' ,
45
47
url : '/documentation/B/b' ,
46
48
title : 'B.B' ,
49
+ type : 'topic' ,
47
50
} ;
48
51
const bbb = {
49
52
identifier : 'doc://BB/documentation/BB/b' ,
50
- url : '/documentation/BB/b' ,
53
+ url : '/documentation/BB/b#b ' ,
51
54
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' ,
52
62
} ;
53
63
54
64
const references = {
55
65
[ aa . identifier ] : aa ,
56
66
[ ab . identifier ] : ab ,
57
67
[ bb . identifier ] : bb ,
58
68
[ bbb . identifier ] : bbb ,
69
+ [ c . identifier ] : c ,
59
70
} ;
60
71
61
72
const provide = {
@@ -117,5 +128,6 @@ describe('referencesProvider', () => {
117
128
expect ( refs3 [ bb . identifier ] . url ) . toBe ( bb . url ) ; // bb still has `url`
118
129
expect ( refs3 [ bbb . identifier ] . title ) . toBe ( bbb . title ) ;
119
130
expect ( refs3 [ bbb . identifier ] . url ) . toBeFalsy ( ) ; // bbb `url` is gone now
131
+ expect ( refs3 [ c . identifier ] . url ) . toBe ( c . url ) ; // external link untouched
120
132
} ) ;
121
133
} ) ;
You can’t perform that action at this time.
0 commit comments