nuxt-community / svg-module

Super simple svg loading module for Nuxt.js
MIT License
340 stars 35 forks source link

Passing alternative content to dynamically imported SVGs #77

Open retroriff opened 3 years ago

retroriff commented 3 years ago

To dynamically import an SVG, we can use the inline require() syntax.

<template>
  <div v-html="require(`../assets/${name}.svg?raw`)" />
</template>

<script>
  export default {
    props: {
      name: { type: String, default: "image" },
    },
  };
</script>

As far as I now, this method does not allow to dynamically pass a title and a description to the inline SVG, which would be great for accessibility on multilanguage sites.