From e44cda35e503f755859601a97753833c56c811d8 Mon Sep 17 00:00:00 2001 From: freshavocado7 Date: Mon, 6 May 2024 16:26:53 +0200 Subject: [PATCH] feat: Update page title based on current view --- frontend/src/components/Breadcrumbs.jsx | 6 ++++-- frontend/src/views/HomeView.jsx | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Breadcrumbs.jsx b/frontend/src/components/Breadcrumbs.jsx index 414d63e..dafe0f8 100644 --- a/frontend/src/components/Breadcrumbs.jsx +++ b/frontend/src/components/Breadcrumbs.jsx @@ -51,10 +51,12 @@ export const Breadcrumbs = () => { } setBreadcrumbLabels(labels); + const modelName = Object.values(labels)[0]; + const instanceName = Object.values(labels).pop(); + document.title = `${instanceName} - ${modelName} - Model Explorer`; }; - updateLabels(); - }, [location]); + }, [location, document.title]); const visible_pathnames = [ breadcrumbLabels['/'], diff --git a/frontend/src/views/HomeView.jsx b/frontend/src/views/HomeView.jsx index 8a1aa13..31a2977 100644 --- a/frontend/src/views/HomeView.jsx +++ b/frontend/src/views/HomeView.jsx @@ -21,6 +21,7 @@ export const HomeView = () => { const response = await fetch(API_BASE_URL + '/model-info'); const data = await response.json(); setModelInfo(data); + document.title = `${data.title} - Model Explorer`; } catch (err) { setError('Failed to fetch model info: ' + err.message); }