summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/snippets/index.js
blob: 654856f8d14b3008aae3e3990499bcc4381bd561 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Vue from 'vue';
import Translate from '~/vue_shared/translate';
import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql';

import SnippetsApp from './components/app.vue';

Vue.use(VueApollo);
Vue.use(Translate);

export default () => {
  const el = document.getElementById('js-snippet-view');

  if (!el) {
    return false;
  }

  const { snippetGid } = el.dataset;
  const apolloProvider = new VueApollo({
    defaultClient: createDefaultClient(),
  });

  return new Vue({
    el,
    apolloProvider,
    render(createElement) {
      return createElement(SnippetsApp, {
        props: {
          snippetGid,
        },
      });
    },
  });
};