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

Recent posts is empty if all the current posts are marked as featured #204

Closed
SSmale opened this issue Dec 30, 2023 · 3 comments · Fixed by #238
Closed

Recent posts is empty if all the current posts are marked as featured #204

SSmale opened this issue Dec 30, 2023 · 3 comments · Fixed by #238

Comments

@SSmale
Copy link
Contributor

SSmale commented Dec 30, 2023

On my version of this (Smale.Codes there is only one post and it is featured. As such there is nothing in Recent and nothing to say 'no posts here' or similar.

image

@satnaing
Copy link
Owner

I intentionally filtered Featured Posts under Recent Posts section.
In this way, I can avoid redundant posts in the index.

Maybe the best way to deal with this problem is to hide Recent section if there's no blog post for that.
Alternative method to solve this issue is displaying all posts without filtering featured posts.

To do so, for now, you can remove the filter logic in src/pages/index.astro

    <section id="recent-posts">
      <h2>Recent Posts</h2>
      <ul>
        {
          sortedPosts
            .filter(({ data }) => !data.featured) // 👈🏻 remove this 
            .map(
              ({ data, slug }, index) =>
                index < 4 && (
                  <Card
                    href={`/posts/${slug}`}
                    frontmatter={data}
                    secHeading={false}
                  />
                )
            )
        }
      </ul>
 ....

@SSmale
Copy link
Contributor Author

SSmale commented Dec 31, 2023

understood, I wonder if there needs to be some smarter logic to see if it is going to be empty then populate it as a message saying 'there are no posts' will be a bit odd.

something like, if there are posts and there is something after the filter, show that, if there are sortedPosts but nothing after the filter, remove the filter, and if there are no sorted posts, show 'no posts yet'

satnaing added a commit that referenced this issue Jan 17, 2024
Changes made:
- Removed the recent posts section if there are no posts under the recent section.
- Eliminated unnecessary <Hr /> tags when there are no recent posts.
- Extracted all-links from the recent section.

Closes: #204
@satnaing
Copy link
Owner

Made a PR for this issue.
Believe it solve this issue with no trade-offs.

satnaing added a commit that referenced this issue Jan 18, 2024
Changes made:
- Removed the recent posts section if there's no post under the recent section.
- Eliminated unnecessary <Hr /> tags when there's no recent post.
- Extracted all-links from the recent section and put it above the footer.

Closes: #204
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 a pull request may close this issue.

2 participants