diff --git a/src/App.vue b/src/App.vue index f22bbee..d34050a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -43,7 +43,7 @@ export default defineComponent({ setup() { const store = useStore(), - title = computed(() => store.state.configuration.title), + title = computed(() => store.getters.pageTitle), currentUrl = computed(() => store.getters.url), currentServer = computed(() => store.state.currentServer), configurationHash = computed(() => store.state.configurationHash), diff --git a/src/store/getters.ts b/src/store/getters.ts index 189efba..56baffb 100644 --- a/src/store/getters.ts +++ b/src/store/getters.ts @@ -25,6 +25,7 @@ export type Getters = { night(state: State): boolean; mapBackground(state: State, getters: GetterTree & Getters): string; url(state: State, getters: GetterTree & Getters): string; + pageTitle(state: State, getters: GetterTree & Getters): string; playersHeading(state: State, getters: GetterTree & Getters): string; } @@ -74,6 +75,12 @@ export const getters: GetterTree & Getters = { return getUrlForLocation(state.currentMap, {x,y,z}, zoom); }, + pageTitle(state: State): string { + return state.configuration.title + .replace(/{world}/gi, state.currentWorld?.displayName || 'No world') + .replace(/{map}/gi, state.currentMap?.displayName || 'No map'); + }, + playersHeading(state: State): string { return state.messages.playersHeading .replace('{cur}', state.players.size.toString())