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

Generate at least one page, issue #52 #53

Merged
merged 2 commits into from Dec 2, 2017

Conversation

ibrado
Copy link
Contributor

@ibrado ibrado commented Nov 30, 2017

In cases where there are no posts (fresh site) or all the posts are hidden, no index.html is generated at the document root, leading to 404 errors from many/most hosting providers. This patch makes paginate-v2 always generate at least 1 page.

This fixes issue #52

# In case there are no (visible) posts, generate the index file anyway
if total_pages == 0
total_pages = 1
end
Copy link
Contributor

Choose a reason for hiding this comment

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

in one line.

total_pages = 1 if total_pages.zero?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok! Those were actually the first lines of Ruby I'd ever written... 😊

@sverrirs
Copy link
Owner

sverrirs commented Dec 2, 2017

Now that is an excellent fix :) short and sweet !

@sverrirs sverrirs merged commit ebdd42f into sverrirs:master Dec 2, 2017
@ibrado ibrado deleted the generate-index-for-no-items branch December 2, 2017 23:03
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

3 participants