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 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'viewer/src/components') 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; } } -- cgit v1.2.3