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

How to select template with cobalt new? #712

Closed
SuperPrower opened this issue Jan 30, 2020 · 6 comments
Closed

How to select template with cobalt new? #712

SuperPrower opened this issue Jan 30, 2020 · 6 comments

Comments

@SuperPrower
Copy link

Let's say I created a _default/special_posts.md, which I want to base some on posts on. How can I specify using it instead of _default/posts.md? I think that #355 does that, but I'm not sure I follow the logic. I tried doing cobalt new "Test" -f special_posts/, but it just created a post based on _default/pages.md (which makes sense since it isn't in the posts dir).

Thanks in advance.

@epage
Copy link
Member

epage commented Jan 31, 2020

Currently, cobalt is hardcoded to supporting _defaults/posts.<ext> and _defaults/pages.<ext>.

In part, this was trying to balance customization with simplicity and intuitiveness. I'm open to ideas on what people will want to see though.

@SuperPrower
Copy link
Author

Oh, okay. Again, notes in #355 made it seem like cobalt can derive template name from the path (which is kinda true, just for the those two names).

In my opinion, this kind of implicit deriving is not very intuitive: for example, you follow the getting started guide trying to write a new post but get the pages template instead of posts. My proposal would be like following (I don't know enough rust (just yet) to make a pull request on this): keep two base templates (I can understand why you would want just them), but instead of deriving the template based on the path, make it a flag for a new command - --post or --page

@epage
Copy link
Member

epage commented Feb 3, 2020

So to further clarify on this.

The long term goal of cobalt is to add support for "collections". "posts" is a built-in collection. By generalizing it, we could define separate "talks" from "posts" or anything else someone might want. Before I fully implement collections, I am planning to re-architect cobalt using the ECS architecture which should make collections a lot easier to implement.

The new template is based on which "collection" you are creating it for (until full collection support, we only have "posts" and "pages"). The idea is that a generic page, a post, a talk, etc are all very different and so the template should be specialized based on the collection. We can infer the collection from the path and don't need collection flags (and collection fags would need to be generic for when we support user-defined collections).

There are chances that

  • A user might want to share a template across collections (probably too small of a use case?)
  • A user might want more than one template for a given collection (unsure of the size of this use case).

So the question would be how to generalize this, if needed. Some examples include

  • Allowing freely specifying the template, relying on the user to get it right
  • Have per-collection additional templates

@epage
Copy link
Member

epage commented Jan 14, 2022

Going to go ahead and close this out as the collection is the unit of template selection

@epage epage closed this as completed Jan 14, 2022
@SuperPrower
Copy link
Author

Oh, that's good. You refer to layouts - https://cobalt-org.github.io/docs/layouts/ - correct?

@epage
Copy link
Member

epage commented Jan 14, 2022

I'm referring to collections of which we currently only have pages and posts but will add support for user-defined ones (#368).

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

No branches or pull requests

2 participants