Fix placeholders in Pl3xmap page title

This commit is contained in:
James Lyne 2021-08-12 14:27:39 +01:00
parent f0a325ad99
commit 13260bbfeb
2 changed files with 8 additions and 1 deletions

View File

@ -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),

View File

@ -25,6 +25,7 @@ export type Getters = {
night(state: State): boolean;
mapBackground(state: State, getters: GetterTree<State, State> & Getters): string;
url(state: State, getters: GetterTree<State, State> & Getters): string;
pageTitle(state: State, getters: GetterTree<State, State> & Getters): string;
playersHeading(state: State, getters: GetterTree<State, State> & Getters): string;
}
@ -74,6 +75,12 @@ export const getters: GetterTree<State, State> & 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())