project setup
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { usePathname } from "expo-router";
|
||||
import { useEffect } from "react";
|
||||
import { Platform } from "react-native";
|
||||
|
||||
export const useDocumentTitle = () => {
|
||||
const pathname = usePathname();
|
||||
|
||||
const getSectionFromPath = (path: string): string => {
|
||||
if (path.includes("/dashboard") || path === "/(tabs)" || path === "/") {
|
||||
return "Dashboard";
|
||||
} else if (path.includes("/accounts")) {
|
||||
return "Accounts";
|
||||
} else if (path.includes("/logs")) {
|
||||
return "Logs";
|
||||
} else if (path.includes("/reports")) {
|
||||
return "Reports";
|
||||
} else if (path.includes("/data-protection")) {
|
||||
return "Data Protection";
|
||||
} else if (path.includes("/settings")) {
|
||||
return "Settings";
|
||||
} else {
|
||||
return "Project Athena";
|
||||
}
|
||||
};
|
||||
|
||||
const currentSection = getSectionFromPath(pathname);
|
||||
|
||||
useEffect(() => {
|
||||
if (Platform.OS === "web") {
|
||||
document.title = `${currentSection} | Project Athena`;
|
||||
}
|
||||
}, [currentSection, pathname]);
|
||||
|
||||
return currentSection;
|
||||
};
|
||||
Reference in New Issue
Block a user