11ty / eleventy-base-blog

A starter repository for a blog web site using the Eleventy static site generator.
https://demo-base-blog.11ty.dev/
MIT License
1.23k stars 619 forks source link

Dynamic content inside {% image %} shortcode? #142

Closed cozarkd closed 1 year ago

cozarkd commented 1 year ago

I'm trying to implement features of this project inside mine.

I would like to start with images but I'm not sure how to use the shortcode inside a .liquid file that I use as a partial/include.

<a href="{{ item.url }}" class="l-card__thumb">
  {% image "{{ item.data.f_imagen.url }}", "{{ item.data.f_imagen.alt }}" %}
  <!--<img src="{{ item.data.f_imagen.url }}" alt="{{ item.data.f_imagen.alt }}" loading="lazy" class="o-plant__img">-->
</a>

Commented is the old code. I think it makes sense but ofc I'm not understanding properly because I get an error while building.

1. Having trouble writing to "_site/index.html" from "./src/pages/index.md" (via EleventyTemplateError)
[11ty] 2. ENOENT: no such file or directory, stat '/Users/user/Documents/GitHub/project/src/pages/{{ item.data.f_imagen.url }}', file:/Users/user/Documents/GitHub/project/src/_includes/c-card.liquid, line:4, col:11 (via RenderError)
[11ty] 3. ENOENT: no such file or directory, stat '/Users/user/Documents/GitHub/project/src/pages/{{ item.data.f_imagen.url }}' (via Error)

Any ideas? What about css classes?

zachleat commented 1 year ago

{% image item.data.f_imagen.url, item.data.f_imagen.alt %} should be the magic you need!

zachleat commented 1 year ago

This is an automated message to let you know that a helpful response was posted to your issue and for the health of the repository issue tracker the issue will be closed. This is to help alleviate issues hanging open waiting for a response from the original poster.

If the response works to solve your problem—great! But if you’re still having problems, do not let the issue’s closing deter you if you have additional questions! Post another comment and we will reopen the issue. Thanks!