resources.GetMatch does not match upper case directory name

Hello everyone, I am currently trying to implement a 3D model library website. To display the models, i use the Online 3D Viewer by kovacsv.

Background

After switching from mounting the module from the npm directory as that was causing a nil pointer ( see on this branch), I switched to using a single minified js file placed in the asset dir as shown in this branch.

What is the issue

After correctly importing the file in the head of the website, I use this code to search any file with the *.step extension and display it in a basic viewer window.

<div class="content">
    <form class="d-flex" role="search">
        <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
        <button class="btn btn-outline-success" type="submit">Search</button>
    </form>
    <div class="models">
        {{ with resources.GetMatch "3D/*.step" }}
        <div class="online_3d_viewer" style="width: 800px; height: 600px;" model="{{ .RelPermalink }}">
        {{ end }}
        </div>
        
    </div>

</div>

when running a debug server however, hugo outputs the div as this

    <div class="models">
        
        </div>

do you now what could cause it?

Thanks in advance

Your .step file resides inside the directory assets/3D. It’s the name 3D of your directory that prevents a match. Rename your directory to mydir (lowercase letters) and your file will show up.

Probably, you want to range over all files in the directory, I guess:

{{ range resources.Match "mydir/*.step" }}
    <div model="{{ .RelPermalink }}">
{{ end }}

Thx it does work now, the code is correctly built by Hugo but the model isn’t still shown. I will check if this comes from Hugo or from the viewer and will then mark the answer as solution

This is a known issue. See the first item in this list:

https://github.com/gohugoio/hugo/issues?q=is%3Aopen+label%3ABug+sort%3Areactions-%2B1-desc

Please use lower case paths within the assets directory.

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