Skip to content
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

Open
wants to merge 1 commit into
base: beta
Choose a base branch
from

Conversation

AmGarera
Copy link

@AmGarera AmGarera commented May 3, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Which package are you modifying?

  • vite-plugin-angular
  • vite-plugin-nitro
  • astro-angular
  • create-analog
  • router
  • platform
  • content
  • nx-plugin
  • trpc

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?

  • Yes
  • No

Other information

Copy link

netlify bot commented May 3, 2024

Deploy Preview for analog-ng-app ready!

Name Link
🔨 Latest commit 2d56281
🔍 Latest deploy log https://app.netlify.com/sites/analog-ng-app/deploys/6635765dcbbe8b0008d97cdc
😎 Deploy Preview https://deploy-preview-1082--analog-ng-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented May 3, 2024

Deploy Preview for analog-blog ready!

Name Link
🔨 Latest commit 2d56281
🔍 Latest deploy log https://app.netlify.com/sites/analog-blog/deploys/6635765df6701a0008bb7d05
😎 Deploy Preview https://deploy-preview-1082--analog-blog.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented May 3, 2024

Deploy Preview for analog-docs ready!

Name Link
🔨 Latest commit 2d56281
🔍 Latest deploy log https://app.netlify.com/sites/analog-docs/deploys/6635765d5c8e810008cdae0c
😎 Deploy Preview https://deploy-preview-1082--analog-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented May 3, 2024

Deploy Preview for analog-app ready!

Name Link
🔨 Latest commit 2d56281
🔍 Latest deploy log https://app.netlify.com/sites/analog-app/deploys/6635765df2c2d50008fb6c2d
😎 Deploy Preview https://deploy-preview-1082--analog-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
Copy link
Member

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.

Suggested change
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'));
Copy link
Member

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?

Suggested change
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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<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:
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs: add example of using a resolver for metatags for markdown component
2 participants