build(aio): ensure that tutorial index arrives in the tutorial search area
Fixes #16457
This commit is contained in:
parent
5bc435eba3
commit
8931e71c5c
|
@ -69,6 +69,19 @@ describe('SearchResultsComponent', () => {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should special case results that are top level folders', () => {
|
||||||
|
searchResults.next({ query: '', results: [
|
||||||
|
{ path: 'tutorial', title: 'Tutorial index', type: '', keywords: '', titleWords: '' },
|
||||||
|
{ path: 'tutorial/toh-pt1', title: 'Tutorial - part 1', type: '', keywords: '', titleWords: '' },
|
||||||
|
]});
|
||||||
|
expect(currentAreas).toEqual([
|
||||||
|
{ name: 'tutorial', pages: [
|
||||||
|
{ path: 'tutorial/toh-pt1', title: 'Tutorial - part 1', type: '', keywords: '', titleWords: '' },
|
||||||
|
{ path: 'tutorial', title: 'Tutorial index', type: '', keywords: '', titleWords: '' },
|
||||||
|
], priorityPages: [] }
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
it('should sort by title within sorted area', () => {
|
it('should sort by title within sorted area', () => {
|
||||||
const results = getTestResults(5);
|
const results = getTestResults(5);
|
||||||
searchResults.next({ query: '', results: results });
|
searchResults.next({ query: '', results: results });
|
||||||
|
|
|
@ -20,6 +20,7 @@ export interface SearchArea {
|
||||||
export class SearchResultsComponent implements OnInit {
|
export class SearchResultsComponent implements OnInit {
|
||||||
|
|
||||||
readonly defaultArea = 'other';
|
readonly defaultArea = 'other';
|
||||||
|
readonly topLevelFolders = ['guide', 'tutorial'];
|
||||||
|
|
||||||
notFound = false;
|
notFound = false;
|
||||||
|
|
||||||
|
@ -76,6 +77,9 @@ export class SearchResultsComponent implements OnInit {
|
||||||
|
|
||||||
// Split the search result path and use the top level folder, if there is one, as the area name.
|
// Split the search result path and use the top level folder, if there is one, as the area name.
|
||||||
private computeAreaName(result: SearchResult) {
|
private computeAreaName(result: SearchResult) {
|
||||||
|
if (this.topLevelFolders.indexOf(result.path) !== -1) {
|
||||||
|
return result.path;
|
||||||
|
}
|
||||||
const [areaName, rest] = result.path.split('/', 2);
|
const [areaName, rest] = result.path.split('/', 2);
|
||||||
return rest && areaName;
|
return rest && areaName;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue