kirby3-static-site-generator icon indicating copy to clipboard operation
kirby3-static-site-generator copied to clipboard

Wrong baseUrl for some elements

Open dimejo opened this issue 1 year ago • 1 comments

I have build a small project that is supposed to be a boilerplate for future static sites with Kirby. The project only consists of Kirby 4, the Starterkit and kirby3-static-site-generator. The site is automatically build by running a build.php script via Github Actions and then deployed to Github Pages. Everything is working well but I noticed that some images are not loaded because 'https://d4l-ssg-base-url' is used as $baseUrl instead of '/kirby-tailwind-static'.

Screenshot 2024-02-14 174542

URLs having this issue: https://dimejo.github.io/kirby-tailwind-static/about/ https://dimejo.github.io/kirby-tailwind-static/notes/exploring-the-universe/

The corresponding code seems to be generated by this snippet, but as I'm completely new to Kirby I have no idea what is going on.

dimejo avatar Feb 14 '24 16:02 dimejo

Hi, thank you for reporting the issue. Unfortunately I'm severely lacking the time at the moment but I will look into this in a couple of weeks. Thank you for linking the repo for reproducing the issue, that will help a lot with debugging.

jonathan-reisdorf avatar Feb 28 '24 15:02 jonathan-reisdorf

Hi, sorry for the late response. The issue here lies in https://github.com/dimejo/kirby-tailwind-static/blob/main/site/snippets/image.php#L11 which you copied from the new starterkit. The snippet escapes the image url which then breaks the part of the site generator which replaces the temporary full/absolute base url (which is needed for kirby) with the one you've set up.

You can solve this on your side by not using esc in conjunction with src or href. In your concrete example, that means replacing https://github.com/dimejo/kirby-tailwind-static/blob/main/site/snippets/image.php#L11 with

    src="<?= $src ?>"

jonathan-reisdorf avatar May 01 '24 05:05 jonathan-reisdorf

@jonathan-reisdorf: Thanks for the pointer. Using the esc() helper works, but not in combination with 'attr' it seems. What confused me was the fact that it works on a live site, but not with this plugin. Hence I suspected a bug in this plugin.

dimejo avatar May 18 '24 08:05 dimejo