0.2.2 • Published 4 years ago

vue-trustpilot v0.2.2

Weekly downloads
546
License
ISC
Repository
github
Last release
4 years ago

vue-trustpilot

Plugin to create Trustpilot widgets in an easy way.

Install

npm install vue-trustpilot --save

How to use it:

Add the static trustpilot script

<script
  src="https://widget.trustpilot.com/bootstrap/v5/tp.widget.bootstrap.min.js"
  async=""
></script>
import TrustpilotPlugin from "vue-trustpilot";

const carouselWidget = {
  templateId: "XXXX",
  businessunitId: "XXXXX",
  reviewUrl: "trustpilot.review.com/mywebsite.com",
  locale: "en-us"
  // ...more Trstupilot options in camel case
};

const reviewsListWidget = {
  templateId: "XXXX",
  businessunitId: "XXXXX",
  reviewUrl: "trustpilot.review.com/mywebsite.com",
  locale: "en-us"
  // ...more Trstupilot options in camel case
};

const options = {
  widgets: {
    carousel: carouselWidget,
    list: reviewsListWidget
  }
};

Vue.use(TrustpilotPlugin, options);

The Plugin going to register the component vue-trustpilot globally.

In your Vue component:

<template>
  <vue-trustpilot identifier="carousel" />
</template>

Also, you can add more custom trustpilot arguments directly:

<template>
  <vue-trustpilot
    identifier="carousel"
    data-theme="light"
    data-schema-type="Organization"
    data-stars="1,2,3,4,5"
  />
</template>

The result:

npm.io

Additionally you can access to your widgets data using the method $trustpilot in Vue global scope

<script>
 export default {
   methods: {
     printWidgetData() {
      console.log(this.$trustpilot('carousel'))
     }
   }
  }

Nuxt

// trustpilot.js
const config = {
  widgets: {
    carousel: carouselWidget,
    list: reviewsListWidget
  }
};

module.exports = config;
// nuxt.config.js

const trustpilot = require("./trustpilot");

const config = {
  modules: [["vue-trustpilot/nuxt", trustpilot]]
};

NOTE: For Nuxt module is not needed to add the truspilot script

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.3

4 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago