1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Fine markdowns #587 #711

This commit is contained in:
Patrik J. Braun 2023-09-04 22:14:25 +02:00
parent e3eda4676e
commit 2b75866949
2 changed files with 20 additions and 10 deletions

View File

@ -2,18 +2,18 @@
<div class="blog" *ngIf="markdowns.length > 0">
<div class="card">
<div class="card-body" style="min-height: 77px" [style.height]="!open ? '77px':''">
<ng-container *ngFor="let md of markdowns; let last = last">
<ng-container *ngFor="let md of markdowns; let last = last; let first = first">
<markdown
*ngIf="open"
[data]="md.text">
</markdown>
<span *ngIf="!open" class="text-preview">
<span *ngIf="!open && first" class="text-preview">
<markdown
[inline]="true"
[data]="md.text">
[data]="md.textShort">
</markdown>
</span>
<hr *ngIf="!last">
<hr *ngIf="open && !last">
</ng-container>
</div>
</div>

View File

@ -55,11 +55,14 @@ export class BlogService {
}];
}
ret.push({
text: markdown.substring(0, matches[0].index),
file: file
});
const baseText = markdown.substring(0, matches[0].index).trim();
// don't show empty
if (baseText) {
ret.push({
text: baseText,
file: file
});
}
for (let i = 0; i < matches.length; ++i) {
const matchedStr = matches[i][0];
@ -72,8 +75,12 @@ export class BlogService {
if (groupDate === undefined) {
groupDate = dates[dates.length - 1];
}
const text = i + 1 >= matches.length ? markdown.substring(matches[i].index) : markdown.substring(matches[i].index, matches[i + 1].index);
const text = (i + 1 >= matches.length ? markdown.substring(matches[i].index) : markdown.substring(matches[i].index, matches[i + 1].index)).trim();
// don't show empty
if (!text) {
continue;
}
// if it would be in the same group. Concatenate it
const sameGroup = ret.find(g => g.date == groupDate);
if (sameGroup) {
@ -87,6 +94,8 @@ export class BlogService {
});
}
ret.forEach(md => md.textShort = md.text.substring(0, 200));
return ret;
}
@ -112,5 +121,6 @@ export class BlogService {
export interface GroupedMarkdown {
date?: number;
text: string;
textShort?: string;
file: FileDTO;
}