New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: added example in docs of using a resolver for metatags for markdown component (#1014) #1082
base: beta
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for analog-ng-app ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for analog-blog ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for analog-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for analog-app ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -161,6 +161,70 @@ export default class BlogPostComponent { | |||
} | |||
``` | |||
|
|||
### Using A Resolver For Metatags | |||
|
|||
The `postMetaResolver` function is responsible for fetching the meta tags for a post. This function should return an array of meta tags. Here's an example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The `postMetaResolver` function is responsible for fetching the meta tags for a post. This function should return an array of meta tags. Here's an example: | |
In your route configuration, you can use the `RouteMeta` object to resolve meta tags for a route. This is done by assigning the `postMetaResolver` function to the `meta` property. | |
Below is an example of using a `postMetaResolver` function that fetches the meta tags for a post. This function returns an array of meta tags. |
}; | ||
``` | ||
|
||
In your route configuration, you can use the `RouteMeta` object to resolve meta tags for a route. This is done by assigning the `postMetaResolver` function to the `meta` property. Here's an example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In your route configuration, you can use the `RouteMeta` object to resolve meta tags for a route. This is done by assigning the `postMetaResolver` function to the `meta` property. Here's an example: | |
The meta tags can be done asynchronously also. Assign the `postMetaResolver` function to the `meta` property. |
}; | ||
``` | ||
|
||
The resolved meta tags can be accessed in the `BlogPostComponent` using the `ActivatedRoute` service. These meta tags can then be passed to the `MarkdownComponent`. Here's an example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The meta tags cannot be passed to the analog-markdown
component, so maybe a different component name that needs to be used here.
The resolved meta tags can be accessed in the `BlogPostComponent` using the `ActivatedRoute` service. These meta tags can then be passed to the `MarkdownComponent`. Here's an example: | |
The resolved meta tags can also be accessed in the component using the `ActivatedRoute` service. |
```ts | ||
export default class BlogPostComponent { | ||
readonly route = inject(ActivatedRoute); | ||
readonly metaTags$ = this.route.data.pipe(pluck('meta')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't pluck
deprecated in RxJS?
readonly metaTags$ = this.route.data.pipe(pluck('meta')); | |
readonly metaTags$ = this.route.data.pipe(map(data => data['meta'])); |
readonly metaTags$ = this.route.data.pipe(pluck('meta')); | ||
|
||
// In the template | ||
<analog-markdown [content]="post.content" [metaTags]="metaTags$ | async"></analog-markdown> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<analog-markdown [content]="post.content" [metaTags]="metaTags$ | async"></analog-markdown> | |
<my-component [metaTags]="metaTags$ | async"></my-component> |
} | ||
``` | ||
|
||
The `MarkdownComponent` should be modified to accept an input for meta tags and use these when rendering the markdown content. Here's an example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this section should be removed
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Which package are you modifying?
What is the current behavior?
Closes #1014
What is the new behavior?
A new Example added to the docs.
Does this PR introduce a breaking change?
Other information