Skip to content

Commit 47fb4df

Browse files
hqhhuangmportiz08
andauthored
Render combined navigation for merged documentation archives rdar://124537023 (#883)
Render combined navigation for merged documentation archives rdar://124537023 (#883) Co-authored-by: Marcus Ortiz <[email protected]>
1 parent fd6da03 commit 47fb4df

File tree

5 files changed

+12
-17
lines changed

5 files changed

+12
-17
lines changed

src/components/Navigator/NavigatorDataProvider.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ export default {
8080
currentLangTechnologies = navigationIndex[Language.swift.key.url] || [];
8181
}
8282
// find the current technology
83-
return currentLangTechnologies.find(t => (
83+
const currentTechnology = currentLangTechnologies.find(t => (
8484
technologyPath.toLowerCase() === t.path.toLowerCase()
8585
));
86+
return currentTechnology ?? currentLangTechnologies[0];
8687
},
8788
},
8889
methods: {

src/routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default [
3232
),
3333
},
3434
{
35-
path: '/documentation/*',
35+
path: '/documentation*',
3636
name: documentationTopicName,
3737
component: () => import(
3838
/* webpackChunkName: "documentation-topic" */ 'theme/views/DocumentationTopic.vue'

tests/unit/components/DocumentationLayout.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const navigatorReferences = { foo: {} };
4141

4242
jest.spyOn(dataUtils, 'fetchIndexPathsData').mockResolvedValue({
4343
interfaceLanguages: {
44-
[Language.swift.key.url]: [TechnologyWithChildren, { path: 'another/technology' }],
44+
[Language.swift.key.url]: [TechnologyWithChildren],
4545
},
4646
references: navigatorReferences,
4747
});

tests/unit/components/Navigator/NavigatorDataProvider.spec.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,6 @@ const swiftIndexOne = {
113113
path: technologyUrl,
114114
children: [1, 2, 3],
115115
};
116-
const swiftIndexTwo = {
117-
id: 'bar',
118-
path: '/bar',
119-
children: [1],
120-
};
121116
const objectiveCIndexOne = {
122117
id: 'foo-objc',
123118
path: technologyUrl,
@@ -138,7 +133,6 @@ const response = {
138133
interfaceLanguages: {
139134
[Language.swift.key.url]: [
140135
swiftIndexOne,
141-
swiftIndexTwo,
142136
],
143137
[Language.objectiveC.key.url]: [
144138
objectiveCIndexOne,
@@ -296,7 +290,7 @@ describe('NavigatorDataProvider', () => {
296290
});
297291
});
298292

299-
it('returns undefined technology, if none matches', async () => {
293+
it('returns the first technology, if none matches', async () => {
300294
createWrapper({
301295
propsData: {
302296
technologyUrl: '/documentation/bar',
@@ -308,8 +302,8 @@ describe('NavigatorDataProvider', () => {
308302
isFetchingAPIChanges: false,
309303
errorFetching: false,
310304
isFetching: false,
311-
technology: undefined,
312-
flatChildren: [],
305+
technology: swiftIndexOne,
306+
flatChildren,
313307
references,
314308
});
315309
});

tests/unit/setup-utils/SwiftDocCRenderRouter.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ describe('SwiftDocCRenderRouter', () => {
168168

169169
expect(resolve('/documentation/foo').name).toBe(route);
170170
expect(resolve('/documentation/bar').name).toBe(route);
171-
expect(resolve('/documentation/foobar').params.pathMatch).toBe('foobar');
171+
expect(resolve('/documentation/foobar').params.pathMatch).toBe('/foobar');
172172

173173
expect(resolve('/documentation/tutorials').name).toBe(route);
174-
expect(resolve('/documentation/tutorials').params.pathMatch).toBe('tutorials');
174+
expect(resolve('/documentation/tutorials').params.pathMatch).toBe('/tutorials');
175175
});
176176

177177
it('resolves paths to the "documentation-topic-locale" route', () => {
@@ -180,17 +180,17 @@ describe('SwiftDocCRenderRouter', () => {
180180
expect(resolve('/en-US/documentation/foo').name).toBe(route);
181181
expect(resolve('/en-US/documentation/foo').params).toEqual({
182182
locale: 'en-US',
183-
pathMatch: 'foo',
183+
pathMatch: '/foo',
184184
});
185185
expect(resolve('/ja-JP/documentation/bar').name).toBe(route);
186186
expect(resolve('/ja-JP/documentation/bar').params).toEqual({
187187
locale: 'ja-JP',
188-
pathMatch: 'bar',
188+
pathMatch: '/bar',
189189
});
190190
expect(resolve('/zh-CN/documentation/baz').name).toBe(route);
191191
expect(resolve('/zh-CN/documentation/baz/qux').params).toEqual({
192192
locale: 'zh-CN',
193-
pathMatch: 'baz/qux',
193+
pathMatch: '/baz/qux',
194194
});
195195
});
196196
});

0 commit comments

Comments
 (0)