cobalt.rs
cobalt.rs copied to clipboard
RFC Add `Collections` support.
Use cases:
- A site might track talks separately from blog posts (see johannhof's site).
- A collection of quotes
- Anything similar to a scrapbook
Proposal: support the user defining something like "posts" called a "collection".
User-facing design
Implementation
Collectionstructfilesfunction that returns a wrapper aroundFilesthat merges draft and non-draft resultsCollectionis given a ignore patterns for all other collections
Prior Art
Jekyll
See docs
Some ideas on refactoring to this:
This isn't about collections but more of notes on how I want to get there
Create Assets
- SassOptions -> SassBuilder in a sass.rs file
Collection
- Add option to Files to limit search to a specific sub-dir so we can walk each collection separately
- PostBuilder is a specialized builder for CollectionBuilder
Work already done:
- #315 was a small step
- #346 is also a step in this direction.
See also #312
See also #309 for alternative ideas for how to do rss for collections
One idea, spawned by #355, is for a folder to have a _collection.yml file. Anything in that folder or deeper would then be a part of that collection.
Pros
- It keeps the configuration close by.
- It makes it easy to detect the collection on a single file
Cons
- More "turds" dropped in the user's site
- We effectively have to walk the entire site (up until we find a
_collection.yml) to discover all the collections - We can't walk each collection in parallel. Instead we walk the files and spit them out into each collection.
Why not making a conf file with all collections and folder for each one? like
collections:
- posts
- talks
And in dir structure, we got folder posts (like usual) and talks. What do you think? Also, it's mean we can walk the collections in parallel more easely and not walk the entire directory structure.
My current is to have all of the collections defined in _cobalt.yml in a manner similar to posts.
collections:
- title: Cats
rss: /cats.xml
default:
layout: cats.liquid
My comment above was more of a one off idea that I was exploring but probably won't do.
As mentioned above, the main question is how to handle RSS (see #309) but I think this should get implemented and worry about making RSS nicer, later.
We can mix both ideas, using epage format and the title as the folder name so we can walk collections in parallel. This whole collection concept looks like gutenberg's Section as well (a folder = a section)
Yeah, I've been looking at gutenburg and others when designing this. You can see the where I'm currently looking at going with collections by looking at the CollectionBuilder. We'd make a CollectionConfig similar to PostConfig and PageConfig that basically exposes every `CollectionBuilder feature in the config format.
What's the status of this feature? The existence of collections.posts suggests the possibility of collections other than posts, but there doesn't seem to be any obvious way to create them (e.g. the syntax mentioned above produces Error: failed to parse config with unknown field `collections`).
I have not gotten back to implementing this (which I need to)