Skip to content

Commit c51fba9

Browse files
committed
sorter resultatene
1 parent fba0978 commit c51fba9

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

xp-archive/client/contentTree/NavigationBar.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ export const NavigationBar = () => {
8282
<li>Situasjonsside</li>
8383
<li>Temaartikkel</li>
8484
<li>Slik gjør du det</li>
85-
<li>Artikkel</li>
8685
<li>Aktuelt</li>
86+
<li>Artikkel</li>
8787
<li>Intern lenke</li>
8888
<li>Ekstern lenke</li>
8989
</ul>
9090
</HelpText>
9191
</Radio>
92-
<Radio value="everything">Alle innholdstyper</Radio>
92+
<Radio value="other">Andre innholdstyper</Radio>
9393
</RadioGroup>
9494
<Search
9595
label={'Søk'}

xp-archive/client/contentTree/search/SearchResult.tsx

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { BodyShort, Button, Detail, Heading, Loader } from '@navikt/ds-react';
2+
import { Button, Detail, Heading, Loader } from '@navikt/ds-react';
33
import { SearchResponse } from 'shared/types';
44
import { SearchResultItem } from './SearchResultItem/SearchResultItem';
55

@@ -14,6 +14,24 @@ type SearchResultProps = {
1414
export const SearchResult = ({ isLoading, searchResult, closeSearchResult }: SearchResultProps) => {
1515
const { hits, query, total, hasMore } = searchResult;
1616

17+
const orderedHits = [...hits].sort((a, b) => {
18+
const orderedTypes = [
19+
'no.nav.navno:content-page-with-sidemenus',
20+
'no.nav.navno:situation-page',
21+
'no.nav.navno:themed-article-page',
22+
'no.nav.navno:guide-page',
23+
'no.nav.navno:current-topic-page',
24+
'no.nav.navno:main-article',
25+
'no.nav.navno:internal-link',
26+
'no.nav.navno:external-link',
27+
];
28+
29+
const indexA = orderedTypes.indexOf(a.type);
30+
const indexB = orderedTypes.indexOf(b.type);
31+
32+
return indexA - indexB;
33+
});
34+
1735
return (
1836
<div>
1937
{isLoading ? (
@@ -32,7 +50,7 @@ export const SearchResult = ({ isLoading, searchResult, closeSearchResult }: Sea
3250
Lukk
3351
</Button>
3452
</div>
35-
{hits.map((hit) => (
53+
{orderedHits.map((hit) => (
3654
<SearchResultItem hit={hit} key={hit._id + hit.layerLocale} />
3755
))}
3856
{hasMore && (

0 commit comments

Comments
 (0)