HeckarNews
HeckarNews copied to clipboard
"Show HN" should not be displayed on the homepage
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/)?
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
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".
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
That's cool! the problem is solved, thank you very much!