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

"Show HN" should not be displayed on the homepage #5

Open
s3689 opened this issue Jul 18, 2022 · 4 comments
Open

"Show HN" should not be displayed on the homepage #5

s3689 opened this issue Jul 18, 2022 · 4 comments

Comments

@s3689
Copy link

s3689 commented Jul 18, 2022

The official "Show HN" is not displayed on the homepage (https://news.ycombinator.com/show), How can I set it to not show on the homepage (see https://forum.krehwell.com/)?

@krehwell
Copy link
Owner

krehwell commented Jul 18, 2022

if you want to change it from backend then,

on

ItemModel.find({ created: { $gt: startDate }, dead: false })
you can add a filter there to find it with type: "news".

However if you don't want to filter from backend, then on front end you can filter it manually on

const apiResult = await getRankedItemsByPage(page, req);
, you can filter it

    const _apiResult = await getRankedItemsByPage(page, req);
    const apiResult = _apiResult?.items?.filter(item => item.type === "news")

I haven't tested the code above, but I think it should work like that

@s3689
Copy link
Author

s3689 commented Jul 18, 2022

    const _apiResult = await getRankedItemsByPage(page, req);
    const apiResult = _apiResult?.items?.filter(item => item.type === "news")

Thank you for your reply, After the modification, the homepage does not display any content at all.

Sorry, my expression is wrong, I think "Show HN" type items are only displayed in the "Show" column (https://forum.krehwell.com/show) , and should not be displayed in the following places "https://forum.krehwell.com/", "https://forum.krehwell.com/news", "https://forum.krehwell.com/newest".

@krehwell
Copy link
Owner

krehwell commented Jul 18, 2022

Thank you for your reply, After the modification, the homepage does not display any content at all.

it's just wrong logic actually, you can log it in console,

after modification,

    const apiResult = await getRankedItemsByPage(page, req);
    const items = apiResult?.items?.filter((item) => item.type === "news");

    return {
        props: {
            items: items || [],
            ...
        }
    }

now it should be good. Do this to the rest of the page if you want to do the filtering from client

@s3689
Copy link
Author

s3689 commented Jul 18, 2022

That's cool! the problem is solved, thank you very much!

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

No branches or pull requests

2 participants