Feature: If RSS is enabled, show RSS icon in menu - #63
Conversation
28619fa to
5f7ce19
Compare
|
Hey, thanks for the feature contribution. Personally, I'd prefer it to be one of the feather icons, since it's just fewer bytes, and also MIT licensed :) It would also be great if there was a configuration toggle for:
What do you think? Would you be interested in adding these? |
|
Oh, I didn't know about that OSS icon, that's much better! As for the other things, sounds good! I'll have a look as soon as I have a bit of free time. |
|
If I use something like <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 32 32" fill="none" stroke="#ee802f" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-rss">
<g transform="translate(0,5)">
<path d="M4 11a9 9 0 0 1 9 9"></path>
<path d="M4 4a16 16 0 0 1 16 16"></path>
<circle cx="5" cy="19" r="1"></circle>
</g>
</svg>is that okay? Otherwise I can keep it white and slightly bigger, which is what your original snippet does! |
|
As for enabling the icon, right now one would need to add this to the menu_items = [
# RSS
{name = "", url = "$BASE_URL/$FEED_FILENAME"}
]so it's opt-in already, in a way. Unless you prefer a dedicated config entry! |
yeah, nice! 3 things I would add on top of it (in order of priority):
|
|
I've done a first pass on those features! For 3) I think it might make more sense to have Let me know what's next! |
f1b4c1d to
c84d03c
Compare
| {% endif -%} | ||
|
|
||
| <a type="application/{{feed_type}}" title="RSS" href="{{ get_url(path=config.feed_filename) | safe }}"> | ||
| <svg id="rss-icon" xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 32 32" fill="none" stroke="{{rss_icon_color}}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-rss"> |
There was a problem hiding this comment.
We should give credit to feather icons https://feathericons.com/ and include their LICENSE file in the repo https://github.com/feathericons/feather/blob/main/LICENSE as LICENSE-Feather.md (similar to Hack fonts).
| generate_feed = true | ||
| author = "yourself@email.com" | ||
|
|
||
| # Use `rss.xml` for RSS feeds and `atom.xml` for ATOM. | ||
| feed_filename = "atom.xml" |
| <a href="{{ item.url | replace(from="$BASE_URL", to=config.base_url) | safe }}" target="_blank" rel="noopener noreferrer">{{ item.name | safe }}</a> | ||
|
|
||
| <!-- RSS --> | ||
| {%- set is_rss = item.url == "$BASE_URL/$FEED_FILENAME" -%} |
There was a problem hiding this comment.
We use
{%- if feed is containing('rss') %}
elsewhere now (see #71), would be good to keep it consistent.
There was a problem hiding this comment.
To do that, I'd need to do it inside the {%- for feed in config.feed_filenames %} loop, but this specific if is guarding against a different thing: whether or not the current item refers to the RSS icon or not (we don't care about RSS or ATOM at this stage). If it is referring to RSS, then we can add the svg icon and also add the relevant <a> element depending if it's ATOM or RSS. Does that make sense ?
| {%- if config.generate_feed %} | ||
| {%- if config.feed_filename == "rss.xml" %} | ||
| {% set feed_type = 'rss+xml' %} | ||
| {%- else %} | ||
| {% set feed_type = 'atom+xml' %} | ||
| {% endif -%} |
There was a problem hiding this comment.
Needs to be updated, see other comments for details.
|
Hey @pawroman , no problem. I noticed these new changes in Zola 19.1 as well (getzola/zola#2566) - I'll give it ago once I have a bit of free time. |
This adds support for showing a tiny RSS svg badge in the top menu in
case the user added a menu_item that looks like this:
`{name = "", url = "$BASE_URL/$FEED_FILENAME"}`
This also requires that the user has a config.toml that contains the
following entries:
generate_feed = true
feed_filename = "rss.xml"
author = "your name here"
There's some css rules for which prepending the name of the menu item as set in the config causes the <a> element to appear shifted down compared to the other <a> elements of the menu. I might have a look later, but for now this enables only the appeareance of the RSS icon, discarding entirely the name of the link.
At some point this might follow the same logic used by `accent_color` and `background_color`, for consistency.
NOTE: This breaks compat with previous previous versions since Zola made a breaking change in 0.19 and imho it's not worth trying to support previous versions too.
13fca2f to
8fc4001
Compare

This PR adds support for showing a tiny RSS svg badge in the top menu in case the user added a
menu_itemthat looks like this:It also requires that the user has a config.toml that contains the following entries, and
generate_feedis set totrue:The icon would look like this:

A live example can be seen here: https://valerioviperino.me