From fd8064319e352a0083c9e282125e658a44e4dabb Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Thu, 27 Feb 2020 22:30:58 +0100 Subject: viewer: set page title New version, making use of the galleryTitle property, from gallery.yaml --- viewer/src/components/LdTitle.vue | 12 +++++++----- viewer/src/store/galleryStore.ts | 4 ++++ viewer/src/views/MainLayout.vue | 5 ++++- 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 'viewer') diff --git a/viewer/src/components/LdTitle.vue b/viewer/src/components/LdTitle.vue index 47e0729..2614c89 100644 --- a/viewer/src/components/LdTitle.vue +++ b/viewer/src/components/LdTitle.vue @@ -22,7 +22,8 @@ import { Component, Vue, Watch, Prop } from "vue-property-decorator"; @Component export default class LdTitle extends Vue { - @Prop({ required: true }) readonly currentItemPath!: Gallery.Item[]; + @Prop({ required: true }) readonly galleryTitle!: string; + @Prop() readonly currentItem?: Gallery.Item; render() { return null; @@ -32,13 +33,14 @@ export default class LdTitle extends Vue { this.changedCurrentItemPath(); } - @Watch("currentItemPath") + @Watch("currentItem") changedCurrentItemPath() { - document.title = this.currentItemPath.map(this.extractTitle).join(" - "); + document.title = this.generateTitle(); } - extractTitle(item: Gallery.Item, idx: number): string { - return item.title || (idx === 0 ? "LdGallery" : "???"); + generateTitle(): string { + if (this.currentItem?.title) return `${this.galleryTitle} • ${this.currentItem.title}`; + return this.galleryTitle; } } diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index 84673b5..9950f5b 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -70,6 +70,10 @@ export default class GalleryStore extends VuexModule { return path.length > 0 ? path[path.length - 1] : null; } + get galleryTitle(): string { + return this.galleryIndex?.properties.galleryTitle ?? "ldgallery"; + } + // --- // Fetches the gallery's JSON config diff --git a/viewer/src/views/MainLayout.vue b/viewer/src/views/MainLayout.vue index c9ab11a..6ab7d9a 100644 --- a/viewer/src/views/MainLayout.vue +++ b/viewer/src/views/MainLayout.vue @@ -19,7 +19,10 @@