vbv/client/src/utils/route.ts

50 lines
1.1 KiB
TypeScript

import { useRoute } from "vue-router";
export function useRouteLookups() {
const route = useRoute();
function inCourse() {
return route.path.startsWith("/course/");
}
function inCockpit() {
const regex = new RegExp("/course/[^/]+/cockpit($|/)");
return regex.test(route.path);
}
function inLearningPath() {
const regex = new RegExp("/course/[^/]+/learn($|/)");
return regex.test(route.path);
}
function inCompetenceProfile() {
const regex = new RegExp("/course/[^/]+/competence($|/)");
return regex.test(route.path);
}
function inLearningMentor() {
const regex = new RegExp("/course/[^/]+/learning-mentor($|/)");
return regex.test(route.path);
}
function inMediaLibrary() {
const regex = new RegExp("/course/[^/]+/media($|/)");
return regex.test(route.path);
}
function inAppointments() {
const regex = new RegExp("/(?:[^/]+/)?appointments($|/)");
return regex.test(route.path);
}
return {
inMediaLibrary,
inCockpit,
inLearningPath,
inCompetenceProfile,
inLearningMentor,
inCourse,
inAppointments: inAppointments,
};
}