Skip to content

Commit 320a76a

Browse files
committed
Sorterer kategorier etter navn
1 parent 4217350 commit 320a76a

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

server/src/cms/CmsArchiveCategoriesService.ts

+11-8
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@ export class CmsArchiveCategoriesService {
4040
);
4141
}
4242

43-
async getCategoryWithXml(categoryKey: string): Promise<CmsCategoryDocument | null> {
44-
return this.client.getDocument<CmsCategoryDocument>({
45-
index: this.index,
46-
id: categoryKey,
47-
});
48-
}
49-
5043
getRootCategories(): CmsCategoryListItem[] {
5144
return this.rootCategories;
5245
}
@@ -55,6 +48,13 @@ export class CmsArchiveCategoriesService {
5548
return this.categoriesMap.get(categoryKey);
5649
}
5750

51+
async getCategoryFull(categoryKey: string): Promise<CmsCategoryDocument | null> {
52+
return this.client.getDocument<CmsCategoryDocument>({
53+
index: this.index,
54+
id: categoryKey,
55+
});
56+
}
57+
5858
getCategories(categoryKeys: string[]): CmsCategoryListItem[] {
5959
return categoryKeys.reduce<CmsCategoryListItem[]>((acc, key) => {
6060
const category = this.categoriesMap.get(key);
@@ -81,7 +81,10 @@ export class CmsArchiveCategoriesService {
8181
if (category.superKey) {
8282
category.path = this.resolveCategoryPath(category.superKey);
8383
}
84+
category.categories.sort((a, b) => a.name.localeCompare(b.name));
8485
});
86+
87+
this.rootCategories.sort((a, b) => a.title.localeCompare(b.title));
8588
}
8689

8790
resolveCategoryPath(categoryKey: string, path: CmsCategoryPath = []): CmsCategoryPath {
@@ -93,7 +96,7 @@ export class CmsArchiveCategoriesService {
9396

9497
const { key, superKey, title } = category;
9598

96-
path.push({
99+
path.unshift({
97100
key,
98101
name: title,
99102
});

0 commit comments

Comments
 (0)