I have added an RSS template blog.rss.twig to supplement blog.html.twig in a theme. I am porting a Wordpress site, so this is a format I want to continue supporting. I have chosen not to use the feed plugin this time.
The feed works fine under this system and I went to add an autodiscovery link tag to the HTML template's head. For those not familiar, these takes the form:
<link rel="alternate" type="application/rss+xml" href="//example.org/feed" />
In future, I want to add both Atom and JSON feed alternatives as well, because they are much richer, but for now I just need to support the old RSS.
When I was adding the autodiscovery link to the HTML template, I added it by hand. But it occurred to me that it would be more robust to run a Twig loop through all the content types that the template is available in. That's when I couldn't find a way to determine that in Twig.
Does anyone know how I can retrieve an array of every extension/content type variant that the current template is available in?
For example, from blog.html.twig, I want to say:
{% for contype in page.getContentTypes() if not contype == 'html' %}
{# add the link element etc #}
(or use get_content_types(page.template) or something like that).
I suppose I can query the filesystem in a custom function, but that seems hacky. This is not holding me back, I am just interested in the question. I think a Github issue might just get buried or de-prioritised.