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

feat(blog): add related posts #976

Merged
merged 4 commits into from
Jan 6, 2025

Conversation

luanargolodev
Copy link
Contributor

What is this contribution about?

This PR was made to add the option to search related posts.
The search is carried out according to the category/categories of the post.
An optional "excludeSlug" prop was also added to exclude the current post from the return list.

Example:

Captura de Tela 2024-12-17 às 20 52 43

Copy link
Contributor

Tagging Options

Should a new tag be published when this PR is merged?

  • 👍 for Patch 0.64.9 update
  • 🎉 for Minor 0.65.0 update
  • 🚀 for Major 1.0.0 update

@IncognitaDev
Copy link
Contributor

Have you a link to admin were this is working? I want to see how the selection of slug is in the form, beside it, LGTM.

@luanargolodev
Copy link
Contributor Author

luanargolodev commented Dec 18, 2024

Have you a link to admin were this is working? I want to see how the selection of slug is in the form, beside it, LGTM.

hello, Luis! it would be like this:

image

) {
const filteredPosts = filterPosts(posts, slug, term);
const filteredPosts = filterPosts(posts, slug, term, excludePostSlug);
Copy link
Contributor

Choose a reason for hiding this comment

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

excludePostSlug is only being applied to filterRelatedPosts.

Filter this post slug from any result:

Suggested change
const filteredPosts = filterPosts(posts, slug, term, excludePostSlug);
const filteredPosts = filterPosts(posts, slug, term).filter(
({ slug: postSlug }) => postSlug !== excludePostSlug)
);

Comment on lines 1 to 8
/**
* Retrieves a list of blog related posts.
*
* @param props - The props for the blog related post list.
* @param req - The request object.
* @param ctx - The application context.
* @returns A promise that resolves to an array of blog related posts.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

JSDoc should be on the exported default function.

Comment on lines +50 to +58
/**
* @title BlogRelatedPosts
* @description Retrieves a list of blog related posts.
*
* @param props - The props for the blog related post list.
* @param req - The request object.
* @param ctx - The application context.
* @returns A promise that resolves to an array of blog related posts.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/**
* @title BlogRelatedPosts
* @description Retrieves a list of blog related posts.
*
* @param props - The props for the blog related post list.
* @param req - The request object.
* @param ctx - The application context.
* @returns A promise that resolves to an array of blog related posts.
*/

@matheusgr matheusgr merged commit c1754b7 into deco-cx:main Jan 6, 2025
1 check passed
vitoUwu pushed a commit that referenced this pull request Jan 30, 2025
* feat(blog): add related posts

* refactor(blog): props loader related posts

* feat(blog): jsdoc and refactors

* chore(deno): eslint
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.

3 participants