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

Unexpected replacement of :counter in resources→title/name #4334

Closed
kaushalmodi opened this Issue Jan 26, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@kaushalmodi
Copy link
Member

kaushalmodi commented Jan 26, 2018

Hello,

Details of this issue got buried in this HugoDocs issue discussion. I believe this is something that needs to be fixed, so cross-posting the issue details here.

Problem

If a Resource file is "fetched" by one set of resourcessrc rule, and then again using a different resourcessrc rule later, :counter value substituted in name (probably in title too) stays stuck at 1.

The above problem statement might not make sense at first read, so please review the below details.

Details

Works

This scenario works as expected i.e. the :counter is doing expected substitutions in the Resource Name.

Here I have only:

[[resources]]
  src = "**.pdf"
  name = "pdf-file-:counter"

Counter in name increments fine.

Does not work

In this scenario, the Resource that is "fetched" twice i.e. photo_specs.pdf has its counter stuck at 1.

Here I have:

[[resources]]
  src = "documents/photo_specs.pdf"
  title = "Photo Specifications"
[[resources]]
  src = "**.pdf"
  name = "pdf-file-:counter"

The difference from the "Works" case is that, here I first set the title for "documents/photo_specs.pdf".

The behavior is strange though.. it could be understood if the name rule had no effect on the Name of "documents/photo_specs.pdf".. assuming that Name was set implicitly in the first rule. The problem is that the Name does get almost set as per the name rule but the count is always stuck at 1.

In summary, if a resource is fetched by an src filter earlier, the :counter messes up if set in a later rule.

Or, to put it another way, it seems like :counter can be used only in the set of rules that first "fetches" a resources.

I hope all that made sense.. It was a bit complicated to explain the issue.


Other

PS: Is it true that :counter is designed to work only in title and name, but not in params?

@bep

This comment has been minimized.

Copy link
Member

bep commented Jan 26, 2018

PS: Is it true that :counter is designed to work only in title and name, but not in params?

Yes. But for the other questions, use the forum.

@bep bep closed this Jan 26, 2018

@kaushalmodi

This comment has been minimized.

Copy link
Member Author

kaushalmodi commented Jan 26, 2018

Alright, I'll post on the forums, but I've done a lot of testing.. the results don't seem right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.