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

Shortcodes are not reloading when inner resources are changed #6177

Closed
totkeks opened this issue Aug 7, 2019 · 8 comments
Closed

Shortcodes are not reloading when inner resources are changed #6177

totkeks opened this issue Aug 7, 2019 · 8 comments

Comments

@totkeks
Copy link

totkeks commented Aug 7, 2019

I have a shortcode to show HTML code examples, both rendered by the browser and the actual code. To keep the examples working properly, I place them and their styles inside a shadow DOM, so the browser ignores the global styles.
This is done by requesting the stylesheet (built in a process parallel to the hugo serve process) as a resource and then passing the link to a javascript that then places it in the shadow dom on creation.
It looks something like this:

{{- $styles := resources.Get "dist/main.min.css" | fingerprint -}}
<template class="example" data-styles="{{ $styles.Permalink }}">

The problem now is, that when the main.min.css file changes, the shortcode using it, is not rebuilt. So I don't see updated styles in my content pages that contain the HTML code examples.
My assumption now is, that the shortcode is not rebuilt, because it does not see the resource as a dependency. Because if I touch the shortcode file, then hugo rebuilds it and the updated css file will be loaded.

@bep bep added the Enhancement label Aug 7, 2019
@bep bep added this to the v0.58 milestone Aug 7, 2019
@bep
Copy link
Member

bep commented Aug 7, 2019

This is a known current limitation (I think there is a similar issue floating around).

But it isn't easily solved.

So what I suggest you do in the meantime is something ala:

{{- $styles := resources.Get "dist/main.min.css" -}}
{{ if eq hugo.Environment "production" }}
{{- $styles = $styles | fingerprint -}}
{{ end }}

@totkeks
Copy link
Author

totkeks commented Aug 7, 2019

Thanks for your reply! Unfortunately that does not work for me. It still didn't rebuild the shortcode, when I rebuilt the main.min.css.
What I did instead now as a workaround, is touching (just triggering a read/write) the shortcode file after the main.min.css has been built.
This works, even though it is not a nice way to achieve it.

@bep
Copy link
Member

bep commented Aug 7, 2019

It still didn't rebuild the shortcode, when I rebuilt the main.min.css.

I don't see why it would need to rebuild the shortcode when it's not changing anything, but good you found a way.

@THS-on
Copy link

THS-on commented Aug 9, 2019

Is this the same limitation with data from the data folder?
If I change something in a file that is under data the shortcode is not updated that uses that data.
Is there a workaround for this other than touching the shortcode after a file update?

@bep bep modified the milestones: v0.58, v0.59 Aug 13, 2019
@bep bep modified the milestones: v0.59, v0.60 Sep 6, 2019
@gpit2286
Copy link

gpit2286 commented Oct 4, 2019

I'm also running into this. I have dynamically generated png's and when the data.json file updates, Hugo reloads the page but doesn't reload the data from the json file.

@bep What about this is hard to implement? I may help give us a better understanding of how to "fix" it.

@bep bep modified the milestones: v0.60, v0.61 Oct 21, 2019
@bep bep modified the milestones: v0.61, v0.62, v0.63 Nov 25, 2019
@bep bep modified the milestones: v0.63, v0.64 Dec 11, 2019
@bep bep modified the milestones: v0.64, v0.65 Jan 22, 2020
@bep bep modified the milestones: v0.65, v0.66 Jan 30, 2020
@bep bep modified the milestones: v0.66, v0.67 Mar 2, 2020
@bep bep modified the milestones: v0.67, v0.68 Mar 9, 2020
@bep bep modified the milestones: v0.68, v0.69 Mar 20, 2020
@bep bep removed this from the v0.69 milestone Apr 8, 2020
@bep bep added this to the v0.117.0 milestone Aug 1, 2023
@bep bep modified the milestones: v0.117.0, v0.118.0 Aug 30, 2023
@bep bep modified the milestones: v0.118.0, v0.119.0 Sep 15, 2023
@bep bep modified the milestones: v0.119.0, v0.120.0 Oct 4, 2023
@bep bep modified the milestones: v0.120.0, v0.121.0 Oct 31, 2023
@bep bep modified the milestones: v0.121.0, v0.122.0 Dec 6, 2023
@bep bep modified the milestones: v0.122.0, v0.123.0, v0.124.0 Jan 27, 2024
@bep bep modified the milestones: v0.124.0, v0.125.0 Mar 4, 2024
@bep bep modified the milestones: v0.125.0, v0.126.0 Apr 23, 2024
@bep bep modified the milestones: v0.126.0, v0.127.0 May 15, 2024
@bep bep modified the milestones: v0.127.0, v0.128.0 Jun 8, 2024
@bep
Copy link
Member

bep commented Jun 21, 2024

I'm pretty sure this one should be fixed by now.

@bep bep closed this as completed Jun 21, 2024
@bep bep modified the milestones: v0.128.0, v0.129.0 Jun 21, 2024
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants