cobalt.rs icon indicating copy to clipboard operation
cobalt.rs copied to clipboard

RFC Add `Collections` support.

Open epage opened this issue 7 years ago • 9 comments

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

  • Collection struct
    • files function that returns a wrapper around Files that merges draft and non-draft results
    • Collection is given a ignore patterns for all other collections

Prior Art

Jekyll

See docs

epage avatar Jan 22 '18 13:01 epage

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

epage avatar Jan 22 '18 13:01 epage

See also #309 for alternative ideas for how to do rss for collections

epage avatar Jan 22 '18 13:01 epage

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.

epage avatar Jan 22 '18 13:01 epage

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.

mnivoliez avatar Jan 24 '18 08:01 mnivoliez

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.

epage avatar Jan 24 '18 13:01 epage

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)

Geobert avatar May 09 '18 20:05 Geobert

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.

epage avatar May 09 '18 21:05 epage

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`​).

dmoles avatar Aug 07 '23 11:08 dmoles

I have not gotten back to implementing this (which I need to)

epage avatar Aug 07 '23 14:08 epage