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

Fix recent posts showing #23

Merged
merged 1 commit into from
Apr 14, 2023
Merged

Conversation

boh717
Copy link
Contributor

@boh717 boh717 commented Apr 14, 2023

What problem does this PR solve?

Content pages are not filtered in recent posts in home page.

image

You're not seeing this issue in the demo because:

  • You have 5 posts published
  • About page date is older than all posts

posts wasn't affected by this issue, only home.

Is this PR related to any issue or discussion?

I didn't open an issue.

PR Checklist

  • I have verified that the code works as described/as intended.
  • This change adds a social icon which has a permissive license to use it.
  • This change does not include any external library/resources.
  • This change does not include any unrelated scripts (e.g. bash and python scripts).
  • I have enabled maintainer edits for this PR.

@netlify
Copy link

netlify bot commented Apr 14, 2023

Deploy Preview for endearing-frangollo-e7abce ready!

Name Link
🔨 Latest commit a362ca5
🔍 Latest deploy log https://app.netlify.com/sites/endearing-frangollo-e7abce/deploys/643972c16773fe00083cf001
😎 Deploy Preview https://deploy-preview-23--endearing-frangollo-e7abce.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@hugo-sid
Copy link
Owner

hugo-sid commented Apr 14, 2023

Hi Alberto.

First, thanks for the detailed explanation.

Thanks for identifying the issue (Content pages are not filtered in recent posts) and creating the PR.

Everything looks good to me, apart from this:

  • if you check the deploy preview link associated with this PR, the view all posts link on the homepage is missing.

I don't think your commits have caused this issue. I have to investigate.

@hugo-sid
Copy link
Owner

hugo-sid commented Apr 14, 2023

Ok, I see why the view all posts link on the homepage is missing.

{{ $posts := .Site.RegularPages.ByDate.Reverse }}
{{ range first 5 $posts }}
{{ partial "postCard" . }}
{{ end }}
{{ if gt (len $posts) 5 }}
<p>
<a href="/posts/">See all posts</a>
</p>
{{ end }}

So, the link is displayed if the length of $posts is greater than 5. It was visible earlier since, previously:

{{ $posts := .Site.RegularPages.ByDate.Reverse }}

But with your commit, this has changed to:

{{ $pagesToShow := where .Site.RegularPages "Type" "in" site.Params.mainSections }}
{{ $posts := $pagesToShow.ByDate.Reverse }}

As a result of this, the about page is no longer counted and thus length of $posts equals to 5 (not greater than). Thus the link is missing.

@hugo-sid
Copy link
Owner

hugo-sid commented Apr 14, 2023

Thanks Alberto, for starring the repo & for creating this PR.

You have made a significant contribution to this theme.

Looking forward to more contributions from you.

Have a good day. Happy blogging 🙂

@hugo-sid hugo-sid merged commit 4afdfcb into hugo-sid:main Apr 14, 2023
@boh717
Copy link
Contributor Author

boh717 commented Apr 17, 2023

Thanks @hugo-sid 😄

@boh717 boh717 deleted the fix-recent-posts-showing branch April 17, 2023 08:15
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 this pull request may close these issues.

None yet

2 participants