aboutsummaryrefslogtreecommitdiff
path: root/viewer/src
diff options
context:
space:
mode:
authorZero~Informatique2020-02-27 22:30:58 +0100
committerZero~Informatique2020-02-27 22:30:58 +0100
commitfd8064319e352a0083c9e282125e658a44e4dabb (patch)
treef558e5d5e378e9eb272f0bb4cb559bcbf071dc74 /viewer/src
parentd0063699f031706860689679d4ecf8651b545af1 (diff)
downloadldgallery-fd8064319e352a0083c9e282125e658a44e4dabb.tar.gz
viewer: set page title
New version, making use of the galleryTitle property, from gallery.yaml
Diffstat (limited to 'viewer/src')
-rw-r--r--viewer/src/components/LdTitle.vue12
-rw-r--r--viewer/src/store/galleryStore.ts4
-rw-r--r--viewer/src/views/MainLayout.vue5
3 files changed, 15 insertions, 6 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
24export default class LdTitle extends Vue { 24export 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>
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 {
70 return path.length > 0 ? path[path.length - 1] : null; 70 return path.length > 0 ? path[path.length - 1] : null;
71 } 71 }
72 72
73 get galleryTitle(): string {
74 return this.galleryIndex?.properties.galleryTitle ?? "ldgallery";
75 }
76
73 // --- 77 // ---
74 78
75 // Fetches the gallery's JSON config 79 // 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 @@
19 19
20<template> 20<template>
21 <div :class="{'fullscreen': $uiStore.fullscreen, 'fullwidth': $uiStore.fullWidth}"> 21 <div :class="{'fullscreen': $uiStore.fullscreen, 'fullwidth': $uiStore.fullWidth}">
22 <ld-title :current-item-path="$galleryStore.currentItemPath" /> 22 <ld-title
23 :gallery-title="$galleryStore.galleryTitle"
24 :current-item="$galleryStore.currentItem"
25 />
23 <panel-top v-if="!isLoading" class="layout layout-top" /> 26 <panel-top v-if="!isLoading" class="layout layout-top" />
24 <panel-left v-if="!isLoading" class="layout layout-left" /> 27 <panel-left v-if="!isLoading" class="layout layout-left" />
25 <router-view v-if="!isLoading" ref="content" class="layout layout-content scrollbar" /> 28 <router-view v-if="!isLoading" ref="content" class="layout layout-content scrollbar" />