cobalt-org / cobalt.rs

Static site generator written in Rust
cobalt-org.github.io/
Apache License 2.0
1.37k stars 103 forks source link

Make excerpts available within a collection #561

Open epage opened 5 years ago

epage commented 5 years ago

Use case: providing a menu within a collection

epage commented 5 years ago

From @flosse in https://github.com/cobalt-org/cobalt.rs/issues/557

Hmmm...the image is working now (https://github.com/flosse/cobalt-issue-557/commit/5d265ff785398df2b941502a3111f792f052a744) but the excerpt does not:

Error: serve command failed
Caused by: Failed to render for "posts/post-1.html"
Caused by: Failed to render layout "default.liquid"
Caused by: liquid: Unknown index
  with:
    variable=post.excerpt
    index=excerpt
from: {% for post in collections["posts"]["pages"]  %}
  with:
    post=is_draft: false, title: Rust in der Industrie & Automatisierung, published_date: 2018-10-09 00:00:00 +0100, file: parent: posts, permalink: posts/post-1.md, description: , categories: , collection: posts, slug: post-1, data: tags: stammtisch,rust,industrie,iot,i40, image: /images/rust.png, lang: de, route: /blog, permalink: posts/post-1.html
    index=1
epage commented 5 years ago

From @epage in https://github.com/cobalt-org/cobalt.rs/issues/557

I noticed that in the error, the post does not include excerpt.

Since I haven't touched this part in a while, I had to dig in further. Apparently, content and excerpt are only available for your own page during the processing of posts. Once we start processing non-post pages, we make these variables available.

I'm assuming the intent is for creating a menu. We'd need to split layout rendering into a separate pass from content/excerpt. This seems like a reasonable request until / if we get support for proper menu generation.

epage commented 5 years ago

We'll probably want to do #560 first.