diff options
author | Zero~Informatique | 2020-02-27 22:30:58 +0100 |
---|---|---|
committer | Zero~Informatique | 2020-02-27 22:30:58 +0100 |
commit | fd8064319e352a0083c9e282125e658a44e4dabb (patch) | |
tree | f558e5d5e378e9eb272f0bb4cb559bcbf071dc74 /viewer/src/components | |
parent | d0063699f031706860689679d4ecf8651b545af1 (diff) | |
download | ldgallery-fd8064319e352a0083c9e282125e658a44e4dabb.tar.gz |
viewer: set page title
New version, making use of the galleryTitle property, from gallery.yaml
Diffstat (limited to 'viewer/src/components')
-rw-r--r-- | viewer/src/components/LdTitle.vue | 12 |
1 files changed, 7 insertions, 5 deletions
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"; | |||
22 | 22 | ||
23 | @Component | 23 | @Component |
24 | export default class LdTitle extends Vue { | 24 | export default class LdTitle extends Vue { |
25 | @Prop({ required: true }) readonly currentItemPath!: Gallery.Item[]; | 25 | @Prop({ required: true }) readonly galleryTitle!: string; |
26 | @Prop() readonly currentItem?: Gallery.Item; | ||
26 | 27 | ||
27 | render() { | 28 | render() { |
28 | return null; | 29 | return null; |
@@ -32,13 +33,14 @@ export default class LdTitle extends Vue { | |||
32 | this.changedCurrentItemPath(); | 33 | this.changedCurrentItemPath(); |
33 | } | 34 | } |
34 | 35 | ||
35 | @Watch("currentItemPath") | 36 | @Watch("currentItem") |
36 | changedCurrentItemPath() { | 37 | changedCurrentItemPath() { |
37 | document.title = this.currentItemPath.map(this.extractTitle).join(" - "); | 38 | document.title = this.generateTitle(); |
38 | } | 39 | } |
39 | 40 | ||
40 | extractTitle(item: Gallery.Item, idx: number): string { | 41 | generateTitle(): string { |
41 | return item.title || (idx === 0 ? "LdGallery" : "???"); | 42 | if (this.currentItem?.title) return `${this.galleryTitle} • ${this.currentItem.title}`; |
43 | return this.galleryTitle; | ||
42 | } | 44 | } |
43 | } | 45 | } |
44 | </script> | 46 | </script> |