Fix broken instance description if it contains a line break

This commit is contained in:
Georg Krause 2022-02-02 10:22:47 +01:00
parent dc29098f54
commit fae4ba08e8
No known key found for this signature in database
GPG Key ID: FD479B9A4D48E632
3 changed files with 25 additions and 19 deletions

View File

@ -0,0 +1 @@
Fix broken instance description if it contains a line break #1673

View File

@ -39,23 +39,24 @@
>
<div class="ui stackable grid">
<div class="eight wide column">
<p v-if="!truncatedDescription">
<p v-if="!renderedDescription">
<translate translate-context="Content/Home/Paragraph">
No description available.
</translate>
</p>
<template v-if="truncatedDescription || rules">
<template v-if="renderedDescription || rules">
<div
v-if="truncatedDescription"
v-html="truncatedDescription"
v-if="renderedDescription"
id="renderedDescription"
v-html="renderedDescription"
/>
<div
v-if="truncatedDescription"
v-if="renderedDescription"
class="ui hidden divider"
/>
<div class="ui relaxed list">
<div
v-if="truncatedDescription"
v-if="renderedDescription"
class="item"
>
<i class="arrow right icon" />
@ -324,7 +325,6 @@
</template>
<script>
import $ from 'jquery'
import _ from '@/lodash'
import { mapState } from 'vuex'
import showdown from 'showdown'
@ -372,22 +372,12 @@ export default {
rules () {
return _.get(this.nodeinfo, 'metadata.rules')
},
truncatedDescription () {
renderedDescription () {
if (!this.longDescription) {
return
}
const doc = this.markdown.makeHtml(this.longDescription)
const nodes = $.parseHTML(doc)
const excerptParts = []
let handled = 0
nodes.forEach((n) => {
const content = n.innerHTML || n.nodeValue
if (handled < this.excerptLength && content.trim()) {
excerptParts.push(n)
handled += 1
}
})
return excerptParts.map((p) => { return p.outerHTML }).join('')
return doc
},
stats () {
const data = {

View File

@ -31,3 +31,18 @@
display: block;
}
}
#renderedDescription {
display: -webkit-box;
-webkit-line-clamp: 5;
-webkit-box-orient: vertical;
overflow: hidden;
}
#renderedDescription p {
margin: 0;
}
#renderedDescription *:not(:first-child) {
display: none;
}