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

Is it just me, or is the search path unclear when calling shortcodes from markdown? #2225

Closed
JohnEmhoff opened this issue Jun 5, 2023 · 4 comments

Comments

@JohnEmhoff
Copy link
Contributor

JohnEmhoff commented Jun 5, 2023

I spent a frustrating hour or two trying to figure out how the path parameter is interpreted in {{ resize_image(path=...) }}. I was a little surprised it seems different from the markdown itself (which will find co-located assets without issue). I finally strace-d it and discovered that it searches, in this order:

  1. / (i.e. the root of the zola project)
  2. static/
  3. content/
  4. public/
  5. themes/current-theme/static

The absence of CWD (i.e., the directory containing the .md file) is what triggered this odyssey. Is this a peculiarity of resize_image, or is this fundamental to zola? Either way the behavior is surprising to me and I didn't see it in the docs. Happy to provide a PR if you'd like.

@Keats
Copy link
Collaborator

Keats commented Jun 5, 2023

As you found out, it searches through that: https://github.com/getzola/zola/blob/master/components/templates/src/global_fns/helpers.rs#L7-L18 and doesn't now from where it's being called.
Is the example in https://www.getzola.org/documentation/content/shortcodes/#page-or-section not enough for colocated images or are you trying to do something different?

@JohnEmhoff
Copy link
Contributor Author

JohnEmhoff commented Jun 5, 2023

Is the example in https://www.getzola.org/documentation/content/shortcodes/#page-or-section not enough for colocated images or are you trying to do something different?

I think that example is partially the source of my confusion. I tried to do something like {{ resize_image(path=page.colocated_path ~ ...,) }} but it would fail silently because (I think?) the concatenation is illegal in the markdown and must be done in the template. At the time I couldn't figure out exactly what was happening -- the site would successfully build but the braced statement would render directly into my page.

I also don't see the search order listed there?

@Keats
Copy link
Collaborator

Keats commented Jun 5, 2023

Ah yes, you can't do any Tera stuff in the markdown. I'll take PRs to clear up the docs though.

I also don't see the search order listed there?

It's kind of an implementation detail. If you think it helps understanding, we can add it to the docs

@JohnEmhoff
Copy link
Contributor Author

Cool, just submitted #2227

@Keats Keats closed this as completed Jun 23, 2023
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

No branches or pull requests

2 participants