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

Add a way to set link header on specific entries #83

Open
HugoImaios opened this issue Feb 15, 2024 · 3 comments
Open

Add a way to set link header on specific entries #83

HugoImaios opened this issue Feb 15, 2024 · 3 comments

Comments

@HugoImaios
Copy link

HugoImaios commented Feb 15, 2024

Description

Hello !

Using preload: link-header is great but it adds too much in the link header in my opinion.
To add only specific entries, I tried two solutions:

  • use different bundle configurations (a regular one, and one for addingto link header) as per the doc but it's not possible, because the preload config entry is not available as per multiple configuration (it's only available on root configuration) as per the configuration file on github lol
  • use RenderAssetTagEvent as per the doc . It worked, by adding a custom "i-want-that-in-link-header" attr, and in the RenderAssetTagEvent subscriber, checking for this attribute and adding the ref attribute to link header via the SF weblink component

The second solution is not that bad, but it would be nice to have another associative array of options next to attr to avoid messing with the existing and legitimates attributes.
But imo, the best solution would be to have the preload: link-header available on "sub" configurations.

Let me know what you think about it, and if you have any questions,

Hugo

Example

No response

@lhapaipai
Copy link
Owner

Hi @HugoImaios,
I think I would lean more towards the 2nd solution. your expectation is precise and it seems to me that the first solution provides an answer but in many cases will not be sufficient while the second would at least have the merit of providing a solution for all cases. Indeed this does not protect us from modifying existing attributes, but I do not think that this is a problem unless we wish to define headers different from the html attributes. Are there any cases where this could happen?

@HugoImaios
Copy link
Author

Indeed I'm not sure it's a problem, but I'm not very comfortable with the idea of adding an attribute "i-want-this-in-link-header" just to flag this tag and not use the attribute. (in fact, I even remove it for the tag in my RenderAssetTagEvent)

@HugoImaios
Copy link
Author

I think that the best solution we be to put it in a separate parameter called something like contextOptions, next to attr which would be clearly used only for html attributes.

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