Giter VIP home page Giter VIP logo

Comments (4)

pawroman avatar pawroman commented on June 5, 2024 1

Thanks @goingforbrooke -- much appreciated!

from zola-theme-terminimal.

goingforbrooke avatar goingforbrooke commented on June 5, 2024

Initial findings

Using page.colocated_path in the image.html shortcode fixes the issue for (@ipetkov's) post-directory style, but breaks images for the post-markdown style (where images are stored in static/).

Fix Attempt

terminimal/templates/shortcodes/image.html

...
{# ... then convert the page's colocated_path ident to a string so it can be concatenated. #}
{% set page_path = page.colocated_path | as_str %}
{# ... and prepend the site's base URL to the image's URL. #}
{% set src = config.base_url ~ page_path ~ src %}
...

Fix Notes

I had to use as_str on page.colocated_path to prevent a concatenation error.

Error: Reason: Tried to concat a value that is not a string or a number from ident page.colocated_path

The page.colocated_path shortcode variable only has the name of the post's parent directory, so we still have to use config.base_url to get the full path to the image. I'm probably missing something about asset search paths and shortcodes, but Zola's issues show that I'm in good company-- the docs for shortcodes were updated just seven hours ago.

Next Steps

Zola promises the same asset-finding logic between markdown-post and directory-post styles. Maybe the shortcode needs some conditional logic for post-directory and post-markdown styles?

from zola-theme-terminimal.

goingforbrooke avatar goingforbrooke commented on June 5, 2024

Actually, this fix only breaks post-markdown style images if a mix of the two styles are used. As long as I stick to post-markdown or post-directory for the content of a post, everything's fine. It's almost as if Zola takes the first image shortcode as its cue for where it should look for images in the rest of the blog post.

It's not pretty but is that a satisfactory fix for now, @pawroman?

from zola-theme-terminimal.

goingforbrooke avatar goingforbrooke commented on June 5, 2024

Created a draft PR with the fix.

from zola-theme-terminimal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.