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

Search is broken #132

Closed
reubenscratton opened this issue Oct 5, 2023 · 9 comments
Closed

Search is broken #132

reubenscratton opened this issue Oct 5, 2023 · 9 comments
Labels
needs more info The issue needs more information

Comments

@reubenscratton
Copy link

Enabling search in site config while using Hexstra theme causes a build error:

Error: error building site: EXECUTE-AS-TEMPLATE: failed to transform "json/search-data.json" (application/json): 
template: json/search-data.json:10:15: executing "json/search-data.json" at <partial "utils/fragments" $page>: 
error calling partial: ".../imfing/hextra@v0.3.0/layouts/partials/utils/fragments.html:39:62": execute of template failed: 
template: partials/utils/fragments.html:39:62: executing "partials/utils/fragments.html" 
at <markdownify>: error calling markdownify: runtime error: slice bounds out of range [:640] with capacity 512

Steps To Reproduce

  1. Get a fresh clone of https://github.com/imfing/hextra-starter-template
  2. Edit hugo.yaml and set params.search.enable to true.
  3. Try to build and serve the site. The command I use is hugo server --logLevel debug --disableFastRender -p 1313 --noHTTPCache.

Environment

  • Hugo Version: 0.118.2
  • Browser/OS: MacOS 14.0
  • Theme Version: 0.3.0
@imfing
Copy link
Owner

imfing commented Oct 5, 2023

I'll look into it, but so far I couldn't reproduce the issue.

@imfing imfing added the question Further information is requested label Oct 7, 2023
@pascalwhoop
Copy link

ran into this as well while adding this shortcode:
https://gohugo.io/templates/shortcode-templates/

when removing the shortcode it still seems to work but otherwise, my build fails

@imfing
Copy link
Owner

imfing commented Oct 8, 2023

ran into this as well while adding this shortcode:

https://gohugo.io/templates/shortcode-templates/

when removing the shortcode it still seems to work but otherwise, my build fails

Can you help share the shortcode and the content you were adding that triggered the issue?

@pascalwhoop
Copy link

sure.

{{ $img := .Page.Resources.GetMatch (printf "*%s*" (.Get 0)) }}
{{ $command := .Get 1 }}
{{ $options := .Get 2 }}
{{ if eq $command "Fit"}}
  {{ $img = $img.Fit $options }}
{{ else if eq $command "Resize"}}
  {{ $img = $img.Resize $options }}
{{ else if eq $command "Fill"}}
  {{ $img = $img.Fill $options }}
{{ else if eq $command "Crop"}}
  {{ $img = $img.Crop $options }}
{{ else }}
  {{ errorf "Invalid image processing command: Must be one of Crop, Fit, Fill or Resize."}}
{{ end }}
<figure style="padding: 0.25rem; margin: 2rem 0; background-color: #cccc">
  <img style="max-width: 100%; width: auto; height: auto;" src="{{ $img.RelPermalink }}" width="{{ $img.Width }}" height="{{ $img.Height }}">
  <figcaption>
  <small>
    {{ with .Inner }}
      {{ . }}
    {{ else }}
      .{{ $command }} "{{ $options }}"
    {{ end }}
  </small>
  </figcaption>
</figure>
{{< imgproc sunset Resize "300x" />}}

@imfing
Copy link
Owner

imfing commented Oct 8, 2023

@pascalwhoop I could not re-produce the issue with the snippet you provided.

$ hugo version
hugo v0.117.0-b2f0696cad918fb61420a6aff173eb36662b406e+extended linux/amd64 BuildDate=2023-08-07T12:49:48Z VendorInfo=brew

I was running the hextra-starter-template using the above Hugo version inside a Gitpod box Ubuntu 22.04.3 LTS.

@imfing
Copy link
Owner

imfing commented Oct 10, 2023

@pascalwhoop could you please share a repository that reproduces the issue you're encountering? This will help me in diagnosing and resolving the problem more effectively.

@imfing imfing added needs more info The issue needs more information and removed question Further information is requested labels Oct 11, 2023
@pascalwhoop
Copy link

pascalwhoop commented Oct 16, 2023

@imfing I pushed something here.
Thx for looking at it. Likely just a hugo error that non-hugo pros just don't recognise. But weird to debug nonetheless
https://github.com/pascalwhoop/curiloo.com/tree/bug/markdownify

@pascalwhoop
Copy link

Found the error. I had a custom fimg shortcode that makes images more efficient. But the markdownify extension breaks the lookup of the page bundles. Putting a if $img around the code of the shortcode helped. The images still show but the search doesn't break. I guess logging a warning would still be nice for UX but this fixes the markdownify call in your fragments page

@imfing
Copy link
Owner

imfing commented Oct 18, 2023

But the markdownify extension breaks the lookup of the page bundles. Putting a if $img around the code of the shortcode helped.

glad you figured this out! I'll close this issue

I guess logging a warning would still be nice for UX but this fixes the markdownify call in your fragments page

I agree, but logging for Hugo built-in function like markdownify can be a bit tricky

@imfing imfing closed this as completed Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info The issue needs more information
Projects
None yet
Development

No branches or pull requests

3 participants