#2069 Raccourcir les titres dans la toc
This commit is contained in:
@@ -96,9 +96,9 @@ export default {
|
|||||||
title () {
|
title () {
|
||||||
// this shoudn't be necessary
|
// this shoudn't be necessary
|
||||||
if (this.item.title && Array.isArray(this.item.title)) {
|
if (this.item.title && Array.isArray(this.item.title)) {
|
||||||
return this.item.title.join(' ')
|
return this.truncate(this.item.title.join(' '), 50, true)
|
||||||
} else if (this.item.title) {
|
} else if (this.item.title) {
|
||||||
return this.item.title
|
return this.truncate(this.item.title, 80, true)
|
||||||
} else {
|
} else {
|
||||||
// console.log('TOC no title', this.item)
|
// console.log('TOC no title', this.item)
|
||||||
// return this.item.type
|
// return this.item.type
|
||||||
@@ -176,6 +176,13 @@ export default {
|
|||||||
...mapActions({
|
...mapActions({
|
||||||
addHistoryItem: 'History/addItem'
|
addHistoryItem: 'History/addItem'
|
||||||
}),
|
}),
|
||||||
|
truncate (str, n, useWordBoundary) {
|
||||||
|
if (str.length <= n) { return str }
|
||||||
|
const subString = str.slice(0, n - 1) // the original check
|
||||||
|
return (useWordBoundary
|
||||||
|
? subString.slice(0, subString.lastIndexOf(' '))
|
||||||
|
: subString) + ' ...'
|
||||||
|
},
|
||||||
onclick (e) {
|
onclick (e) {
|
||||||
console.log('clicked on toc text', this.item, e)
|
console.log('clicked on toc text', this.item, e)
|
||||||
this.addHistoryItem({
|
this.addHistoryItem({
|
||||||
|
|||||||
Reference in New Issue
Block a user