Skip to content

Commit 30ba12b

Browse files
authored
Merge pull request #56 from AdamVacha/prod-update2
fixed modules ordering
2 parents f26b35f + 739ec9b commit 30ba12b

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/routes/lessons/subject/[subject]/module/[module]/+layout.server.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ export const load: LayoutServerLoad = async ({ params, parent, locals }) => {
88
const { module: moduleId, lesson: lessonId } = params;
99
const { subject } = await parent();
1010

11-
const allModules = subject.modules || [];
12-
11+
const allModules = (subject.modules || []).sort((a, b) => {
12+
// Order modules
13+
if (a.orderInSubject && b.orderInSubject) {
14+
return a.orderInSubject - b.orderInSubject;
15+
}
16+
// Fallback to ID
17+
return a.id - b.id;
18+
});
1319
const module = allModules.find((m) => m.id === +moduleId);
1420
if (!module) {
1521
return error(404, 'Module not found');

0 commit comments

Comments
 (0)