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

Front-matter defaults in collections #2405

Closed
jens-na opened this issue May 13, 2014 · 8 comments
Closed

Front-matter defaults in collections #2405

jens-na opened this issue May 13, 2014 · 8 comments

Comments

@jens-na
Copy link

jens-na commented May 13, 2014

Front-matter defaults are available since #2205 and collection support is enabled since #2199, but unfortunately front-matter default values for collections are not implemented.

This is my initial implementation proposal for that.

Implementation

Create a new "defaults scope" named collection.

_config.yml example:

name: test
markdown: redcarpet
highlighter: pygments

collections:
  slides:
    output: true

defaults:
  -
    scope:
      collection: slides
    values:
      test: "foo"
      test2: "bar"

The values test and test2 are only available in files which belong to the _slides collection.

_slides/example-slide.html:

---
layout: slide
title: Example

---
<html>
  <h1>{{ page.test }}</h1>
</html>

Any ideas/opinions?

@parkr
Copy link
Member

parkr commented May 15, 2014

I think collection as an option for scope is smart. It may cause problems, though, if we ever decide to allow collections to be in a subdir. Thoughts?

/cc @benbalter @mattr-

@benbalter
Copy link
Contributor

We should be building under the assumption that we are abstracting and posts and pages will eventually be a specialized collection. No more one-off logic. type: slides

@parkr
Copy link
Member

parkr commented May 15, 2014

I'm 👍 to @benbalter's suggestion.

@jens-na
Copy link
Author

jens-na commented May 15, 2014

👍 for type slides.

jens-na pushed a commit to jens-na/jekyll that referenced this issue May 21, 2014
jens-na pushed a commit to jens-na/jekyll that referenced this issue Jun 1, 2014
jens-na pushed a commit to jens-na/jekyll that referenced this issue Jun 1, 2014
@mattr-
Copy link
Member

mattr- commented Jun 7, 2014

yeah, def 👍 on type: slides. Good call @benbalter.

@jens-na jens-na closed this as completed Jun 13, 2014
@MattiSG
Copy link

MattiSG commented Jun 18, 2014

Looking forward to this being shipped :)

In the meantime, a note in the documentation would be welcome. I tried for some time to use the "path" selector to my collection without understanding why this wouldn't work.

@jens-na
Copy link
Author

jens-na commented Jun 18, 2014

The documentation for the frontmatter-defaults got improved with #2439.
I also added an example how to use frontmatter-defaults with collections in #2419.

@MattiSG
Copy link

MattiSG commented Jun 18, 2014

I also added an example how to use frontmatter-defaults with collections

Yes, which I found when I searched for “defaults” in issues. Thank you very much for your work on this :)

What I meant was that the currently distributed version (2.0.3) does not seem to support type: <collectionName>, and the current manual does not mention path: "_collectionName" doesn't work.

@jekyll jekyll locked and limited conversation to collaborators Feb 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants