split by words

This commit is contained in:
Evert Prants 2020-11-08 17:39:43 +02:00
parent 3e42d44e83
commit 66216075e7
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
3 changed files with 8 additions and 3 deletions

View File

@ -65,7 +65,7 @@
<div class="person-info"> <div class="person-info">
<div class="image"> <div class="image">
<div class="image-wrapper"> <div class="image-wrapper">
<img src="{{ person.image.small }}" alt="{{ person.image.alt }}" title="{{ person.image.title }}"> <img src="{{ person.images[0].medium }}">
</div> </div>
</div> </div>
<div class="detail"> <div class="detail">

View File

@ -69,7 +69,12 @@ export class ListComponent implements OnInit {
public getPersonDetail(person: IPerson): string { public getPersonDetail(person: IPerson): string {
const str = person.intro.replace(/<.*?>/g, ''); const str = person.intro.replace(/<.*?>/g, '');
return (person.intro.length > 284) ? (str.substring(0, 284)) + '....' : (person.intro); let words = str.split(' ');
if (words.length >= 38) {
words = words.slice(0, 37);
words[words.length - 1] += '...';
}
return words.join(' ');
} }
private getList(): void { private getList(): void {

View File

@ -6,7 +6,7 @@ export interface IPerson {
personal_code: number; personal_code: number;
dob: string; dob: string;
phone: string; phone: string;
image: string[]; images: any;
intro: string; intro: string;
} }