Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct taxonomy declaration in category #20

Merged
merged 2 commits into from
Feb 16, 2024
Merged

Correct taxonomy declaration in category #20

merged 2 commits into from
Feb 16, 2024

Conversation

jpawlowski
Copy link
Contributor

@jpawlowski jpawlowski commented Aug 8, 2019

Based on this, this and my RSS derivate of this feed template, I believe that the category should reflect the taxonomy type in a different scheme.

A URI does not necessarily mean that it is a real URL / internet address (URI != URL, but URL = URI :-)).

@stefanv
Copy link

stefanv commented Jan 14, 2021

I can confirm that this patch brings us closer to a correct rendering.

I also needed to add:

                        {{ if not (reflect.IsSlice $taxo_list) }}                                                                                                        
                          {{ $taxo_list = slice $taxo_list }}                                                                                                            
                        {{ end }}

to ensure that taxo_list was, in fact, a list. Sometimes (for categories), it comes in as a string.

@stefanv
Copy link

stefanv commented Feb 16, 2024

Here's the full patch I had to apply:

diff --git a/layouts/_default/list.atom.xml b/layouts/_default/list.atom.xml
index 69e361e..6bf08ae 100644
--- a/layouts/_default/list.atom.xml
+++ b/layouts/_default/list.atom.xml
@@ -104,12 +104,15 @@
             {{ printf `<content type="html"><![CDATA[%s%s]]></content>` $description .Content | safeHTML }}
             {{ with site.Taxonomies }}
                 {{ range $taxo,$_ := . }} <!-- Defaults taxos: "tags", "categories" -->
-                    {{ with $page.Param $taxo }}
+                {{ with $page.Param $taxo }}
                         {{ $taxo_list := . }} <!-- $taxo_list will be the tags/categories list -->
+                        {{ if not (reflect.IsSlice $taxo_list) }}
+                          {{ $taxo_list = slice $taxo_list }}
+                        {{ end }}
                         {{ with site.GetPage (printf "/%s" $taxo) }}
                             {{ $taxonomy_page := . }}
                             {{ range $taxo_list }} <!-- Below, assuming pretty URLs -->
-                                <category scheme="{{ printf "%s%s" $taxonomy_page.Permalink (. | urlize) }}" term="{{ (. | urlize) }}" label="{{ . }}" />
+                                <category scheme="taxonomy:{{ printf "%s" $taxo | humanize }}" term="{{ (. | urlize) }}" label="{{ . }}" />
                             {{ end }}
                         {{ end }}
                     {{ end }}

It would be great not to have to maintain a fork of this theme; @kaushalmodi any chance you'd be willing to look at the PR?

@kaushalmodi
Copy link
Owner

@stefanv I am not active in Hugo development lately, but to your comment

Sometimes (for categories), it comes in as a string.

That looks strange. I have never seen that happen. Should that be an issue on Hugo?

@kaushalmodi kaushalmodi merged commit d545eff into kaushalmodi:master Feb 16, 2024
@stefanv
Copy link

stefanv commented Feb 16, 2024

Happens if you set categories: foo in the preamble, but that's a mistake, so we can stick to what is in this PR.

@stefanv
Copy link

stefanv commented Feb 16, 2024

Thanks @kaushalmodi!

stefanv added a commit to stefanv/scientific-python-hugo-theme that referenced this pull request Feb 16, 2024
This is part of a larger move to integrate all blog functionality into
the theme, instead of into blog.scientific-python.org.

Before, we used to use a custom fork of kaushalmodi's theme. However,
with

kaushalmodi/hugo-atom-feed#20

merged, we can make use of the original.
jarrodmillman pushed a commit to scientific-python/scientific-python-hugo-theme that referenced this pull request Feb 17, 2024
This is part of a larger move to integrate all blog functionality into
the theme, instead of into blog.scientific-python.org.

Before, we used to use a custom fork of kaushalmodi's theme. However,
with

kaushalmodi/hugo-atom-feed#20

merged, we can make use of the original.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants