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

Simplify front matter defaults syntax #50

Closed
jaredcwhite opened this issue May 14, 2020 · 7 comments
Closed

Simplify front matter defaults syntax #50

jaredcwhite opened this issue May 14, 2020 · 7 comments
Assignees
Labels
enhancement New feature or request process Improve the development process for the repo
Projects

Comments

@jaredcwhite
Copy link
Member

jaredcwhite commented May 14, 2020

Update: we ended up opting for a "data cascade" folder-based approach rather than changing the syntax of the defaults key in the config. See #139


I've always found the YAML syntax for defining front matter defaults to be extremely obtuse and I always have to look up a reference to remember how the heck to write it out. Really all I want to do is:

defaults:
  posts:
    layout: post
  pages:
    layout: page
  "some/path/to/stuff":
    category: stuff

Let's make this a whole lot better and then deprecate the old syntax with the goal of removing it for the 1.0 release.

Note: it should be a pretty straightforward swap because the old syntax is array-based, whereas the new one will be hash-based, so we can easily detect which syntax is being used.

@jaredcwhite jaredcwhite added the enhancement New feature or request label May 14, 2020
@jaredcwhite jaredcwhite added this to To do in Spring 2020 May 14, 2020
@jaredcwhite jaredcwhite added the process Improve the development process for the repo label May 14, 2020
@jaredcwhite
Copy link
Member Author

jaredcwhite commented Jun 3, 2020

We should do a full performance review of front matter defaults in general as part of this issue. Related issue in Jekyll: jekyll/jekyll#8188 (it's unclear to me why lazily-loading defaults improves the build time so much…not something I would expect)

@KonnorRogers
Copy link
Member

KonnorRogers commented Jul 1, 2020

So heres the current syntax from bridgetown-website/bridgetown.config.yaml

defaults:
- scope:
path: ""
values:
image: /images/bridgetown-logo-twitter-card.jpg
- scope:
path: _docs
values:
layout: docs
- scope:
path: _posts
values:
layout: post
category: news
- scope:
path: _posts/drafts
values:
published: false

The - scope: syntax is pretty gross I agree and I do like the idea of specifying the path as the key value.

I do like the idea of it being top level in the config rather than being nested into a _data folder.

However, I have also thought about the idea of the user defining defaults inside of a defaults.yaml file at the top level of a directory.

IE:

# ./src/_posts/defaults.yaml

layout: post
author: Jared White

Of course, I imagine the performance implications of reading multiple defaults.yaml is probably significantly worse than reading from a single source of truth.

@jaredcwhite
Copy link
Member Author

@ParamagicDev I agree performance should be a concern, but since the number of defaults files would probably be fairly low for an entire site even with thousands of individual pages, I can't imagine it would be a huge hit over a single file. I really like your idea of a "data cascade" based on the filesystem itself — both Eleventy and Hugo have similar concepts, for example.

@jaredcwhite
Copy link
Member Author

OK, I'm going to give the data cascade idea a try. For this initial version, I'm thinking it is only collection-scoped, so _collection_name/_defaults.yml. Next round of improvements would be to allow subfolder trees with their own unique defaults.

@jaredcwhite
Copy link
Member Author

Update: I got it working with subfolder trees out of the gate. 😃 See #139

@jaredcwhite
Copy link
Member Author

I'm keeping this issue open for a bit longer in case we have ideas for further improvements, but I think #139 will address most of the things people expect to do with front matter defaults.

@jaredcwhite jaredcwhite moved this from To do to Done in Spring 2020 Sep 11, 2020
@jaredcwhite jaredcwhite removed this from the 0.17.0 "Mount Scott" milestone Sep 11, 2020
@jaredcwhite
Copy link
Member Author

I think we're good to go at this point. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request process Improve the development process for the repo
Projects
No open projects
Spring 2020
  
Done
Development

No branches or pull requests

2 participants