Closed ghost closed 1 year ago
Hi, thanks for the contribution! Glad to see someone else using the theme :)
I considered using the continue-reading
anchor before, but I found that I didn't like it. But this is personal taste entirely.
I think it would be good to have it as a configurable switch (opt-in, so false
by default, not to break backwards compatibility). Something in the likes of (untested!):
<a class="read-more button" href="{{ page.permalink | safe }}{% if config.extra.use_continue_reading_anchors %}#continue-reading{% endif %}">
I'm happy to pull once above is resolved :smile:
I've been heavily modifying your great theme, and at this point I changed it so that if the summary is long enough, I add the #continue-reading
, but if it's a short summary I don't bother. So maybe have three options, e.g. "false", "true", "auto"? I find that #continue-reading
is useful when the summary is longer than a page for example.
Perhaps that's too complex but I do like the idea of making it an option.
Hm, auto
does sound like we'd need a piece of logic in the template. But I like the idea. There would have to be a word count or something like that for post sections and we'd enable the anchor if it went above a certain threshold (which could also be configurable).
There's something similar in Zola already (word_count
): https://www.getzola.org/documentation/templates/pages-sections/#page-variables but it seems to count the entire post length.
To use word count on summary, you'd probably have to contribute to Zola: https://github.com/getzola/zola/blob/e6902264ef61c0745e1afa835c4d7717fc075e95/components/library/src/content/page.rs#L139
but perhaps could also get away with a naive character count on summary
? https://github.com/getzola/zola/blob/e6902264ef61c0745e1afa835c4d7717fc075e95/components/library/src/content/page.rs#L59
Might also consider naive splitting on space in Tera: https://tera.netlify.com/docs/templates/#filters
Anyways, completely up to you to pursue - I'm happy with a simple boolean or auto
. I'm also happy with an iterative approach.
I've just been using the character length like {%- if page.summary | length < n -%}
. That's probably good enough for Latin characters? I think 3 options should be ok with proper documentation. I'll add some commits later™.
Sounds good for the first version! Once you're at it, it would be great to add entries in the README
and in config.toml
so that this is documented.
https://www.getzola.org/documentation/content/page/#summary