jekyll-default-layout
jekyll-default-layout copied to clipboard
Check for collection docs and include them in generator
This resolves https://github.com/benbalter/jekyll-default-layout/issues/32
I grab first all the collection names, then I iterate through them pulling out their docs. These are then included in the flattened array that the existing documents method returns.
~This PR still needs tests added to it but seemed to be working when I tested locally on my example repo from my issue.~
I just added tests and in testing realised that posts
are also considered a collection so I was able to remove the site.posts.docs
call in the documents method since it was redundant and resulting in posts getting pulled into documents twice.
There were some rubocop violations unrelated to this PR that I fixed:
-
RSpec/SubjectDeclaration was mad about the
let(:subject)
use, instead ofsubject(:test_subject)
(it also wasn't happy if I tried to dosubject(:subject)
-
RSpec/NamedSubject was then mad after the above that I hadn't used the named subject
test_subject
instead of just callingsubject
-
RSpec/SpecFilePathFormat
was unhappy that the path was
jekyll-default-layout
instead ofjekyll_default_layout
. -
RSpec/ContextWording
was mad about a few context blocks that didn't start with
when
@halorrr I'm supportive of this functionality, but I suspect it will be a breaking change for many sites (that currently have collections rendered without a default layout). What do you think about making this feature opt-in, or potentially opt-in per collection? Also, what is the advantage of this approach vs. defining a per-collection default layout via frontmatter defaults?
@benbalter I didn't actually know about frontmatter defaults until you mentioned them, but reading about them I think this entire plugin could be replaced by using frontmatter defaults, so I'm not sure I can give a good reason for the advantage, other than awareness of options by the user base. Your plugin was referenced in the github pages docs which is what pointed me toward it.
I tested for my own usage of this plugin for my docs site was replicated with:
defaults:
- values:
layout: "default"
Which did apply to collections as well.
That being said, my only pushback to this being a opt-in feature, is that I don't really see any other config options in this plugin currently, so it would be a new pattern for this plugin. Might make more sense to just bump the major version number and add to the changelog about the new behaviour.