From ef15adcb887183bc41c415a243ecb94cec9a7d2b Mon Sep 17 00:00:00 2001 From: Maicol Battistini Date: Tue, 25 Jul 2023 11:21:41 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Permetti=20di=20personalizz?= =?UTF-8?q?are=20il=20titolo=20della=20pagina?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/ts/Components/Page.tsx | 6 +++++- resources/ts/app.ts | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/resources/ts/Components/Page.tsx b/resources/ts/Components/Page.tsx index 4e822bde3..406522b25 100644 --- a/resources/ts/Components/Page.tsx +++ b/resources/ts/Components/Page.tsx @@ -45,10 +45,14 @@ export default abstract class Page ex } if (this.title) { - document.title = `${this.title} - OpenSTAManager`; + document.title = this.pageTitle(); } } + pageTitle(): string { + return this.title ? `${this.title} - OpenSTAManager` : 'OpenSTAManager'; + } + contents(vnode: Vnode): Children | Collection { return undefined; } diff --git a/resources/ts/app.ts b/resources/ts/app.ts index 24517416b..b42f5d534 100644 --- a/resources/ts/app.ts +++ b/resources/ts/app.ts @@ -3,6 +3,7 @@ import '@osm/../scss/app.scss'; import {createInertiaApp} from '@maicol07/inertia-mithril'; import {showSnackbar} from '@osm/utils/misc'; import Mithril from 'mithril'; +import Stream from 'mithril/stream'; import {registerSW} from 'virtual:pwa-register'; import {resolvePage} from '~inertia'; @@ -29,8 +30,11 @@ window.__ = stringTranslator; // Load modules bootstrap file import.meta.glob('../../vendor/**/**/resources/{js,ts}/bootstrap.{tsx,ts,js,jsx}', {eager: true}); +// eslint-disable-next-line import/no-mutable-exports,import/prefer-default-export,prefer-const +export const titleCallback = Stream((title: string) => `${title} - OpenSTAManager`); + await createInertiaApp({ - title: ((title) => `${title} - OpenSTAManager`), + title: (title) => titleCallback()(title), // This rule is disabled to avoid a bug in Inertia plugin // eslint-disable-next-line arrow-body-style resolve: resolvePage(() => {