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

union, complement, symdiff, and intersect not working with resource collections #13181

Closed
rnwst opened this issue Dec 22, 2024 · 2 comments · Fixed by #13182
Closed

union, complement, symdiff, and intersect not working with resource collections #13181

rnwst opened this issue Dec 22, 2024 · 2 comments · Fixed by #13182
Assignees
Milestone

Comments

@rnwst
Copy link

rnwst commented Dec 22, 2024

Description

As per the title, the set methods provided for collections do not seem to work with global resources. For example:

{{- $styles := resources.Match "css/**.css" }}
{{- $katex := resources.Match "css/**katex*" }}
{{- $complement := complement $katex $styles }}

Here, $complement contains all resources from $styles, not excluding those also found in $katex. The functions union, symdiff, and intersect malfunction in similar ways. intersect seems to return an empty collection, irrespective of the resource collections provided.

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.140.0+extended linux/amd64 BuildDate=unknown
@jmooring
Copy link
Member

To clarify, this works fine:

{{ $a := resources.Get "a.jpg" }}
{{ $b := resources.Get "b.jpg" }}
{{ $c := resources.Get "c.jpg" }}
{{ $d := resources.Get "d.jpg" }}

{{ $abcd := slice $a $b $c $d }}
{{ $cd := slice $c $d}}

{{ $abcd | complement $cd }}

But these do not:

{{ $match := resources.Match "*" }}
{{ $match | complement $cd }}

{{ $byType := resources.ByType "image"}}
{{ $byType | complement $cd }}

The problem occurs when working with the collections created by resources.Match and resources.ByType.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants