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

Add baseURL variable on See all posts button #38

Merged
merged 3 commits into from
May 16, 2023

Conversation

Rayjun0525
Copy link
Contributor

@Rayjun0525 Rayjun0525 commented May 5, 2023

What problem does this PR solve?

P : Fix for 404 errors in see all posts if the default URL is not root.
S : Add a baseURL variable to the link in the button.

Is this PR adding a new feature?

no

Is this PR related to any issue or discussion?

Issue #36 (closed)

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.

Add baseURL variable to link of see all posts button.
Fix for 404 errors in see all posts if the default URL is not root. Add a baseURL variable to the link in the button.
@netlify
Copy link

netlify bot commented May 5, 2023

Deploy Preview for hugo-blog-awesome ready!

Name Link
🔨 Latest commit 00c748c
🔍 Latest deploy log https://app.netlify.com/sites/hugo-blog-awesome/deploys/6456769c2c7b2f00080deae9
😎 Deploy Preview https://deploy-preview-38--hugo-blog-awesome.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.

@github-actions github-actions bot added the size/s label May 5, 2023
@@ -17,7 +17,7 @@ <h3 class="posts-item-note" aria-label="Recent Posts">Recent Posts</h3>
{{ end }}
{{ if gt (len $posts) 5 }}
<p>
<a href="/posts/">See all posts</a>
<a href="{{ .Site.Home.Permalink }}posts/">See all posts</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I missed this 😉

Copy link
Contributor

@kusyka911 kusyka911 May 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is ability to get full link from hugo.

In this example we get first element from .Site.Params.mainSections and get matching section object from .Site.Sections. This will allow our user to use any name for posts directory. And for us to get full main section URL from hugo.

{{ range $firstSection := (where .Site.Sections "Section" "in" (first 1 (.Site.Params.mainSections))) }}
<a href="{{ $firstSection.Permalink }}">See all posts</a>
{{ end }}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's grate! I will try that on my local project :)

@Rayjun0525 Rayjun0525 requested a review from kusyka911 May 6, 2023 15:01
Apply by changing all publishing buttons to the code suggested by @kusyka911
@sonarcloud
Copy link

sonarcloud bot commented May 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@hugo-sid
Copy link
Owner

hugo-sid commented May 8, 2023

Thanks for this PR @Rayjun0525.

Your contribution is greatly appreciated.

@kusyka911, could you please review this? I will merge it after that.

Copy link
Contributor

@kusyka911 kusyka911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for me

@hugo-sid
Copy link
Owner

Thanks @Rayjun0525 and @kusyka911 for your contributions.

@hugo-sid hugo-sid merged commit 6e12b25 into hugo-sid:main May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants