Skip to content

Commit

Permalink
fix: article's display
Browse files Browse the repository at this point in the history
  • Loading branch information
valerymelou committed Aug 2, 2024
1 parent e4990a3 commit 30f5207
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
12 changes: 8 additions & 4 deletions libs/blog/feature-article/src/lib/blog-article.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@
<img
class="h-96 w-full rounded-lg object-cover object-center"
[src]="article.cover.url"
[alt]="article.cover.title"
[alt]="article.cover.description"
/>
<figcaption class="italic text-slate-500 dark:text-slate-400">
{{ article.cover.title }}
{{ article.cover.description }}
</figcaption>
</figure>
}

<div class="my-10">
@if (article.abstract) {
<p class="my-5">{{ article.abstract }}</p>
<hr class="my-10 border-slate-200 dark:border-slate-700" />
}
<div [cfRichTextDocument]="article.content" ngSkipHydration>
<ng-container *cfRichTextNode="BLOCKS.HEADING_1; let node = node">
<h1
Expand Down Expand Up @@ -118,11 +122,11 @@
<img
class="h-auto w-full"
[src]="node.data.target.fields.file.url"
[alt]="node.data.target.fields.title"
[alt]="node.data.target.fields.description"
/>
@if (node.data.target.fields.title) {
<figcaption class="italic text-slate-500 dark:text-slate-400">
{{ node.data.target.fields.title }}
{{ node.data.target.fields.description }}
</figcaption>
}
</figure>
Expand Down
2 changes: 1 addition & 1 deletion libs/shared/ui/src/lib/code/code.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@if (code) {
@if (code.split(' ').length === 1) {
@if (inline) {
<div [innerHTML]="highlightedCode" class="code inline-flex"></div>
} @else {
<div class="group relative">
Expand Down
2 changes: 2 additions & 0 deletions libs/shared/ui/src/lib/code/code.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class CodeComponent {
@Input()
set code(value: string) {
this._code = value;
this.inline = !value.includes('\n');
this.highlight();
}

Expand All @@ -29,6 +30,7 @@ export class CodeComponent {

@Input() language!: string;
highlightedCode!: SafeHtml;
inline = false;

private languages = [
'javascript',
Expand Down

0 comments on commit 30f5207

Please sign in to comment.