-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
Summary
Routes are constructed using string interpolation throughout the UI, making the application fragile to URL structure changes.
Full Description
Components like CourseVisitCard.svelte and MainNavigator.svelte manually build strings like /course/${id}. If the folder structure in src/routes changes (e.g., moving /course to /reader), the app will break in dozens of places.
How to Resolve
- Create a central
route-utils.tsfile. - Define functions for every major route.
- Replace hardcoded backticks with these function calls.
Code Fix Create src/lib/services/course/utils/routes.ts:
export const paths = {
course: (id: string) => `/course/${id}`,
topic: (courseId: string, topicId: string) => `/topic/${courseId}/${topicId}`,
lab: (courseId: string, labId: string) => `/lab/${courseId}/${labId}`,
live: (courseId: string) => `/live/${courseId}`
};
Then in CourseVisitCard.svelte :
<script>
import { paths } from "$lib/services/course/utils/routes";
</script>
<a href={paths.course(course.id)}>
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels