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

Filter out entries without routing info #30

Merged
merged 1 commit into from
Dec 10, 2020

Conversation

michaellindahl
Copy link
Contributor

@michaellindahl michaellindahl commented Aug 30, 2020

This fixes #26 and fixes #27 where entries without routes are generated overriding the homepage and excessively generating files.
I'm unsure this should also be applied to urls/terms/scopedTerms and if there's a better approach than the one taken here.

@michaellindahl
Copy link
Contributor Author

So I found a better way of doing this. Previously I was doing:

->filter(function ($entry) {
    return ! is_null($entry->collection()->routes()->get('default'));
})

However, I just realized that Entries are Routable which has a uri() method which returns null when $this->route() doesn't have a value. This seem like the proper solution for Entries. So now I'm doing this:

->reject(function ($entry) {
     return is_null($entry->uri());
})

Terms always have a slug associated with them, which leads me to believe that the urls/terms/scopedTerms do not need this treatment.

This fixes the bug where items without routes are generated overriding the homepage and excessively generating files.
@jasonvarga
Copy link
Member

Sorry for the delay. Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants