-
Notifications
You must be signed in to change notification settings - Fork 34
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
fix: add whitelist prop to HeadProvider #84
base: master
Are you sure you want to change the base?
Conversation
<HeadProvider/> accepts additional prop `whitelist` which accepts a CSS selector string to disable `data-rh` for identification on whitelisted tags As mentioned here tizmagik#40 based on nfl/react-helmet#79
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey this seems really neat @CanRau -- thanks for submitting the PR! Also excited to hear about a potential gatsby-plugin-react-head
, that's pretty cool!
Question about the whitelist API and then I think this will need some additional tests to cover the changes, otherwise this LGTM and I'd be happy to add this additional capability.
Kay takes array instead of string now 👍 Got a side question, still haven't been able to publish the website including the gatsby-plugin yet, so nothing to link to for now. Edit: Uh, I forgot the tests, looking into them now |
Kay added some tests, I'm still not as much into testing as I would love to be, so let me know if they're okay and sufficient like this or what else I could improve 🙏 |
Like so https://github.com/tizmagik/react-head/pull/84/files#diff-04c6e90faac2675aa89e2176d2eec7d8R88 ? Should I merge in the latest commit, with the |
@tizmagik Any update on a possible merge? Should I merge the last changes to master beforehand? |
Hey sorry @CanRau , I haven't forgotten about this! Curious if you think getting started on that gatsby plugin before this is released against |
The plugin is basically done https://github.com/GaiAma/Coding4GaiAma/tree/master/packages/gatsby-plugin-react-head Yeah I guess I can get the plugin published, only thing I'm not sure, how are people going to use this PR then before it's merged? I've got a local fork in the same repo to make it work Or did I misunderstand your request? You're interested in the plugin being used more to know if that API makes sense like this right? |
Yes I can release under a |
Awesome than I update the plugin to depend on |
@CanRau ok this is available now as |
…feature/disable-data-rh
…d into feature/disable-data-rh
Awesome thank you 🙏 Don't worry all good 👍 I'm testing it locally right now...for whatever reason my plugin broke..I'll have breakfast now and then figure out how to fix it.. By the way I hope I didn't mess up those merges 😕 |
I released from your branch at this commit, 8ba9786 I can do another release at the latest commit if you'd like. Let me know |
…d into pr/CanRau/84
I'm embarrassed to say I have no idea what's wrong 😭 I've got a separate directory on my machine with the fork I used to update the tests etc and push changes to this PR. When
Even more confusing, When I manually wrap I'm pretty confused and don't know what I'm doing wrong |
Hey no worries, I appreciate your efforts here and I'm sure we'll figure out what's going on, there's no rush 😁 If I find some time I'll try and dig in and try to repro. Where is the gatsby plugin/what repro steps could I look at? |
Wow, that was a long time, didn't expect that, I know you said "no worries" yet I'm sorry for just "disappearing" 🤦♂ a lot going on here in the jungle right now, then my mom is visiting us and they're cutting electricity for about 15 days from next Saturday it seems 😦 So if you find time and curiosity to try to repro it I'd say this would be the easiest GaiAma/Coding4GaiAma cause it should contain everything I'll return as quick as possible which might take another couple of weeks unfortunately though Thanks a lot for your patience 🙏 See you soon'ish 💯 |
Not a problem at all. There’s no rush on this so take your time. My wife and I actually just had our baby girl so I will be out on parental leave for several weeks anyway 😊 |
Congratulations 🎉 enjoy yourselves then ❤️ |
Long time no see 😱 How are you and your family doing? 😀 I have to admit I'm not sure what was going on when I last worked on this feature 🤷♂️
As
Where Do you have any thoughts on this or ideas? Cause I think turning that whitelist into just tags would be too loose and we're using it in Thought I could come up with a clever |
Maybe const whitelist = {
title: true,
meta: [
{ attr: 'name', value: 'description' },
{ attr: 'property', value: 'og:*' },
],
} basic globbing/regex support? Or just do a ''.startsWith() to compare const whitelist = {
title: true,
meta: {
name: 'description',
property: 'og:*',
},
} And we could provide a default |
Hmm... admittedly I'm context switching a bunch and haven't been working too closely to this code, but I wonder if we could somehow support this with an elegant API rather than an explicit whitelist (would that be more desirable?) What do you think about having it as a prop on each react-head element so you can opt-in/out as you go? import { Meta } from 'react-head';
<Meta name="example" content="whatever" whitelist /> Maybe I think this approach may require additional context to be passed in on the client render, so not sure if that's more or less desirable. Thoughts? |
Interesting, yea I think I like that a lot better as it makes it more explicit. Wait, I'm a little confused now ^^ That API would then kind of auto generate the whitelist correct? |
The issue is, as to how react-head works currently, it only manages tags that it knows that it created (e.g. tags with I think I have an idea of how to manage this. Let me write up a separate issue (and I'll post back here) with more details, and we can discuss/vote on options there. Give me a few minutes... |
Wrote up a quick RFC: #97 |
<HeadProvider/>
accepts additional propwhitelist
which takes a CSS selector string (used indocument.querySelector
) to disabledata-rh
for identification on whitelisted tagsAs mentioned here #40
based on nfl/react-helmet#79
As it doesn't seem too heavy, I think it's a good addition which could make many former
react-helmet
users pretty happyI plan another PR soon'ish🤞 to add support for html & body attributes as mentioned here #40
I'm working on a new website for our org right now and am evaluating plugins one by one, not just copying everything from the main website.
If all this gets merged I would publish a
gatsby-plugin-react-head
, I've already prepared, which could makereact-head
more interesting to many gatsbys 💜Edit: Forget to mention that I'm of course open to feedback about everything.
For example I'm not sure about
whitelist
being the best name, so any suggestions are highly appreciated 🙏 and code style changes are welcome as well, it's kind of a POC..