vue-expandable-image icon indicating copy to clipboard operation
vue-expandable-image copied to clipboard

Need SSR Support

Open cavinpabua opened this issue 5 years ago • 6 comments

vue-expandable-image.js line 226 has a document.head but using SSR will throw an error document is not defined

cavinpabua avatar Jan 17 '20 10:01 cavinpabua

Indeed it would make sense to display the <img /> itself on the server side.

augnustin avatar Feb 05 '20 13:02 augnustin

Is there at least a workaround that anyone can suggest? I'm using nuxt and facing the same issue with SSR.

abhishekfinhawk avatar Aug 10 '20 06:08 abhishekfinhawk

I did use:

        <client-only>
          <expandable-image class="no-stretch bg-click" :src="img" :close-on-background-click="true"></expandable-image>
        </client-only>

Along with the following in the plugins repository:

import Vue from 'vue';
import VueExpandableImage from 'vue-expandable-image';

Vue.use(VueExpandableImage);

And nuxt.config.js:

  plugins: [
    { src: '~/plugins/expandable-image', mode: 'client' },
  ],

But indeed, no SSR <img /> tag for now. :unamused:

augnustin avatar Aug 31 '20 08:08 augnustin

@augnustin Does anyone know how I'd use this with Nuxt for a static site? The expandable image works with dev script but not nuxt generate

keshprad avatar Aug 10 '21 21:08 keshprad

I did use:

        <client-only>
          <expandable-image class="no-stretch bg-click" :src="img" :close-on-background-click="true"></expandable-image>
        </client-only>

Along with the following in the plugins repository:

import Vue from 'vue';
import VueExpandableImage from 'vue-expandable-image';

Vue.use(VueExpandableImage);

And nuxt.config.js:

  plugins: [
    { src: '~/plugins/expandable-image', mode: 'client' },
  ],

But indeed, no SSR <img /> tag for now. 😒

Hello, I still get the same error - no plugin found. Is this path really correct? ~/plugins/expandable-image

matichek avatar Nov 18 '21 11:11 matichek

You need to create a file called expandable-image.js inside the plugin folder (if the folder is not already there, create one in the project root) that contains:

import Vue from 'vue';
import VueExpandableImage from 'vue-expandable-image';

Vue.use(VueExpandableImage);

Michael-Francalanci avatar Apr 30 '22 10:04 Michael-Francalanci