Really a question, not an issue. I set canonical at the App.vue level (root) but would like to remove the tag under certain conditions in child comps (like when we set something to noindex,nofollow).
Is there any way for a child comp to remove the parent meta tag? It seems like vmid would REPLACE it, but I'd like to totally nuke it. I'd like to not use any trickery via Vuex and would like to stay in vue-meta land if possible :)
Unfortunately this is not possible. Do you have a suggestion how this would work?
Eg currently vue-meta works by deepmerging all the metaInfo objects of the components on a page, which means by design that adding/overwriting works but deleting wont unless we introduce a special case of meta.content === false
@manniL Wdyt about this? I think #204 is similar
@pimlie Not sure whether that would add too much complexity :thinking:
I think this should work by ignoring source when source[contentKeyName] === false or source.innerHTML === false in arrayMerge and when we delete data properties in getComponentOption when there are false so they dont get deepmerged.
@pimlie I'd probably tend to use null for it as false could be a valid value :thinking: But yeah, that sounds like a decent approach :clap:
Is false a valid value or 'false'? Because we actually need two falsy values to differentiate between nuking the parents vmid (this issue) or ignoring the childs (issue 204). I would propose to use null for this issue and false for 204, but you might have a better idea?
@pimlie hmm. good question, don't know by heart.
hm.. couldn't we use undefined for "No content" and null (or false?) for nuking? :relaxed:
I think that'd be closer to the semantic expressions for undefined and null
@manniL The only problem I have with undefined is that given a = {} then a.content is also undefined, which means you have to check for both key existence as key value. But will change it for 204
@pimlie Do we have to distinguish between a = {} and a = { content: undefined }?
It's possible I don't understand everything in this lib, but couldn't we just introduce functions or something vs magic values? To me it would make a little more sense to call removeMeta(something) and resetMeta(something) vs setting a value to null, false, etc..
Hmm, maybe its code style preference but a = {} means to me implicit behaviour and a = { content: undefined } means explicit behaviour. Personally I often like the latter because you have to indicate that you want the app to behave in a certain manner so its less likely to do stuff you didnt expect (because you didnt read the docs and really just wanted a meta tag without content like meta charset).
@hecktarzuli The problem with that is where are those functions defined and when are they called? If you have multiple branches with components which define metaInfo then vue-meta will merge all the metaInfo's into one single object. Are those functions called after all the merging has taken place or immediately when a parent and child are merged? And does it call both parent and child functions or only the one of the child? I agree that having functions is nicer but it complicate things and for vue-meta v3 we will probably refactor everything from the ground up anyway. So therefore using null, false is a quick and easy solution for now :)
This issue has been closed as changes for it are included in the v2 release candidate. Please help us testing the release candidate and report any follow-ups in a new issue
We'll have to check it out, thank you!
Most helpful comment
@pimlie I'd probably tend to use
nullfor it as false could be a valid value :thinking: But yeah, that sounds like a decent approach :clap: