Skip to content

Conversation

@TatsatJha
Copy link
Collaborator

Some entries are still not being rendered despite all conditionals evaluating to true. More debugging is needed

Copy link
Member

@rlskoeser rlskoeser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a little bit of time end of day to test this out briefly, hope my comments are useful.

I looked up and found this command to determine current cache directory:

hugo config | grep cachedir

Maybe you've already found that; thought it could be helpful to look at the data you're getting back from the api call in the template. (I imagine eventually we'll want to recommend custom configuration or custom cache dir...)

Comment on lines 9 to 10
{{ $groupId := site.Params.groupId }}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a site configuration parameter, I suggest using a shortcode parameter - that will make the shortcode more flexible, since it could be used with multiple different ids on the same site. Maybe site config could be a fallback default, since it could be a common approach for sites like DHTech. (In which case, keep this for a later refinement once you get the basics working!)

https://gohugo.io/content-management/shortcodes/#arguments
I would go with named parameters. In future this could allow handling both group id and personal id in the same shortcode.

(I see now that you're using arguments for filters; I don't think that's necessarily incompatible with this....)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, thinking more about it, the cite tag would need to use the same zotero data as the biblography; so I guess it should either be a site parameter or a page parameter.

{{- $authorParam := $context.Get "authorNum" | default "3" }}
{{- $authorNum := int $authorParam }}

{{ $endpoint := printf "https://api.zotero.org/groups/%d/items?start=0&limit=100&format=json" $groupId }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are functions for constructing urls (urls.JoinPath) and query strings (collections.Querify). Annoyingly it seems like you still have to use printf to combine them, but should make it more semantic to construct the api endpoint url and then set the parameters as a dictionary.

https://gohugo.io/functions/urls/joinpath/
https://gohugo.io/functions/collections/querify/#

Example (not connected, just constructing the two parts):

{{ urls.JoinPath "https://api.zotero.org/groups/" $groupId "items"}}
 {{ collections.Querify (dict "start" 0 "limist" 100 "format" "json") }} 

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logic for getting the zotero data will need to be pulled out into a shared internal shortcode that both bibliography and cite shortcodes can use, since they need to work with the same data.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Rebecca, I tried to pull out the fetching data but I think this would require the data be stored with scratch and then gotten from scratch in each of the shortcodes afterwards. I kept running into issues with scratch trying to do this even though I used scratch elsewhere in the shortcode. Do you know if there's a better way for this sort of application?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a partial template in another project that returns json data generated from templates, maybe it could be a useful example?

https://github.com/Princeton-CDH/lenape-timetree/blob/main/layouts/partials/leaf_data.json

{{- end }}

<!-- adds entry to citations if it should be included based on filters and in-text citations -->
{{- if and $include (or (not $onlyCited) (in $citedTitles $entry.title)) }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's hard for me to follow the filter logic above this, but when I disable the include check I get citations displaying. Without it, none of them display for me (even when I am not passing filters to the shortcode).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Rebeecca, I'm trying to make the filter logic more readable right now, but it was working correctly for me, what exactly led to none of the citations displaying?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was testing on my personal site, where I started trying to integrate hugo-biblography - I wanted to do something like a customized version of the 'my publications' that zotero lets you set up on your personal profile.

However, in hindsight, that isn't the best place to test since I haven't gotten it fully working. What do you recommend for testing? Should I use the dh-tech site and switch to this branch for testing?

@TatsatJha TatsatJha marked this pull request as ready for review November 7, 2025 17:19
@TatsatJha TatsatJha merged commit b098d63 into main Nov 7, 2025
1 check passed
@TatsatJha TatsatJha deleted the update-fetch branch December 17, 2025 17:47
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