From be534559aa5c1190c8da7c4e3b9757707769da1a Mon Sep 17 00:00:00 2001 From: bach Date: Tue, 28 Feb 2023 16:27:06 +0100 Subject: [PATCH] shortening search result title #1250 --- assets/css/app.scss | 2 ++ src/components/Content/ResultItem.vue | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/assets/css/app.scss b/assets/css/app.scss index e77a025..c3e6edf 100644 --- a/assets/css/app.scss +++ b/assets/css/app.scss @@ -1134,8 +1134,10 @@ footer[role="tools"]{ article.item{ h1{ @include title3black; + font-size: 0.9em; font-weight: 600; max-width: 95%; + word-break:normal; } h2{ @include title3black; diff --git a/src/components/Content/ResultItem.vue b/src/components/Content/ResultItem.vue index 55f6576..0a4c4c6 100644 --- a/src/components/Content/ResultItem.vue +++ b/src/components/Content/ResultItem.vue @@ -5,7 +5,7 @@ :href="'/texts/'+result.textId+'/'+result.uuid" @click.prevent="onclick" @keyup.enter="onclick" - v-html="result.title" + v-html="shorted_title" />

@@ -49,14 +49,21 @@ export default { return this.editionsbyuuid[this.result.textId].title } }, - // created () { + created () { + let max = 40 + if (this.result.title.length > max) { + let subString = this.result.title.substr(0, max) + this.shorted_title = subString.substr(0, subString.lastIndexOf(' ')) + ' …' + } else { + this.shorted_title = this.result.title + } // if (this.result.extract) { // const subString = this.result.extract.substr(0, 80) // this.preview = subString.substr(0, subString.lastIndexOf(' ')) + ' …' // } else { // console.warn(`No extract for ${this.result.textId}/${this.result.uuid}`) // } - // }, + }, methods: { ...mapActions({ addHistoryItem: 'History/addItem'