Skip to content

Render combined navigation for merged documentation archives #877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
3 changes: 2 additions & 1 deletion src/components/Navigator/NavigatorDataProvider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ export default {
currentLangTechnologies = navigationIndex[Language.swift.key.url] || [];
}
// find the current technology
return currentLangTechnologies.find(t => (
const currentTechnology = currentLangTechnologies.find(t => (
technologyPath.toLowerCase() === t.path.toLowerCase()
));
return currentTechnology ?? currentLangTechnologies[0];
},
},
methods: {
Expand Down
2 changes: 1 addition & 1 deletion src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default [
),
},
{
path: '/documentation/*',
path: '/documentation*',
name: documentationTopicName,
component: () => import(
/* webpackChunkName: "documentation-topic" */ 'theme/views/DocumentationTopic.vue'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/components/DocumentationLayout.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const navigatorReferences = { foo: {} };

jest.spyOn(dataUtils, 'fetchIndexPathsData').mockResolvedValue({
interfaceLanguages: {
[Language.swift.key.url]: [TechnologyWithChildren, { path: 'another/technology' }],
[Language.swift.key.url]: [TechnologyWithChildren],
},
references: navigatorReferences,
});
Expand Down
12 changes: 3 additions & 9 deletions tests/unit/components/Navigator/NavigatorDataProvider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,6 @@ const swiftIndexOne = {
path: technologyUrl,
children: [1, 2, 3],
};
const swiftIndexTwo = {
id: 'bar',
path: '/bar',
children: [1],
};
const objectiveCIndexOne = {
id: 'foo-objc',
path: technologyUrl,
Expand All @@ -138,7 +133,6 @@ const response = {
interfaceLanguages: {
[Language.swift.key.url]: [
swiftIndexOne,
swiftIndexTwo,
],
[Language.objectiveC.key.url]: [
objectiveCIndexOne,
Expand Down Expand Up @@ -296,7 +290,7 @@ describe('NavigatorDataProvider', () => {
});
});

it('returns undefined technology, if none matches', async () => {
it('returns the first technology, if none matches', async () => {
createWrapper({
propsData: {
technologyUrl: '/documentation/bar',
Expand All @@ -308,8 +302,8 @@ describe('NavigatorDataProvider', () => {
isFetchingAPIChanges: false,
errorFetching: false,
isFetching: false,
technology: undefined,
flatChildren: [],
technology: swiftIndexOne,
flatChildren,
references,
});
});
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/setup-utils/SwiftDocCRenderRouter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ describe('SwiftDocCRenderRouter', () => {

expect(resolve('/documentation/foo').name).toBe(route);
expect(resolve('/documentation/bar').name).toBe(route);
expect(resolve('/documentation/foobar').params.pathMatch).toBe('foobar');
expect(resolve('/documentation/foobar').params.pathMatch).toBe('/foobar');

expect(resolve('/documentation/tutorials').name).toBe(route);
expect(resolve('/documentation/tutorials').params.pathMatch).toBe('tutorials');
expect(resolve('/documentation/tutorials').params.pathMatch).toBe('/tutorials');
});

it('resolves paths to the "documentation-topic-locale" route', () => {
Expand All @@ -180,17 +180,17 @@ describe('SwiftDocCRenderRouter', () => {
expect(resolve('/en-US/documentation/foo').name).toBe(route);
expect(resolve('/en-US/documentation/foo').params).toEqual({
locale: 'en-US',
pathMatch: 'foo',
pathMatch: '/foo',
});
expect(resolve('/ja-JP/documentation/bar').name).toBe(route);
expect(resolve('/ja-JP/documentation/bar').params).toEqual({
locale: 'ja-JP',
pathMatch: 'bar',
pathMatch: '/bar',
});
expect(resolve('/zh-CN/documentation/baz').name).toBe(route);
expect(resolve('/zh-CN/documentation/baz/qux').params).toEqual({
locale: 'zh-CN',
pathMatch: 'baz/qux',
pathMatch: '/baz/qux',
});
});
});
Expand Down