nuxt / vue-meta

Manage HTML metadata in Vue.js components with SSR support
https://vue-meta.nuxtjs.org
Other
4.08k stars 247 forks source link

Request for inline comments #241

Open davutkara opened 6 years ago

davutkara commented 6 years ago

Sometimes need to add the code below for ie browser.

<!--[if IE]>
<![endif]>

It can be added like this.

{
  metaInfo: {
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      '<!--[if IE]>',
      { name: 'script', src:'index.js'}
      '<![endif]>'
    ]
  }
}

I tried to make on my branch to make pull-request but, I got some dependency errors.

hecktarzuli commented 5 years ago

Total sidebar: Does your app really need support IE10? These tags are not supported in IE11/Edge.

davutkara commented 5 years ago

@hecktarzuli This feature can be needed for other purpose. I think if the item of meta array is string, add string directly. Also there are a few people who uses old IE browsers.

pimlie commented 5 years ago

This might cause a problem when using multiple child components which set the same vmid and only one has the comments defined. Not sure if we can guarantee the correct order in that case when everything is merged

@manniL Wdyt? We could also add prefix / suffix attributes (which maybe only work on ssr?)

manniL commented 5 years ago

I'm not sure if it's worth the hassle implementing it as it only helps With IE < 11. People using Nuxt can always use a custom AppView (HTML file) anyway.

pimlie commented 5 years ago

I have added the target: v3 label because if we are going to refactor vue-meta as proposed then it should probably be supported by default already (using vue 3.0 fragments)

shaunc commented 4 years ago

I'm trying to include a fragment such as below (from stackoverflow). Is there another way to do this with vue-meta, or should I look for another solution, while waiting on this branch? (My intention is to not support IE -- and explicitly navigate users somewhere else to tell them it isn't supported.)

<!-- For IE <= 9 -->
<!--[if IE]>
<script type="text/javascript">
    window.location = "https://google.com";
</script>
<![endif]-->

<!-- For IE > 9 -->
<script type="text/javascript">
    if (window.navigator.msPointerEnabled) {
        window.location = "https://google.com";
    }
</script>
manniL commented 4 years ago

I'm trying to include a fragment such as below (from stackoverflow). Is there another way to do this with vue-meta, or should I look for another solution, while waiting on this branch? (My intention is to not support IE -- and explicitly navigate users somewhere else to tell them it isn't supported.)

<!-- For IE <= 9 -->
<!--[if IE]>
<script type="text/javascript">
    window.location = "https://google.com";
</script>
<![endif]-->

<!-- For IE > 9 -->
<script type="text/javascript">
    if (window.navigator.msPointerEnabled) {
        window.location = "https://google.com";
    }
</script>

You can detect IE in other ways with pure JS btw.

export default {
  data () {
    return {
      isInternetExplorer: false
    }
  },
  beforeMount () {
    this.isInternetExplorer = Boolean(document.documentMode)
  }
}
shaunc commented 4 years ago

The problem is that my vue code doesn't run on IE. Perhaps if I were to dumb down the javascript dialect and/or fiddle with babel it would work, but I'd prefer just to redirect. Should be simple(?)

pimlie commented 4 years ago

@shaunc Are you using Nuxt.js? Then you could include this static piece of code in your app template

If you are not using Nuxt then you will probably still have a similar app template file that you use with ssr, so you should be able to apply the same fix. Look up the docs of the framework you are using.

shaunc commented 4 years ago

Ah -- cool; I am using Nuxt. I overlooked the "app template" setting. Thank you!

1isten commented 4 years ago

People using Nuxt can always use a custom AppView (HTML file) anyway.

@manniL Do you mean we can use a custom HTML file as the template (like the public/index.html in vue-cli)? If yes, how?

1isten commented 4 years ago

@manniL Oh I just found the doc: https://nuxtjs.org/guide/views/#app-template