Skip to content

Generate at least one page, issue #52#53

Merged
sverrirs merged 2 commits intosverrirs:masterfrom
ibrado:generate-index-for-no-items
Dec 2, 2017
Merged

Generate at least one page, issue #52#53
sverrirs merged 2 commits intosverrirs:masterfrom
ibrado:generate-index-for-no-items

Conversation

@ibrado
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

3 participants