collections: posts as collection #4055

Merged
merged 1 commit into from Oct 26, 2015

Conversation

Projects
None yet
6 participants
@parkr
Member

parkr commented Oct 26, 2015

I guess I need to release Jekyll 3 tomorrow...

This is the last piece we were considering doing.

In an effort to not break sites, this is all backwards compatible liquid-wise. The only big difference is that site.posts is a Collection instead of an Array. But I feel more comfortable breaking plugins than I do breaking people's Liquid. Especially because Liquid doesn't have a means of erroring out on a bad dereference (see Shopify/liquid#490 for more).

The cukes all pass. I'm going to work on the presentation now and leave this. But here it is.

/cc @benbalter who was looking to see this in 3.

@parkr parkr added this to the 3.0 milestone Oct 26, 2015

@parkr

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Oct 26, 2015

Member

cc @jekyll/core for thoughts. will merge now – please leave thoughts or submit follow-up PR's in the 3.0 milestone to fix things. it's not perfect, but at least it's something. crunch time!

Member

parkr commented Oct 26, 2015

cc @jekyll/core for thoughts. will merge now – please leave thoughts or submit follow-up PR's in the 3.0 milestone to fix things. it's not perfect, but at least it's something. crunch time!

parkr added a commit that referenced this pull request Oct 26, 2015

@parkr parkr merged commit e58d0ae into master Oct 26, 2015

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@parkr parkr deleted the beefer-collections branch Oct 26, 2015

@parkr parkr added the Enhancement label Oct 26, 2015

parkr added a commit that referenced this pull request Oct 26, 2015

+ config['collections']['posts']['permalink'] = style_to_permalink(config['permalink'])
+
+ config
+ end

This comment has been minimized.

@benbalter

benbalter Oct 26, 2015

Contributor

Nicely implemented.

@benbalter

benbalter Oct 26, 2015

Contributor

Nicely implemented.

@@ -242,19 +293,54 @@ def read(opts = {})
end
end
+ def post_read

This comment has been minimized.

@benbalter

benbalter Oct 26, 2015

Contributor

Does this mean that all collections can have a date now?

@benbalter

benbalter Oct 26, 2015

Contributor

Does this mean that all collections can have a date now?

This comment has been minimized.

@parkr

parkr Oct 26, 2015

Member

Yes!

@parkr

parkr Oct 26, 2015

Member

Yes!

This comment has been minimized.

@benbalter

benbalter Oct 26, 2015

Contributor

Huh. 🤘

@benbalter

benbalter Oct 26, 2015

Contributor

Huh. 🤘

This comment has been minimized.

@parkr

parkr Oct 26, 2015

Member

_decisions/2015-06-29-glossip-v-gross.md

@parkr

parkr Oct 26, 2015

Member

_decisions/2015-06-29-glossip-v-gross.md

+ "collection" => collection.label,
+ "next" => next_doc,
+ "previous" => previous_doc,
+ "id" => id,

This comment has been minimized.

@benbalter

benbalter Oct 26, 2015

Contributor

All documents having IDs is going to fix so many terrible workarounds I've created. 😄

@benbalter

benbalter Oct 26, 2015

Contributor

All documents having IDs is going to fix so many terrible workarounds I've created. 😄

@benbalter

This comment has been minimized.

Show comment
Hide comment
@benbalter

benbalter Oct 26, 2015

Contributor

Helz yes

Contributor

benbalter commented Oct 26, 2015

Helz yes

@envygeeks

This comment has been minimized.

Show comment
Hide comment
@envygeeks

envygeeks Oct 26, 2015

Contributor

Since @benbalter posted the Wonder Years guy is this gonna be Jekyll's Wonder Years?

Contributor

envygeeks commented Oct 26, 2015

Since @benbalter posted the Wonder Years guy is this gonna be Jekyll's Wonder Years?

@benbalter

This comment has been minimized.

Show comment
Hide comment
@benbalter

benbalter Oct 26, 2015

Contributor

Technically, that was from FOX's new hit show the Grinder, so I say we have a 50/50 chance. 😄

Contributor

benbalter commented Oct 26, 2015

Technically, that was from FOX's new hit show the Grinder, so I say we have a 50/50 chance. 😄

@parkr

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Oct 26, 2015

Member

Thanks for taking the time to 👀 this, @benbalter!

Member

parkr commented Oct 26, 2015

Thanks for taking the time to 👀 this, @benbalter!

@envygeeks

This comment has been minimized.

Show comment
Hide comment
@envygeeks

envygeeks Oct 26, 2015

Contributor

He will forever be Kevin Arnold to me. Always. 💯

Contributor

envygeeks commented Oct 26, 2015

He will forever be Kevin Arnold to me. Always. 💯

@envygeeks

This comment has been minimized.

Show comment
Hide comment
@envygeeks

envygeeks Oct 26, 2015

Contributor

This renames a hook, are we going to have trouble with this? Perhaps we should have hook aliases? I think :page is a nice name, you think :pages is a nice name, we can have aliases like we do for Jekyll Assets hooks.

This renames a hook, are we going to have trouble with this? Perhaps we should have hook aliases? I think :page is a nice name, you think :pages is a nice name, we can have aliases like we do for Jekyll Assets hooks.

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Oct 26, 2015

Member

Sure! We use duplicates here for front matter defaults so I figured it would be nice to be uniform. :site has stayed singular, but :pages, :posts, and :documents are all pluralized now. It gave me the flexibility, for Documents, to call Jekyll::Hooks.trigger collection.label.to_sym, :hook_name, args which I found powerful. This way, you can define hooks for your :cookies collection or whatever and have global :documents hooks for all Documents.

Member

parkr replied Oct 26, 2015

Sure! We use duplicates here for front matter defaults so I figured it would be nice to be uniform. :site has stayed singular, but :pages, :posts, and :documents are all pluralized now. It gave me the flexibility, for Documents, to call Jekyll::Hooks.trigger collection.label.to_sym, :hook_name, args which I found powerful. This way, you can define hooks for your :cookies collection or whatever and have global :documents hooks for all Documents.

@envygeeks

This comment has been minimized.

Show comment
Hide comment
@envygeeks

envygeeks Oct 26, 2015

Contributor

Ditto on the above.

Ditto on the above.

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Oct 26, 2015

Member

Want to be able to trigger hooks for arbitrary collection names, like posts. b89f943#commitcomment-13990093

Member

parkr replied Oct 26, 2015

Want to be able to trigger hooks for arbitrary collection names, like posts. b89f943#commitcomment-13990093

@envygeeks

This comment has been minimized.

Show comment
Hide comment
@envygeeks

envygeeks Oct 26, 2015

Contributor

Why not Hash#fetch?

Contributor

envygeeks commented on lib/jekyll.rb in b89f943 Oct 26, 2015

Why not Hash#fetch?

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Oct 26, 2015

Member

Not sure, just copied from above

Member

parkr replied Oct 26, 2015

Not sure, just copied from above

@envygeeks

This comment has been minimized.

Show comment
Hide comment
@envygeeks

envygeeks Oct 26, 2015

Contributor

From past experience this is slower than define_method with send, any reason why you opted for this?

From past experience this is slower than define_method with send, any reason why you opted for this?

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Oct 26, 2015

Member

Hadn't thought of define_method last night in the trenches.

Member

parkr replied Oct 26, 2015

Hadn't thought of define_method last night in the trenches.

@envygeeks

This comment has been minimized.

Show comment
Hide comment
@envygeeks

envygeeks Oct 26, 2015

Contributor

I think this is an advantageous example of the need for Hooks on configuration, we could push this off of this class and into an internal hook and simplify this class since it's probably starting to get beastly.

I think this is an advantageous example of the need for Hooks on configuration, we could push this off of this class and into an internal hook and simplify this class since it's probably starting to get beastly.

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Oct 26, 2015

Member

👍 let's do that in 3.1. can you show me how you'd like that done at some point?

Member

parkr replied Oct 26, 2015

👍 let's do that in 3.1. can you show me how you'd like that done at some point?

This comment has been minimized.

Show comment
Hide comment
@WelcometomyblogJoebravo

WelcometomyblogJoebravo Dec 28, 2015

Hey I'm sorry if I did somethings wrong I'm just learning.

Hey I'm sorry if I did somethings wrong I'm just learning.

@alfredxing

This comment has been minimized.

Show comment
Hide comment
@alfredxing

alfredxing Oct 26, 2015

Member

Woohoo! 🍻

I'll take a good look at the code a bit later!

Member

alfredxing commented Oct 26, 2015

Woohoo! 🍻

I'll take a good look at the code a bit later!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.