-
Notifications
You must be signed in to change notification settings - Fork 89
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
Conversation
Tagging OptionsShould a new tag be published when this PR is merged?
|
Have you a link to admin were this is working? I want to see how the selection of |
blog/utils/handlePosts.ts
Outdated
) { | ||
const filteredPosts = filterPosts(posts, slug, term); | ||
const filteredPosts = filterPosts(posts, slug, term, excludePostSlug); |
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.
excludePostSlug
is only being applied to filterRelatedPosts
.
Filter this post slug from any result:
const filteredPosts = filterPosts(posts, slug, term, excludePostSlug); | |
const filteredPosts = filterPosts(posts, slug, term).filter( | |
({ slug: postSlug }) => postSlug !== excludePostSlug) | |
); |
blog/loaders/BlogRelatedPosts.ts
Outdated
/** | ||
* 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. | ||
*/ |
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.
JSDoc should be on the exported default function.
/** | ||
* @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. | ||
*/ |
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.
/** | |
* @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. | |
*/ |
* feat(blog): add related posts * refactor(blog): props loader related posts * feat(blog): jsdoc and refactors * chore(deno): eslint
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: