Ics Resource not recognized by .Resources.ByType

I’m currently trying to access all .ics Calendar Files located in the same Folder where my Shortcode is applied like so:

{{ range .Page.Resources.ByType "text/calendar" }}
  <p>{{ .RelPermalink }}</p>
{{ end }}

but it does not work (nothing listed).
as a test, I also changed ‘text/calendar’ with ‘image’ as there are also images in the Folder, that works.
so, I have the impression that Hugo does not recognize MIME Type text/calendar (which is listed as a common type at Mozilla.
Could that be right, or am I just missing something ?

according to the docs “text/calendar” is available.

Reading Resources.ByType

Returns a collection of page resources of the given media type, or nil if none found. The media type is typically one of image , text , audio , video , or application .

there’s a subtile distinction between MIME and Media Type :wink:

Maybe the docs could be clearer here about using the “MainType” only (same for image - “image/jpeg” won’t work

Try this one

   {{ range (.Resources.ByType "text") }}
      <h2>{{ . }}</h2>
      {{ highlight (debug.Dump .MediaType) "JSON" }}
   {{ end }}
1 Like

oh, well, you are right, it is the MainType (without the Subtype) which is meant here, that works :sunglasses:
Thanks for the Hint !

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.