HeckarNews icon indicating copy to clipboard operation
HeckarNews copied to clipboard

"Show HN" should not be displayed on the homepage

Open s3689 opened this issue 2 years ago • 4 comments

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/)?

s3689 avatar Jul 18 '22 01:07 s3689

if you want to change it from backend then,

on https://github.com/krehwell/HeckarNews/blob/e535db3d44b110e212fd834936932f324a2a38aa/rest-api/routes/items/api.js#L626 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 https://github.com/krehwell/HeckarNews/blob/e535db3d44b110e212fd834936932f324a2a38aa/website/pages/index.js#L45, 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

krehwell avatar Jul 18 '22 07:07 krehwell

    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".

s3689 avatar Jul 18 '22 08:07 s3689

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

krehwell avatar Jul 18 '22 12:07 krehwell

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

s3689 avatar Jul 18 '22 13:07 s3689