Skip to content

A self-hosted media server and file management system

Auto page title

aminnausin381664d0ba07
diff --git a/resources/js/router/index.js b/resources/js/router/index.js
index 470422cb..7dc9fb1f 100644
--- a/resources/js/router/index.js
+++ b/resources/js/router/index.js
@@ -8,6 +8,7 @@ import { createRouter, createWebHistory} from "vue-router";
import { useAuthStore } from "../stores/AuthStore";
import { storeToRefs } from "pinia";
import { logout } from "../service/auth";
+import { toTitleCase } from '../service/util';
const router = createRouter({
history: createWebHistory(),
@@ -71,6 +72,8 @@ const router = createRouter({
})
router.beforeEach((to, from, next) => {
+ document.title = to.meta?.title ?? toTitleCase(to.name);
+
if(!to.meta?.protected){
next();
return;
diff --git a/resources/js/service/util.js b/resources/js/service/util.js
new file mode 100644
index 00000000..0b6f108f
--- /dev/null
+++ b/resources/js/service/util.js
@@ -0,0 +1,5 @@
+export function toTitleCase(str) {
+ return str.toLowerCase().replace(/(?:^|\s)\w/g, function(match) {
+ return match.toUpperCase();
+ });
+}
\ No newline at end of file