-
-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(content): update injectContent function to return content object… (
#229) Closes #228 BREAKING CHANGES: The signature of the `injectContent` function has changed. BEFORE: injectContent now returns an observable of a string from the rendered markdown. AFTER: injectContent now ContentFile<Attributes | Record<string, never>> which is an object that includes the rendered markdown as the `content` property.
- Loading branch information
1 parent
d740a5c
commit 19beed1
Showing
6 changed files
with
68 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
import { injectContent, MarkdownComponent } from '@analogjs/content'; | ||
import { AsyncPipe } from '@angular/common'; | ||
import { AsyncPipe, NgIf } from '@angular/common'; | ||
import { Component } from '@angular/core'; | ||
import { BlogAttributes } from '../../../lib/blog-attributes'; | ||
|
||
@Component({ | ||
selector: 'blog-post', | ||
standalone: true, | ||
imports: [MarkdownComponent, AsyncPipe], | ||
imports: [MarkdownComponent, AsyncPipe, NgIf], | ||
template: ` | ||
<analog-markdown [content]="content$ | async"></analog-markdown> | ||
<ng-container *ngIf="contentFile$ | async as cf"> | ||
<h1>{{ cf.attributes.title }}</h1> | ||
<analog-markdown [content]="cf.content"></analog-markdown> | ||
</ng-container> | ||
`, | ||
}) | ||
export default class BlogPostComponent { | ||
content$ = injectContent(); | ||
public contentFile$ = injectContent<BlogAttributes>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,4 @@ title: My First Post | |
slug: 2022-12-27-my-first-post | ||
--- | ||
|
||
## My First Post | ||
|
||
Hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface BlogAttributes { | ||
title: string; | ||
slug: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters